documentation.d.ts 3.9 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451694526945369454694556945669457694586945969460694616946269463694646946569466694676946869469694706947169472694736947469475694766947769478694796948069481694826948369484694856948669487694886948969490694916949269493694946949569496694976949869499695006950169502695036950469505695066950769508695096951069511695126951369514695156951669517695186951969520695216952269523695246952569526695276952869529695306953169532695336953469535695366953769538695396954069541695426954369544695456954669547695486954969550695516955269553695546955569556695576955869559695606956169562695636956469565695666956769568695696957069571695726957369574695756957669577695786957969580695816958269583695846958569586695876958869589695906959169592695936959469595695966959769598695996960069601696026960369604696056960669607696086960969610696116961269613696146961569616696176961869619696206962169622696236962469625696266962769628696296963069631696326963369634696356963669637696386963969640696416964269643696446964569646696476964869649696506965169652696536965469655696566965769658696596966069661696626966369664696656966669667696686966969670696716967269673696746967569676696776967869679696806968169682696836968469685696866968769688696896969069691696926969369694696956969669697696986969969700697016970269703697046970569706697076970869709697106971169712697136971469715697166971769718697196972069721697226972369724697256972669727697286972969730697316973269733697346973569736697376973869739697406974169742697436974469745697466974769748697496975069751697526975369754697556975669757697586975969760697616976269763697646976569766697676976869769697706977169772697736977469775697766977769778697796978069781697826978369784697856978669787697886978969790697916979269793697946979569796697976979869799698006980169802698036980469805698066980769808698096981069811698126981369814698156981669817698186981969820698216982269823698246982569826698276982869829698306983169832698336983469835698366983769838698396984069841698426984369844698456984669847698486984969850698516985269853698546985569856698576985869859698606986169862698636986469865698666986769868698696987069871698726987369874698756987669877698786987969880698816988269883698846988569886698876988869889698906989169892698936989469895698966989769898698996990069901699026990369904699056990669907699086990969910699116991269913699146991569916699176991869919699206992169922699236992469925699266992769928699296993069931699326993369934699356993669937699386993969940699416994269943699446994569946699476994869949699506995169952699536995469955699566995769958699596996069961699626996369964699656996669967699686996969970699716997269973699746997569976699776997869979699806998169982699836998469985699866998769988699896999069991699926999369994699956999669997699986999970000700017000270003700047000570006700077000870009700107001170012700137001470015700167001770018700197002070021700227002370024700257002670027700287002970030700317003270033700347003570036700377003870039700407004170042700437004470045700467004770048700497005070051700527005370054700557005670057700587005970060700617006270063700647006570066700677006870069700707007170072700737007470075700767007770078700797008070081700827008370084700857008670087700887008970090700917009270093700947009570096700977009870099701007010170102701037010470105701067010770108701097011070111701127011370114701157011670117701187011970120701217012270123701247012570126701277012870129701307013170132701337013470135701367013770138701397014070141701427014370144701457014670147701487014970150701517015270153701547015570156701577015870159701607016170162701637016470165701667016770168701697017070171701727017370174701757017670177701787017970180701817018270183701847018570186701877018870189701907019170192701937019470195701967019770198701997020070201702027020370204702057020670207702087020970210702117021270213702147021570216702177021870219702207022170222702237022470225702267022770228702297023070231702327023370234702357023670237702387023970240702417024270243702447024570246702477024870249702507025170252702537025470255702567025770258702597026070261702627026370264702657026670267702687026970270702717027270273702747027570276702777027870279702807028170282702837028470285702867028770288702897029070291702927029370294702957029670297702987029970300703017030270303703047030570306703077030870309703107031170312703137031470315703167031770318703197032070321703227032370324703257032670327703287032970330703317033270333703347033570336703377033870339703407034170342703437034470345703467034770348703497035070351703527035370354703557035670357703587035970360703617036270363703647036570366703677036870369703707037170372703737037470375703767037770378703797038070381703827038370384703857038670387703887038970390703917039270393703947039570396703977039870399704007040170402704037040470405704067040770408704097041070411704127041370414704157041670417704187041970420704217042270423704247042570426704277042870429704307043170432704337043470435704367043770438704397044070441704427044370444704457044670447704487044970450704517045270453704547045570456704577045870459704607046170462704637046470465704667046770468704697047070471704727047370474704757047670477704787047970480704817048270483704847048570486704877048870489704907049170492704937049470495704967049770498704997050070501705027050370504705057050670507705087050970510705117051270513705147051570516705177051870519705207052170522705237052470525705267052770528705297053070531705327053370534705357053670537705387053970540705417054270543705447054570546705477054870549705507055170552705537055470555705567055770558705597056070561705627056370564705657056670567705687056970570705717057270573705747057570576705777057870579705807058170582705837058470585705867058770588705897059070591705927059370594705957059670597705987059970600706017060270603706047060570606706077060870609706107061170612706137061470615706167061770618706197062070621706227062370624706257062670627706287062970630706317063270633706347063570636706377063870639706407064170642706437064470645706467064770648706497065070651706527065370654706557065670657706587065970660706617066270663706647066570666706677066870669706707067170672706737067470675706767067770678706797068070681706827068370684706857068670687706887068970690706917069270693706947069570696706977069870699707007070170702707037070470705707067070770708707097071070711707127071370714707157071670717707187071970720707217072270723707247072570726707277072870729707307073170732707337073470735707367073770738707397074070741707427074370744707457074670747707487074970750707517075270753707547075570756707577075870759707607076170762707637076470765707667076770768707697077070771707727077370774707757077670777707787077970780707817078270783707847078570786707877078870789707907079170792707937079470795707967079770798707997080070801708027080370804708057080670807708087080970810708117081270813708147081570816708177081870819708207082170822708237082470825708267082770828708297083070831708327083370834708357083670837708387083970840708417084270843708447084570846708477084870849708507085170852708537085470855708567085770858708597086070861708627086370864708657086670867708687086970870708717087270873708747087570876708777087870879708807088170882708837088470885708867088770888708897089070891708927089370894708957089670897708987089970900709017090270903709047090570906709077090870909709107091170912709137091470915709167091770918709197092070921709227092370924709257092670927709287092970930709317093270933709347093570936709377093870939709407094170942709437094470945709467094770948709497095070951709527095370954709557095670957709587095970960709617096270963709647096570966709677096870969709707097170972709737097470975709767097770978709797098070981709827098370984709857098670987709887098970990709917099270993709947099570996709977099870999710007100171002710037100471005710067100771008710097101071011710127101371014710157101671017710187101971020710217102271023710247102571026710277102871029710307103171032710337103471035710367103771038710397104071041710427104371044710457104671047710487104971050710517105271053710547105571056710577105871059710607106171062710637106471065710667106771068710697107071071710727107371074710757107671077710787107971080710817108271083710847108571086710877108871089710907109171092710937109471095710967109771098710997110071101711027110371104711057110671107711087110971110711117111271113711147111571116711177111871119711207112171122711237112471125711267112771128711297113071131711327113371134711357113671137711387113971140711417114271143711447114571146711477114871149711507115171152711537115471155711567115771158711597116071161711627116371164711657116671167711687116971170711717117271173711747117571176711777117871179711807118171182711837118471185711867118771188711897119071191711927119371194711957119671197711987119971200712017120271203712047120571206712077120871209712107121171212712137121471215712167121771218712197122071221712227122371224712257122671227712287122971230712317123271233712347123571236712377123871239712407124171242712437124471245712467124771248712497125071251712527125371254712557125671257712587125971260712617126271263712647126571266712677126871269712707127171272712737127471275712767127771278712797128071281712827128371284712857128671287712887128971290712917129271293712947129571296712977129871299713007130171302713037130471305713067130771308713097131071311713127131371314713157131671317713187131971320713217132271323713247132571326713277132871329713307133171332713337133471335713367133771338713397134071341713427134371344713457134671347713487134971350713517135271353713547135571356713577135871359713607136171362713637136471365713667136771368713697137071371713727137371374713757137671377713787137971380713817138271383713847138571386713877138871389713907139171392713937139471395713967139771398713997140071401714027140371404714057140671407714087140971410714117141271413714147141571416714177141871419714207142171422714237142471425714267142771428714297143071431714327143371434714357143671437714387143971440714417144271443714447144571446714477144871449714507145171452714537145471455714567145771458714597146071461714627146371464714657146671467714687146971470714717147271473714747147571476714777147871479714807148171482714837148471485714867148771488714897149071491714927149371494714957149671497714987149971500715017150271503715047150571506715077150871509715107151171512715137151471515715167151771518715197152071521715227152371524715257152671527715287152971530715317153271533715347153571536715377153871539715407154171542715437154471545715467154771548715497155071551715527155371554715557155671557715587155971560715617156271563715647156571566715677156871569715707157171572715737157471575715767157771578715797158071581715827158371584715857158671587715887158971590715917159271593715947159571596715977159871599716007160171602716037160471605716067160771608716097161071611716127161371614716157161671617716187161971620716217162271623716247162571626716277162871629716307163171632716337163471635716367163771638716397164071641716427164371644716457164671647716487164971650716517165271653716547165571656716577165871659716607166171662716637166471665716667166771668716697167071671716727167371674716757167671677716787167971680716817168271683716847168571686716877168871689716907169171692716937169471695716967169771698716997170071701717027170371704717057170671707717087170971710717117171271713717147171571716717177171871719717207172171722717237172471725717267172771728717297173071731717327173371734717357173671737717387173971740717417174271743717447174571746717477174871749717507175171752717537175471755717567175771758717597176071761717627176371764717657176671767717687176971770717717177271773717747177571776717777177871779717807178171782717837178471785717867178771788717897179071791717927179371794717957179671797717987179971800718017180271803718047180571806718077180871809718107181171812718137181471815718167181771818718197182071821718227182371824718257182671827718287182971830718317183271833718347183571836718377183871839718407184171842718437184471845718467184771848718497185071851718527185371854718557185671857718587185971860718617186271863718647186571866718677186871869718707187171872718737187471875718767187771878718797188071881718827188371884718857188671887718887188971890718917189271893718947189571896718977189871899719007190171902719037190471905719067190771908719097191071911719127191371914719157191671917719187191971920719217192271923719247192571926719277192871929719307193171932719337193471935719367193771938719397194071941719427194371944719457194671947719487194971950719517195271953719547195571956719577195871959719607196171962719637196471965719667196771968719697197071971719727197371974719757197671977719787197971980719817198271983719847198571986719877198871989719907199171992719937199471995719967199771998719997200072001720027200372004720057200672007720087200972010720117201272013720147201572016720177201872019720207202172022720237202472025720267202772028720297203072031720327203372034720357203672037720387203972040720417204272043720447204572046720477204872049720507205172052720537205472055720567205772058720597206072061720627206372064720657206672067720687206972070720717207272073720747207572076720777207872079720807208172082720837208472085720867208772088720897209072091720927209372094720957209672097720987209972100721017210272103721047210572106721077210872109721107211172112721137211472115721167211772118721197212072121721227212372124721257212672127721287212972130721317213272133721347213572136721377213872139721407214172142721437214472145721467214772148721497215072151721527215372154721557215672157721587215972160721617216272163721647216572166721677216872169721707217172172721737217472175721767217772178721797218072181721827218372184721857218672187721887218972190721917219272193721947219572196721977219872199722007220172202722037220472205722067220772208722097221072211722127221372214722157221672217722187221972220722217222272223722247222572226722277222872229722307223172232722337223472235722367223772238722397224072241722427224372244722457224672247722487224972250722517225272253722547225572256722577225872259722607226172262722637226472265722667226772268722697227072271722727227372274722757227672277722787227972280722817228272283722847228572286722877228872289722907229172292722937229472295722967229772298722997230072301723027230372304723057230672307723087230972310723117231272313723147231572316723177231872319723207232172322723237232472325723267232772328723297233072331723327233372334723357233672337723387233972340723417234272343723447234572346723477234872349723507235172352723537235472355723567235772358723597236072361723627236372364723657236672367723687236972370723717237272373723747237572376723777237872379723807238172382723837238472385723867238772388723897239072391723927239372394723957239672397723987239972400724017240272403724047240572406724077240872409724107241172412724137241472415724167241772418724197242072421724227242372424724257242672427724287242972430724317243272433724347243572436724377243872439724407244172442724437244472445724467244772448724497245072451724527245372454724557245672457724587245972460724617246272463724647246572466724677246872469724707247172472724737247472475724767247772478724797248072481724827248372484724857248672487724887248972490724917249272493724947249572496724977249872499725007250172502725037250472505725067250772508725097251072511725127251372514725157251672517725187251972520725217252272523725247252572526725277252872529725307253172532725337253472535725367253772538725397254072541725427254372544725457254672547725487254972550725517255272553725547255572556725577255872559725607256172562725637256472565725667256772568725697257072571725727257372574725757257672577725787257972580725817258272583725847258572586725877258872589725907259172592725937259472595725967259772598725997260072601726027260372604726057260672607726087260972610726117261272613726147261572616726177261872619726207262172622726237262472625726267262772628726297263072631726327263372634726357263672637726387263972640726417264272643726447264572646726477264872649726507265172652726537265472655726567265772658726597266072661726627266372664726657266672667726687266972670726717267272673726747267572676726777267872679726807268172682726837268472685726867268772688726897269072691726927269372694726957269672697726987269972700727017270272703727047270572706727077270872709727107271172712727137271472715727167271772718727197272072721727227272372724727257272672727727287272972730727317273272733727347273572736727377273872739727407274172742727437274472745727467274772748727497275072751727527275372754727557275672757727587275972760727617276272763727647276572766727677276872769727707277172772727737277472775727767277772778727797278072781727827278372784727857278672787727887278972790727917279272793727947279572796727977279872799728007280172802728037280472805728067280772808728097281072811728127281372814728157281672817728187281972820728217282272823728247282572826728277282872829728307283172832728337283472835728367283772838728397284072841728427284372844728457284672847728487284972850728517285272853728547285572856728577285872859728607286172862728637286472865728667286772868728697287072871728727287372874728757287672877728787287972880728817288272883728847288572886728877288872889728907289172892728937289472895728967289772898728997290072901729027290372904729057290672907729087290972910729117291272913729147291572916729177291872919729207292172922729237292472925729267292772928729297293072931729327293372934729357293672937729387293972940729417294272943729447294572946729477294872949729507295172952729537295472955729567295772958729597296072961729627296372964729657296672967729687296972970729717297272973729747297572976729777297872979729807298172982729837298472985729867298772988729897299072991729927299372994729957299672997729987299973000730017300273003730047300573006730077300873009730107301173012730137301473015730167301773018730197302073021730227302373024730257302673027730287302973030730317303273033730347303573036730377303873039730407304173042730437304473045730467304773048730497305073051730527305373054730557305673057730587305973060730617306273063730647306573066730677306873069730707307173072730737307473075730767307773078730797308073081730827308373084730857308673087730887308973090730917309273093730947309573096730977309873099731007310173102731037310473105731067310773108731097311073111731127311373114731157311673117731187311973120731217312273123731247312573126731277312873129731307313173132731337313473135731367313773138731397314073141731427314373144731457314673147731487314973150731517315273153731547315573156731577315873159731607316173162731637316473165731667316773168731697317073171731727317373174731757317673177731787317973180731817318273183731847318573186731877318873189731907319173192731937319473195731967319773198731997320073201732027320373204732057320673207732087320973210732117321273213732147321573216732177321873219732207322173222732237322473225732267322773228732297323073231732327323373234732357323673237732387323973240732417324273243732447324573246732477324873249732507325173252732537325473255732567325773258732597326073261732627326373264732657326673267732687326973270732717327273273732747327573276732777327873279732807328173282732837328473285732867328773288732897329073291732927329373294732957329673297732987329973300733017330273303733047330573306733077330873309733107331173312733137331473315733167331773318733197332073321733227332373324733257332673327733287332973330733317333273333733347333573336733377333873339733407334173342733437334473345733467334773348733497335073351733527335373354733557335673357733587335973360733617336273363733647336573366733677336873369733707337173372733737337473375733767337773378733797338073381733827338373384733857338673387733887338973390733917339273393733947339573396733977339873399734007340173402734037340473405734067340773408734097341073411734127341373414734157341673417734187341973420734217342273423734247342573426734277342873429734307343173432734337343473435734367343773438734397344073441734427344373444734457344673447734487344973450734517345273453734547345573456734577345873459734607346173462734637346473465734667346773468734697347073471734727347373474734757347673477734787347973480734817348273483734847348573486734877348873489734907349173492734937349473495734967349773498734997350073501735027350373504735057350673507735087350973510735117351273513735147351573516735177351873519735207352173522735237352473525735267352773528735297353073531735327353373534735357353673537735387353973540735417354273543735447354573546735477354873549735507355173552735537355473555735567355773558735597356073561735627356373564735657356673567735687356973570735717357273573735747357573576735777357873579735807358173582735837358473585735867358773588735897359073591735927359373594735957359673597735987359973600736017360273603736047360573606736077360873609736107361173612736137361473615736167361773618736197362073621736227362373624736257362673627736287362973630736317363273633736347363573636736377363873639736407364173642736437364473645736467364773648736497365073651736527365373654736557365673657736587365973660736617366273663736647366573666736677366873669736707367173672736737367473675736767367773678736797368073681736827368373684736857368673687736887368973690736917369273693736947369573696736977369873699737007370173702737037370473705737067370773708737097371073711737127371373714737157371673717737187371973720737217372273723737247372573726737277372873729737307373173732737337373473735737367373773738737397374073741737427374373744737457374673747737487374973750737517375273753737547375573756737577375873759737607376173762737637376473765737667376773768737697377073771737727377373774737757377673777737787377973780737817378273783737847378573786737877378873789737907379173792737937379473795737967379773798737997380073801738027380373804738057380673807738087380973810738117381273813738147381573816738177381873819738207382173822738237382473825738267382773828738297383073831738327383373834738357383673837738387383973840738417384273843738447384573846738477384873849738507385173852738537385473855738567385773858738597386073861738627386373864738657386673867738687386973870738717387273873738747387573876738777387873879738807388173882738837388473885738867388773888738897389073891738927389373894738957389673897738987389973900739017390273903739047390573906739077390873909739107391173912739137391473915739167391773918739197392073921739227392373924739257392673927739287392973930739317393273933739347393573936739377393873939739407394173942739437394473945739467394773948739497395073951739527395373954739557395673957739587395973960739617396273963739647396573966739677396873969739707397173972739737397473975739767397773978739797398073981739827398373984739857398673987739887398973990739917399273993739947399573996739977399873999740007400174002740037400474005740067400774008740097401074011740127401374014740157401674017740187401974020740217402274023740247402574026740277402874029740307403174032740337403474035740367403774038740397404074041740427404374044740457404674047740487404974050740517405274053740547405574056740577405874059740607406174062740637406474065740667406774068740697407074071740727407374074740757407674077740787407974080740817408274083740847408574086740877408874089740907409174092740937409474095740967409774098740997410074101741027410374104741057410674107741087410974110741117411274113741147411574116741177411874119741207412174122741237412474125741267412774128741297413074131741327413374134741357413674137741387413974140741417414274143741447414574146741477414874149741507415174152741537415474155741567415774158741597416074161741627416374164741657416674167741687416974170741717417274173741747417574176741777417874179741807418174182741837418474185741867418774188741897419074191741927419374194741957419674197741987419974200742017420274203742047420574206742077420874209742107421174212742137421474215742167421774218742197422074221742227422374224742257422674227742287422974230742317423274233742347423574236742377423874239742407424174242742437424474245742467424774248742497425074251742527425374254742557425674257742587425974260742617426274263742647426574266742677426874269742707427174272742737427474275742767427774278742797428074281742827428374284742857428674287742887428974290742917429274293742947429574296742977429874299743007430174302743037430474305743067430774308743097431074311743127431374314743157431674317743187431974320743217432274323743247432574326743277432874329743307433174332743337433474335743367433774338743397434074341743427434374344743457434674347743487434974350743517435274353743547435574356743577435874359743607436174362743637436474365743667436774368743697437074371743727437374374743757437674377743787437974380743817438274383743847438574386743877438874389743907439174392743937439474395743967439774398743997440074401744027440374404744057440674407744087440974410744117441274413744147441574416744177441874419744207442174422744237442474425744267442774428744297443074431744327443374434744357443674437744387443974440744417444274443744447444574446744477444874449744507445174452744537445474455744567445774458744597446074461744627446374464744657446674467744687446974470744717447274473744747447574476744777447874479744807448174482744837448474485744867448774488744897449074491744927449374494744957449674497744987449974500745017450274503745047450574506745077450874509745107451174512745137451474515745167451774518745197452074521745227452374524745257452674527745287452974530745317453274533745347453574536745377453874539745407454174542745437454474545745467454774548745497455074551745527455374554745557455674557745587455974560745617456274563745647456574566745677456874569745707457174572745737457474575745767457774578745797458074581745827458374584745857458674587745887458974590745917459274593745947459574596745977459874599746007460174602746037460474605746067460774608746097461074611746127461374614746157461674617746187461974620746217462274623746247462574626746277462874629746307463174632746337463474635746367463774638746397464074641746427464374644746457464674647746487464974650746517465274653746547465574656746577465874659746607466174662746637466474665746667466774668746697467074671746727467374674746757467674677746787467974680746817468274683746847468574686746877468874689746907469174692746937469474695746967469774698746997470074701747027470374704747057470674707747087470974710747117471274713747147471574716747177471874719747207472174722747237472474725747267472774728747297473074731747327473374734747357473674737747387473974740747417474274743747447474574746747477474874749747507475174752747537475474755747567475774758747597476074761747627476374764747657476674767747687476974770747717477274773747747477574776747777477874779747807478174782747837478474785747867478774788747897479074791747927479374794747957479674797747987479974800748017480274803748047480574806748077480874809748107481174812748137481474815748167481774818748197482074821748227482374824748257482674827748287482974830748317483274833748347483574836748377483874839748407484174842748437484474845748467484774848748497485074851748527485374854748557485674857748587485974860748617486274863748647486574866748677486874869748707487174872748737487474875748767487774878748797488074881748827488374884748857488674887748887488974890748917489274893748947489574896748977489874899749007490174902749037490474905749067490774908749097491074911749127491374914749157491674917749187491974920749217492274923749247492574926749277492874929749307493174932749337493474935749367493774938749397494074941749427494374944749457494674947749487494974950749517495274953749547495574956749577495874959749607496174962749637496474965749667496774968749697497074971749727497374974749757497674977749787497974980749817498274983749847498574986749877498874989749907499174992749937499474995749967499774998749997500075001750027500375004750057500675007750087500975010750117501275013750147501575016750177501875019750207502175022750237502475025750267502775028750297503075031750327503375034750357503675037750387503975040750417504275043750447504575046750477504875049750507505175052750537505475055750567505775058750597506075061750627506375064750657506675067750687506975070750717507275073750747507575076750777507875079750807508175082750837508475085750867508775088750897509075091750927509375094750957509675097750987509975100751017510275103751047510575106751077510875109751107511175112751137511475115751167511775118751197512075121751227512375124751257512675127751287512975130751317513275133751347513575136751377513875139751407514175142751437514475145751467514775148751497515075151751527515375154751557515675157751587515975160751617516275163751647516575166751677516875169751707517175172751737517475175751767517775178751797518075181751827518375184751857518675187751887518975190751917519275193751947519575196751977519875199752007520175202752037520475205752067520775208752097521075211752127521375214752157521675217752187521975220752217522275223752247522575226752277522875229752307523175232752337523475235752367523775238752397524075241752427524375244752457524675247752487524975250752517525275253752547525575256752577525875259752607526175262752637526475265752667526775268752697527075271752727527375274752757527675277752787527975280752817528275283752847528575286752877528875289752907529175292752937529475295752967529775298752997530075301753027530375304753057530675307753087530975310753117531275313753147531575316753177531875319753207532175322753237532475325753267532775328753297533075331753327533375334753357533675337753387533975340753417534275343753447534575346753477534875349753507535175352753537535475355753567535775358753597536075361753627536375364753657536675367753687536975370753717537275373753747537575376753777537875379753807538175382753837538475385753867538775388753897539075391753927539375394753957539675397753987539975400754017540275403754047540575406754077540875409754107541175412754137541475415754167541775418754197542075421754227542375424754257542675427754287542975430754317543275433754347543575436754377543875439754407544175442754437544475445754467544775448754497545075451754527545375454754557545675457754587545975460754617546275463754647546575466754677546875469754707547175472754737547475475754767547775478754797548075481754827548375484754857548675487754887548975490754917549275493754947549575496754977549875499755007550175502755037550475505755067550775508755097551075511755127551375514755157551675517755187551975520755217552275523755247552575526755277552875529755307553175532755337553475535755367553775538755397554075541755427554375544755457554675547755487554975550755517555275553755547555575556755577555875559755607556175562755637556475565755667556775568755697557075571755727557375574755757557675577755787557975580755817558275583755847558575586755877558875589755907559175592755937559475595755967559775598755997560075601756027560375604756057560675607756087560975610756117561275613756147561575616756177561875619756207562175622756237562475625756267562775628756297563075631756327563375634756357563675637756387563975640756417564275643756447564575646756477564875649756507565175652756537565475655756567565775658756597566075661756627566375664756657566675667756687566975670756717567275673756747567575676756777567875679756807568175682756837568475685756867568775688756897569075691756927569375694756957569675697756987569975700757017570275703757047570575706757077570875709757107571175712757137571475715757167571775718757197572075721757227572375724757257572675727757287572975730757317573275733757347573575736757377573875739757407574175742757437574475745757467574775748757497575075751757527575375754757557575675757757587575975760757617576275763757647576575766757677576875769757707577175772757737577475775757767577775778757797578075781757827578375784757857578675787757887578975790757917579275793757947579575796757977579875799758007580175802758037580475805758067580775808758097581075811758127581375814758157581675817758187581975820758217582275823758247582575826758277582875829758307583175832758337583475835758367583775838758397584075841758427584375844758457584675847758487584975850758517585275853758547585575856758577585875859758607586175862758637586475865758667586775868758697587075871758727587375874758757587675877758787587975880758817588275883758847588575886758877588875889758907589175892758937589475895758967589775898758997590075901759027590375904759057590675907759087590975910759117591275913759147591575916759177591875919759207592175922759237592475925759267592775928759297593075931759327593375934759357593675937759387593975940759417594275943759447594575946759477594875949759507595175952759537595475955759567595775958759597596075961759627596375964759657596675967759687596975970759717597275973759747597575976759777597875979759807598175982759837598475985759867598775988759897599075991759927599375994759957599675997759987599976000760017600276003760047600576006760077600876009760107601176012760137601476015760167601776018760197602076021760227602376024760257602676027760287602976030760317603276033760347603576036760377603876039760407604176042760437604476045760467604776048760497605076051760527605376054760557605676057760587605976060760617606276063760647606576066760677606876069760707607176072760737607476075760767607776078760797608076081760827608376084760857608676087760887608976090760917609276093760947609576096760977609876099761007610176102761037610476105761067610776108761097611076111761127611376114761157611676117761187611976120761217612276123761247612576126761277612876129761307613176132761337613476135761367613776138761397614076141761427614376144761457614676147761487614976150761517615276153761547615576156761577615876159761607616176162761637616476165761667616776168761697617076171761727617376174761757617676177761787617976180761817618276183761847618576186761877618876189761907619176192761937619476195761967619776198761997620076201762027620376204762057620676207762087620976210762117621276213762147621576216762177621876219762207622176222762237622476225762267622776228762297623076231762327623376234762357623676237762387623976240762417624276243762447624576246762477624876249762507625176252762537625476255762567625776258762597626076261762627626376264762657626676267762687626976270762717627276273762747627576276762777627876279762807628176282762837628476285762867628776288762897629076291762927629376294762957629676297762987629976300763017630276303763047630576306763077630876309763107631176312763137631476315763167631776318763197632076321763227632376324763257632676327763287632976330763317633276333763347633576336763377633876339763407634176342763437634476345763467634776348763497635076351763527635376354763557635676357763587635976360763617636276363763647636576366763677636876369763707637176372763737637476375763767637776378763797638076381763827638376384763857638676387763887638976390763917639276393763947639576396763977639876399764007640176402764037640476405764067640776408764097641076411764127641376414764157641676417764187641976420764217642276423764247642576426764277642876429764307643176432764337643476435764367643776438764397644076441764427644376444764457644676447764487644976450764517645276453764547645576456764577645876459764607646176462764637646476465764667646776468764697647076471764727647376474764757647676477764787647976480764817648276483764847648576486764877648876489764907649176492764937649476495764967649776498764997650076501765027650376504765057650676507765087650976510765117651276513765147651576516765177651876519765207652176522765237652476525765267652776528765297653076531765327653376534765357653676537765387653976540765417654276543765447654576546765477654876549765507655176552765537655476555765567655776558765597656076561765627656376564765657656676567765687656976570765717657276573765747657576576765777657876579765807658176582765837658476585765867658776588765897659076591765927659376594765957659676597765987659976600766017660276603766047660576606766077660876609766107661176612766137661476615766167661776618766197662076621766227662376624766257662676627766287662976630766317663276633766347663576636766377663876639766407664176642766437664476645766467664776648766497665076651766527665376654766557665676657766587665976660766617666276663766647666576666766677666876669766707667176672766737667476675766767667776678766797668076681766827668376684766857668676687766887668976690766917669276693766947669576696766977669876699767007670176702767037670476705767067670776708767097671076711767127671376714767157671676717767187671976720767217672276723767247672576726767277672876729767307673176732767337673476735767367673776738767397674076741767427674376744767457674676747767487674976750767517675276753767547675576756767577675876759767607676176762767637676476765767667676776768767697677076771767727677376774767757677676777767787677976780767817678276783767847678576786767877678876789767907679176792767937679476795767967679776798767997680076801768027680376804768057680676807768087680976810768117681276813768147681576816768177681876819768207682176822768237682476825768267682776828768297683076831768327683376834768357683676837768387683976840768417684276843768447684576846768477684876849768507685176852768537685476855768567685776858768597686076861768627686376864768657686676867768687686976870768717687276873768747687576876768777687876879768807688176882768837688476885768867688776888768897689076891768927689376894768957689676897768987689976900769017690276903769047690576906769077690876909769107691176912769137691476915769167691776918769197692076921769227692376924769257692676927769287692976930769317693276933769347693576936769377693876939769407694176942769437694476945769467694776948769497695076951769527695376954769557695676957769587695976960769617696276963769647696576966769677696876969769707697176972769737697476975769767697776978769797698076981769827698376984769857698676987769887698976990769917699276993769947699576996769977699876999770007700177002770037700477005770067700777008770097701077011770127701377014770157701677017770187701977020770217702277023770247702577026770277702877029770307703177032770337703477035770367703777038770397704077041770427704377044770457704677047770487704977050770517705277053770547705577056770577705877059770607706177062770637706477065770667706777068770697707077071770727707377074770757707677077770787707977080770817708277083770847708577086770877708877089770907709177092770937709477095770967709777098770997710077101771027710377104771057710677107771087710977110771117711277113771147711577116771177711877119771207712177122771237712477125771267712777128771297713077131771327713377134771357713677137771387713977140771417714277143771447714577146771477714877149771507715177152771537715477155771567715777158771597716077161771627716377164771657716677167771687716977170771717717277173771747717577176771777717877179771807718177182771837718477185771867718777188771897719077191771927719377194771957719677197771987719977200772017720277203772047720577206772077720877209772107721177212772137721477215772167721777218772197722077221772227722377224772257722677227772287722977230772317723277233772347723577236772377723877239772407724177242772437724477245772467724777248772497725077251772527725377254772557725677257772587725977260772617726277263772647726577266772677726877269772707727177272772737727477275772767727777278772797728077281772827728377284772857728677287772887728977290772917729277293772947729577296772977729877299773007730177302773037730477305773067730777308773097731077311773127731377314773157731677317773187731977320773217732277323773247732577326773277732877329773307733177332773337733477335773367733777338773397734077341773427734377344773457734677347773487734977350773517735277353773547735577356773577735877359773607736177362773637736477365773667736777368773697737077371773727737377374773757737677377773787737977380773817738277383773847738577386773877738877389773907739177392773937739477395773967739777398773997740077401774027740377404774057740677407774087740977410774117741277413774147741577416774177741877419774207742177422774237742477425774267742777428774297743077431774327743377434774357743677437774387743977440774417744277443774447744577446774477744877449774507745177452774537745477455774567745777458774597746077461774627746377464774657746677467774687746977470774717747277473774747747577476774777747877479774807748177482774837748477485774867748777488774897749077491774927749377494774957749677497774987749977500775017750277503775047750577506775077750877509775107751177512775137751477515775167751777518775197752077521775227752377524775257752677527775287752977530775317753277533775347753577536775377753877539775407754177542775437754477545775467754777548775497755077551775527755377554775557755677557775587755977560775617756277563775647756577566775677756877569775707757177572775737757477575775767757777578775797758077581775827758377584775857758677587775887758977590775917759277593775947759577596775977759877599776007760177602776037760477605776067760777608776097761077611776127761377614776157761677617776187761977620776217762277623776247762577626776277762877629776307763177632776337763477635776367763777638776397764077641776427764377644776457764677647776487764977650776517765277653776547765577656776577765877659776607766177662776637766477665776667766777668776697767077671776727767377674776757767677677776787767977680776817768277683776847768577686776877768877689776907769177692776937769477695776967769777698776997770077701777027770377704777057770677707777087770977710777117771277713777147771577716777177771877719777207772177722777237772477725777267772777728777297773077731777327773377734777357773677737777387773977740777417774277743777447774577746777477774877749777507775177752777537775477755777567775777758777597776077761777627776377764777657776677767777687776977770777717777277773777747777577776777777777877779777807778177782777837778477785777867778777788777897779077791777927779377794777957779677797777987779977800778017780277803778047780577806778077780877809778107781177812778137781477815778167781777818778197782077821778227782377824778257782677827778287782977830778317783277833778347783577836778377783877839778407784177842778437784477845778467784777848778497785077851778527785377854778557785677857778587785977860778617786277863778647786577866778677786877869778707787177872778737787477875778767787777878778797788077881778827788377884778857788677887778887788977890778917789277893778947789577896778977789877899779007790177902779037790477905779067790777908779097791077911779127791377914779157791677917779187791977920779217792277923779247792577926779277792877929779307793177932779337793477935779367793777938779397794077941779427794377944779457794677947779487794977950779517795277953779547795577956779577795877959779607796177962779637796477965779667796777968779697797077971779727797377974779757797677977779787797977980779817798277983779847798577986779877798877989779907799177992779937799477995779967799777998779997800078001780027800378004780057800678007780087800978010780117801278013780147801578016780177801878019780207802178022780237802478025780267802778028780297803078031780327803378034780357803678037780387803978040780417804278043780447804578046780477804878049780507805178052780537805478055780567805778058780597806078061780627806378064780657806678067780687806978070780717807278073780747807578076780777807878079780807808178082780837808478085780867808778088780897809078091780927809378094780957809678097780987809978100781017810278103781047810578106781077810878109781107811178112781137811478115781167811778118781197812078121781227812378124781257812678127781287812978130781317813278133781347813578136781377813878139781407814178142781437814478145781467814778148781497815078151781527815378154781557815678157781587815978160781617816278163781647816578166781677816878169781707817178172781737817478175781767817778178781797818078181781827818378184781857818678187781887818978190781917819278193781947819578196781977819878199782007820178202782037820478205782067820778208782097821078211782127821378214782157821678217782187821978220782217822278223782247822578226782277822878229782307823178232782337823478235782367823778238782397824078241782427824378244782457824678247782487824978250782517825278253782547825578256782577825878259782607826178262782637826478265782667826778268782697827078271782727827378274782757827678277782787827978280782817828278283782847828578286782877828878289782907829178292782937829478295782967829778298782997830078301783027830378304783057830678307783087830978310783117831278313783147831578316783177831878319783207832178322783237832478325783267832778328783297833078331783327833378334783357833678337783387833978340783417834278343783447834578346783477834878349783507835178352783537835478355783567835778358783597836078361783627836378364783657836678367783687836978370783717837278373783747837578376783777837878379783807838178382783837838478385783867838778388783897839078391783927839378394783957839678397783987839978400784017840278403784047840578406784077840878409784107841178412784137841478415784167841778418784197842078421784227842378424784257842678427784287842978430784317843278433784347843578436784377843878439784407844178442784437844478445784467844778448784497845078451784527845378454784557845678457784587845978460784617846278463784647846578466784677846878469784707847178472784737847478475784767847778478784797848078481784827848378484784857848678487784887848978490784917849278493784947849578496784977849878499785007850178502785037850478505785067850778508785097851078511785127851378514785157851678517785187851978520785217852278523785247852578526785277852878529785307853178532785337853478535785367853778538785397854078541785427854378544785457854678547785487854978550785517855278553785547855578556785577855878559785607856178562785637856478565785667856778568785697857078571785727857378574785757857678577785787857978580785817858278583785847858578586785877858878589785907859178592785937859478595785967859778598785997860078601786027860378604786057860678607786087860978610786117861278613786147861578616786177861878619786207862178622786237862478625786267862778628786297863078631786327863378634786357863678637786387863978640786417864278643786447864578646786477864878649786507865178652786537865478655786567865778658786597866078661786627866378664786657866678667786687866978670786717867278673786747867578676786777867878679786807868178682786837868478685786867868778688786897869078691786927869378694786957869678697786987869978700787017870278703787047870578706787077870878709787107871178712787137871478715787167871778718787197872078721787227872378724787257872678727787287872978730787317873278733787347873578736787377873878739787407874178742787437874478745787467874778748787497875078751787527875378754787557875678757787587875978760787617876278763787647876578766787677876878769787707877178772787737877478775787767877778778787797878078781787827878378784787857878678787787887878978790787917879278793787947879578796787977879878799788007880178802788037880478805788067880778808788097881078811788127881378814788157881678817788187881978820788217882278823788247882578826788277882878829788307883178832788337883478835788367883778838788397884078841788427884378844788457884678847788487884978850788517885278853788547885578856788577885878859788607886178862788637886478865788667886778868788697887078871788727887378874788757887678877788787887978880788817888278883788847888578886788877888878889788907889178892788937889478895788967889778898788997890078901789027890378904789057890678907789087890978910789117891278913789147891578916789177891878919789207892178922789237892478925789267892778928789297893078931789327893378934789357893678937789387893978940789417894278943789447894578946789477894878949789507895178952789537895478955789567895778958789597896078961789627896378964789657896678967789687896978970789717897278973789747897578976789777897878979789807898178982789837898478985789867898778988789897899078991789927899378994789957899678997789987899979000790017900279003790047900579006790077900879009790107901179012790137901479015790167901779018790197902079021790227902379024790257902679027790287902979030790317903279033790347903579036790377903879039790407904179042790437904479045790467904779048790497905079051790527905379054790557905679057790587905979060790617906279063790647906579066790677906879069790707907179072790737907479075790767907779078790797908079081790827908379084790857908679087790887908979090790917909279093790947909579096790977909879099791007910179102791037910479105791067910779108791097911079111791127911379114791157911679117791187911979120791217912279123791247912579126791277912879129791307913179132791337913479135791367913779138791397914079141791427914379144791457914679147791487914979150791517915279153791547915579156791577915879159791607916179162791637916479165791667916779168791697917079171791727917379174791757917679177791787917979180791817918279183791847918579186791877918879189791907919179192791937919479195791967919779198791997920079201792027920379204792057920679207792087920979210792117921279213792147921579216792177921879219792207922179222792237922479225792267922779228792297923079231792327923379234792357923679237792387923979240792417924279243792447924579246792477924879249792507925179252792537925479255792567925779258792597926079261792627926379264792657926679267792687926979270792717927279273792747927579276792777927879279792807928179282792837928479285792867928779288792897929079291792927929379294792957929679297792987929979300793017930279303793047930579306793077930879309793107931179312793137931479315793167931779318793197932079321793227932379324793257932679327793287932979330793317933279333793347933579336793377933879339793407934179342793437934479345793467934779348793497935079351793527935379354793557935679357793587935979360793617936279363793647936579366793677936879369793707937179372793737937479375793767937779378793797938079381793827938379384793857938679387793887938979390793917939279393793947939579396793977939879399794007940179402794037940479405794067940779408794097941079411794127941379414794157941679417794187941979420794217942279423794247942579426794277942879429794307943179432794337943479435794367943779438794397944079441794427944379444794457944679447794487944979450794517945279453794547945579456794577945879459794607946179462794637946479465794667946779468794697947079471794727947379474794757947679477794787947979480794817948279483794847948579486794877948879489794907949179492794937949479495794967949779498794997950079501795027950379504795057950679507795087950979510795117951279513795147951579516795177951879519795207952179522795237952479525795267952779528795297953079531795327953379534795357953679537795387953979540795417954279543795447954579546795477954879549795507955179552795537955479555795567955779558795597956079561795627956379564795657956679567795687956979570795717957279573795747957579576795777957879579795807958179582795837958479585795867958779588795897959079591795927959379594795957959679597795987959979600796017960279603796047960579606796077960879609796107961179612796137961479615796167961779618796197962079621796227962379624796257962679627796287962979630796317963279633796347963579636796377963879639796407964179642796437964479645796467964779648796497965079651796527965379654796557965679657796587965979660796617966279663796647966579666796677966879669796707967179672796737967479675796767967779678796797968079681796827968379684796857968679687796887968979690796917969279693796947969579696796977969879699797007970179702797037970479705797067970779708797097971079711797127971379714797157971679717797187971979720797217972279723797247972579726797277972879729797307973179732797337973479735797367973779738797397974079741797427974379744797457974679747797487974979750797517975279753797547975579756797577975879759797607976179762797637976479765797667976779768797697977079771797727977379774797757977679777797787977979780797817978279783797847978579786797877978879789797907979179792797937979479795797967979779798797997980079801798027980379804798057980679807798087980979810798117981279813798147981579816798177981879819798207982179822798237982479825798267982779828798297983079831798327983379834798357983679837798387983979840798417984279843798447984579846798477984879849798507985179852798537985479855798567985779858798597986079861798627986379864798657986679867798687986979870798717987279873798747987579876798777987879879798807988179882798837988479885798867988779888798897989079891798927989379894798957989679897798987989979900799017990279903799047990579906799077990879909799107991179912799137991479915799167991779918799197992079921799227992379924799257992679927799287992979930799317993279933799347993579936799377993879939799407994179942799437994479945799467994779948799497995079951799527995379954799557995679957799587995979960799617996279963799647996579966799677996879969799707997179972799737997479975799767997779978799797998079981799827998379984799857998679987799887998979990799917999279993799947999579996799977999879999800008000180002800038000480005800068000780008800098001080011800128001380014800158001680017800188001980020800218002280023800248002580026800278002880029800308003180032800338003480035800368003780038800398004080041800428004380044800458004680047800488004980050800518005280053800548005580056800578005880059800608006180062800638006480065800668006780068800698007080071800728007380074800758007680077800788007980080800818008280083800848008580086800878008880089800908009180092800938009480095800968009780098800998010080101801028010380104801058010680107801088010980110801118011280113801148011580116801178011880119801208012180122801238012480125801268012780128801298013080131801328013380134801358013680137801388013980140801418014280143801448014580146801478014880149801508015180152801538015480155801568015780158801598016080161801628016380164801658016680167801688016980170801718017280173801748017580176801778017880179801808018180182801838018480185801868018780188801898019080191801928019380194801958019680197801988019980200802018020280203802048020580206802078020880209802108021180212802138021480215802168021780218802198022080221802228022380224802258022680227802288022980230802318023280233802348023580236802378023880239802408024180242802438024480245802468024780248802498025080251802528025380254802558025680257802588025980260802618026280263802648026580266802678026880269802708027180272802738027480275802768027780278802798028080281802828028380284802858028680287802888028980290802918029280293802948029580296802978029880299803008030180302803038030480305803068030780308803098031080311803128031380314803158031680317803188031980320803218032280323803248032580326803278032880329803308033180332803338033480335803368033780338803398034080341803428034380344803458034680347803488034980350803518035280353803548035580356803578035880359803608036180362803638036480365803668036780368803698037080371803728037380374803758037680377803788037980380803818038280383803848038580386803878038880389803908039180392803938039480395803968039780398803998040080401804028040380404804058040680407804088040980410804118041280413804148041580416804178041880419804208042180422804238042480425804268042780428804298043080431804328043380434804358043680437804388043980440804418044280443804448044580446804478044880449804508045180452804538045480455804568045780458804598046080461804628046380464804658046680467804688046980470804718047280473804748047580476804778047880479804808048180482804838048480485804868048780488804898049080491804928049380494804958049680497804988049980500805018050280503805048050580506805078050880509805108051180512805138051480515805168051780518805198052080521805228052380524805258052680527805288052980530805318053280533805348053580536805378053880539805408054180542805438054480545805468054780548805498055080551805528055380554805558055680557805588055980560805618056280563805648056580566805678056880569805708057180572805738057480575805768057780578805798058080581805828058380584805858058680587805888058980590805918059280593805948059580596805978059880599806008060180602806038060480605806068060780608806098061080611806128061380614806158061680617806188061980620806218062280623806248062580626806278062880629806308063180632806338063480635806368063780638806398064080641806428064380644806458064680647806488064980650806518065280653806548065580656806578065880659806608066180662806638066480665806668066780668806698067080671806728067380674806758067680677806788067980680806818068280683806848068580686806878068880689806908069180692806938069480695806968069780698806998070080701807028070380704807058070680707807088070980710807118071280713807148071580716807178071880719807208072180722807238072480725807268072780728807298073080731807328073380734807358073680737807388073980740807418074280743807448074580746807478074880749807508075180752807538075480755807568075780758807598076080761807628076380764807658076680767807688076980770807718077280773807748077580776807778077880779807808078180782807838078480785807868078780788807898079080791807928079380794807958079680797807988079980800808018080280803808048080580806808078080880809808108081180812808138081480815808168081780818808198082080821808228082380824808258082680827808288082980830808318083280833808348083580836808378083880839808408084180842808438084480845808468084780848808498085080851808528085380854808558085680857808588085980860808618086280863808648086580866808678086880869808708087180872808738087480875808768087780878808798088080881808828088380884808858088680887808888088980890808918089280893808948089580896808978089880899809008090180902809038090480905809068090780908809098091080911809128091380914809158091680917809188091980920809218092280923809248092580926809278092880929809308093180932809338093480935809368093780938809398094080941809428094380944809458094680947809488094980950809518095280953809548095580956809578095880959809608096180962809638096480965809668096780968809698097080971809728097380974809758097680977809788097980980809818098280983809848098580986809878098880989809908099180992809938099480995809968099780998809998100081001810028100381004810058100681007810088100981010810118101281013810148101581016810178101881019810208102181022810238102481025810268102781028810298103081031810328103381034810358103681037810388103981040810418104281043810448104581046810478104881049810508105181052810538105481055810568105781058810598106081061810628106381064810658106681067810688106981070810718107281073810748107581076810778107881079810808108181082810838108481085810868108781088810898109081091810928109381094810958109681097810988109981100811018110281103811048110581106811078110881109811108111181112811138111481115811168111781118811198112081121811228112381124811258112681127811288112981130811318113281133811348113581136811378113881139811408114181142811438114481145811468114781148811498115081151811528115381154811558115681157811588115981160811618116281163811648116581166811678116881169811708117181172811738117481175811768117781178811798118081181811828118381184811858118681187811888118981190811918119281193811948119581196811978119881199812008120181202812038120481205812068120781208812098121081211812128121381214812158121681217812188121981220812218122281223812248122581226812278122881229812308123181232812338123481235812368123781238812398124081241812428124381244812458124681247812488124981250812518125281253812548125581256812578125881259812608126181262812638126481265812668126781268812698127081271812728127381274812758127681277812788127981280812818128281283812848128581286812878128881289812908129181292812938129481295812968129781298812998130081301813028130381304813058130681307813088130981310813118131281313813148131581316813178131881319813208132181322813238132481325813268132781328813298133081331813328133381334813358133681337813388133981340813418134281343813448134581346813478134881349813508135181352813538135481355813568135781358813598136081361813628136381364813658136681367813688136981370813718137281373813748137581376813778137881379813808138181382813838138481385813868138781388813898139081391813928139381394813958139681397813988139981400814018140281403814048140581406814078140881409814108141181412814138141481415814168141781418814198142081421814228142381424814258142681427814288142981430814318143281433814348143581436814378143881439814408144181442814438144481445814468144781448814498145081451814528145381454814558145681457814588145981460814618146281463814648146581466814678146881469814708147181472814738147481475814768147781478814798148081481814828148381484814858148681487814888148981490814918149281493814948149581496814978149881499815008150181502815038150481505815068150781508815098151081511815128151381514815158151681517815188151981520815218152281523815248152581526815278152881529815308153181532815338153481535815368153781538815398154081541815428154381544815458154681547815488154981550815518155281553815548155581556815578155881559815608156181562815638156481565815668156781568815698157081571815728157381574815758157681577815788157981580815818158281583815848158581586815878158881589815908159181592815938159481595815968159781598815998160081601816028160381604816058160681607816088160981610816118161281613816148161581616816178161881619816208162181622816238162481625816268162781628816298163081631816328163381634816358163681637816388163981640816418164281643816448164581646816478164881649816508165181652816538165481655816568165781658816598166081661816628166381664816658166681667816688166981670816718167281673816748167581676816778167881679816808168181682816838168481685816868168781688816898169081691816928169381694816958169681697816988169981700817018170281703817048170581706817078170881709817108171181712817138171481715817168171781718817198172081721817228172381724817258172681727817288172981730817318173281733817348173581736817378173881739817408174181742817438174481745817468174781748817498175081751817528175381754817558175681757817588175981760817618176281763817648176581766817678176881769817708177181772817738177481775817768177781778817798178081781817828178381784817858178681787817888178981790817918179281793817948179581796817978179881799818008180181802818038180481805818068180781808818098181081811818128181381814818158181681817818188181981820818218182281823818248182581826818278182881829818308183181832818338183481835818368183781838818398184081841818428184381844818458184681847818488184981850818518185281853818548185581856818578185881859818608186181862818638186481865818668186781868818698187081871818728187381874818758187681877818788187981880818818188281883818848188581886818878188881889818908189181892818938189481895818968189781898818998190081901819028190381904819058190681907819088190981910819118191281913819148191581916819178191881919819208192181922819238192481925819268192781928819298193081931819328193381934819358193681937819388193981940819418194281943819448194581946819478194881949819508195181952819538195481955819568195781958819598196081961819628196381964819658196681967819688196981970819718197281973819748197581976819778197881979819808198181982819838198481985819868198781988819898199081991819928199381994819958199681997819988199982000820018200282003820048200582006820078200882009820108201182012820138201482015820168201782018820198202082021820228202382024820258202682027820288202982030820318203282033820348203582036820378203882039820408204182042820438204482045820468204782048820498205082051820528205382054820558205682057820588205982060820618206282063820648206582066820678206882069820708207182072820738207482075820768207782078820798208082081820828208382084820858208682087820888208982090820918209282093820948209582096820978209882099821008210182102821038210482105821068210782108821098211082111821128211382114821158211682117821188211982120821218212282123821248212582126821278212882129821308213182132821338213482135821368213782138821398214082141821428214382144821458214682147821488214982150821518215282153821548215582156821578215882159821608216182162821638216482165821668216782168821698217082171821728217382174821758217682177821788217982180821818218282183821848218582186821878218882189821908219182192821938219482195821968219782198821998220082201822028220382204822058220682207822088220982210822118221282213822148221582216822178221882219822208222182222822238222482225822268222782228822298223082231822328223382234822358223682237822388223982240822418224282243822448224582246822478224882249822508225182252822538225482255822568225782258822598226082261822628226382264822658226682267822688226982270822718227282273822748227582276822778227882279822808228182282822838228482285822868228782288822898229082291822928229382294822958229682297822988229982300823018230282303823048230582306823078230882309823108231182312823138231482315823168231782318823198232082321823228232382324823258232682327823288232982330823318233282333823348233582336823378233882339823408234182342823438234482345823468234782348823498235082351823528235382354823558235682357823588235982360823618236282363823648236582366823678236882369823708237182372823738237482375823768237782378823798238082381823828238382384823858238682387823888238982390823918239282393823948239582396823978239882399824008240182402824038240482405824068240782408824098241082411824128241382414824158241682417824188241982420824218242282423824248242582426824278242882429824308243182432824338243482435824368243782438824398244082441824428244382444824458244682447824488244982450824518245282453824548245582456824578245882459824608246182462824638246482465824668246782468824698247082471824728247382474824758247682477824788247982480824818248282483824848248582486824878248882489824908249182492824938249482495824968249782498824998250082501825028250382504825058250682507825088250982510825118251282513825148251582516825178251882519825208252182522825238252482525825268252782528825298253082531825328253382534825358253682537825388253982540825418254282543825448254582546825478254882549825508255182552825538255482555825568255782558825598256082561825628256382564825658256682567825688256982570825718257282573825748257582576825778257882579825808258182582825838258482585825868258782588825898259082591825928259382594825958259682597825988259982600826018260282603826048260582606826078260882609826108261182612826138261482615826168261782618826198262082621826228262382624826258262682627826288262982630826318263282633826348263582636826378263882639826408264182642826438264482645826468264782648826498265082651826528265382654826558265682657826588265982660826618266282663826648266582666826678266882669826708267182672826738267482675826768267782678826798268082681826828268382684826858268682687826888268982690826918269282693826948269582696826978269882699827008270182702827038270482705827068270782708827098271082711827128271382714827158271682717827188271982720827218272282723827248272582726827278272882729827308273182732827338273482735827368273782738827398274082741827428274382744827458274682747827488274982750827518275282753827548275582756827578275882759827608276182762827638276482765827668276782768827698277082771827728277382774827758277682777827788277982780827818278282783827848278582786827878278882789827908279182792827938279482795827968279782798827998280082801828028280382804828058280682807828088280982810828118281282813828148281582816828178281882819828208282182822828238282482825828268282782828828298283082831828328283382834828358283682837828388283982840828418284282843828448284582846828478284882849828508285182852828538285482855828568285782858828598286082861828628286382864828658286682867828688286982870828718287282873828748287582876828778287882879828808288182882828838288482885828868288782888828898289082891828928289382894828958289682897828988289982900829018290282903829048290582906829078290882909829108291182912829138291482915829168291782918829198292082921829228292382924829258292682927829288292982930829318293282933829348293582936829378293882939829408294182942829438294482945829468294782948829498295082951829528295382954829558295682957829588295982960829618296282963829648296582966829678296882969829708297182972829738297482975829768297782978829798298082981829828298382984829858298682987829888298982990829918299282993829948299582996829978299882999830008300183002830038300483005830068300783008830098301083011830128301383014830158301683017830188301983020830218302283023830248302583026830278302883029830308303183032830338303483035830368303783038830398304083041830428304383044830458304683047830488304983050830518305283053830548305583056830578305883059830608306183062830638306483065830668306783068830698307083071830728307383074830758307683077830788307983080830818308283083830848308583086830878308883089830908309183092830938309483095830968309783098830998310083101831028310383104831058310683107831088310983110831118311283113831148311583116831178311883119831208312183122831238312483125831268312783128831298313083131831328313383134831358313683137831388313983140831418314283143831448314583146831478314883149831508315183152831538315483155831568315783158831598316083161831628316383164831658316683167831688316983170831718317283173831748317583176831778317883179831808318183182831838318483185831868318783188831898319083191831928319383194831958319683197831988319983200832018320283203832048320583206832078320883209832108321183212832138321483215832168321783218832198322083221832228322383224832258322683227832288322983230832318323283233832348323583236832378323883239832408324183242832438324483245832468324783248832498325083251832528325383254832558325683257832588325983260832618326283263832648326583266832678326883269832708327183272832738327483275832768327783278832798328083281832828328383284832858328683287832888328983290832918329283293832948329583296832978329883299833008330183302833038330483305833068330783308833098331083311833128331383314833158331683317833188331983320833218332283323833248332583326833278332883329833308333183332833338333483335833368333783338833398334083341833428334383344833458334683347833488334983350833518335283353833548335583356833578335883359833608336183362833638336483365833668336783368833698337083371833728337383374833758337683377833788337983380833818338283383833848338583386833878338883389833908339183392833938339483395833968339783398833998340083401834028340383404834058340683407834088340983410834118341283413834148341583416834178341883419834208342183422834238342483425834268342783428834298343083431834328343383434834358343683437834388343983440834418344283443834448344583446834478344883449834508345183452834538345483455834568345783458834598346083461834628346383464834658346683467834688346983470834718347283473834748347583476834778347883479834808348183482834838348483485834868348783488834898349083491834928349383494834958349683497834988349983500835018350283503835048350583506835078350883509835108351183512835138351483515835168351783518835198352083521835228352383524835258352683527835288352983530835318353283533835348353583536835378353883539835408354183542835438354483545835468354783548835498355083551835528355383554835558355683557835588355983560835618356283563835648356583566835678356883569835708357183572835738357483575835768357783578835798358083581835828358383584835858358683587835888358983590835918359283593835948359583596835978359883599836008360183602836038360483605836068360783608836098361083611836128361383614836158361683617836188361983620836218362283623836248362583626836278362883629836308363183632836338363483635836368363783638836398364083641836428364383644836458364683647836488364983650836518365283653836548365583656836578365883659836608366183662836638366483665836668366783668836698367083671836728367383674836758367683677836788367983680836818368283683836848368583686836878368883689836908369183692836938369483695836968369783698836998370083701837028370383704837058370683707837088370983710837118371283713837148371583716837178371883719837208372183722837238372483725837268372783728837298373083731837328373383734837358373683737837388373983740837418374283743837448374583746837478374883749837508375183752837538375483755837568375783758837598376083761837628376383764837658376683767837688376983770837718377283773837748377583776837778377883779837808378183782837838378483785837868378783788837898379083791837928379383794837958379683797837988379983800838018380283803838048380583806838078380883809838108381183812838138381483815838168381783818838198382083821838228382383824838258382683827838288382983830838318383283833838348383583836838378383883839838408384183842838438384483845838468384783848838498385083851838528385383854838558385683857838588385983860838618386283863838648386583866838678386883869838708387183872838738387483875838768387783878838798388083881838828388383884838858388683887838888388983890838918389283893838948389583896838978389883899839008390183902839038390483905839068390783908839098391083911839128391383914839158391683917839188391983920839218392283923839248392583926839278392883929839308393183932839338393483935839368393783938839398394083941839428394383944839458394683947839488394983950839518395283953839548395583956839578395883959839608396183962839638396483965839668396783968839698397083971839728397383974839758397683977839788397983980839818398283983839848398583986839878398883989839908399183992839938399483995839968399783998839998400084001840028400384004840058400684007840088400984010840118401284013840148401584016840178401884019840208402184022840238402484025840268402784028840298403084031840328403384034840358403684037840388403984040840418404284043840448404584046840478404884049840508405184052840538405484055840568405784058840598406084061840628406384064840658406684067840688406984070840718407284073840748407584076840778407884079840808408184082840838408484085840868408784088840898409084091840928409384094840958409684097840988409984100841018410284103841048410584106841078410884109841108411184112841138411484115841168411784118841198412084121841228412384124841258412684127841288412984130841318413284133841348413584136841378413884139841408414184142841438414484145841468414784148841498415084151841528415384154841558415684157841588415984160841618416284163841648416584166841678416884169841708417184172841738417484175841768417784178841798418084181841828418384184841858418684187841888418984190841918419284193841948419584196841978419884199842008420184202842038420484205842068420784208842098421084211842128421384214842158421684217842188421984220842218422284223842248422584226842278422884229842308423184232842338423484235842368423784238842398424084241842428424384244842458424684247842488424984250842518425284253842548425584256842578425884259842608426184262842638426484265842668426784268842698427084271842728427384274842758427684277842788427984280842818428284283842848428584286842878428884289842908429184292842938429484295842968429784298842998430084301843028430384304843058430684307843088430984310843118431284313843148431584316843178431884319843208432184322843238432484325843268432784328843298433084331843328433384334843358433684337843388433984340843418434284343843448434584346843478434884349843508435184352843538435484355843568435784358843598436084361843628436384364843658436684367843688436984370843718437284373843748437584376843778437884379843808438184382843838438484385843868438784388843898439084391843928439384394843958439684397843988439984400844018440284403844048440584406844078440884409844108441184412844138441484415844168441784418844198442084421844228442384424844258442684427844288442984430844318443284433844348443584436844378443884439844408444184442844438444484445844468444784448844498445084451844528445384454844558445684457844588445984460844618446284463844648446584466844678446884469844708447184472844738447484475844768447784478844798448084481844828448384484844858448684487844888448984490844918449284493844948449584496844978449884499845008450184502845038450484505845068450784508845098451084511845128451384514845158451684517845188451984520845218452284523845248452584526845278452884529845308453184532845338453484535845368453784538845398454084541845428454384544845458454684547845488454984550845518455284553845548455584556845578455884559845608456184562845638456484565845668456784568845698457084571845728457384574845758457684577845788457984580845818458284583845848458584586845878458884589845908459184592845938459484595845968459784598845998460084601846028460384604846058460684607846088460984610846118461284613846148461584616846178461884619846208462184622846238462484625846268462784628846298463084631846328463384634846358463684637846388463984640846418464284643846448464584646846478464884649846508465184652846538465484655846568465784658846598466084661846628466384664846658466684667846688466984670846718467284673846748467584676846778467884679846808468184682846838468484685846868468784688846898469084691846928469384694846958469684697846988469984700847018470284703847048470584706847078470884709847108471184712847138471484715847168471784718847198472084721847228472384724847258472684727847288472984730847318473284733847348473584736847378473884739847408474184742847438474484745847468474784748847498475084751847528475384754847558475684757847588475984760847618476284763847648476584766847678476884769847708477184772847738477484775847768477784778847798478084781847828478384784847858478684787847888478984790847918479284793847948479584796847978479884799848008480184802848038480484805848068480784808848098481084811848128481384814848158481684817848188481984820848218482284823848248482584826848278482884829848308483184832848338483484835848368483784838848398484084841848428484384844848458484684847848488484984850848518485284853848548485584856848578485884859848608486184862848638486484865848668486784868848698487084871848728487384874848758487684877848788487984880848818488284883848848488584886848878488884889848908489184892848938489484895848968489784898848998490084901849028490384904849058490684907849088490984910849118491284913849148491584916849178491884919849208492184922849238492484925849268492784928849298493084931849328493384934849358493684937849388493984940849418494284943849448494584946849478494884949849508495184952849538495484955849568495784958849598496084961849628496384964849658496684967849688496984970849718497284973849748497584976849778497884979849808498184982849838498484985849868498784988849898499084991849928499384994849958499684997849988499985000850018500285003850048500585006850078500885009850108501185012850138501485015850168501785018850198502085021850228502385024850258502685027850288502985030850318503285033850348503585036850378503885039850408504185042850438504485045850468504785048850498505085051850528505385054850558505685057850588505985060850618506285063850648506585066850678506885069850708507185072850738507485075850768507785078850798508085081850828508385084850858508685087850888508985090850918509285093850948509585096850978509885099851008510185102851038510485105851068510785108851098511085111851128511385114851158511685117851188511985120851218512285123851248512585126851278512885129851308513185132851338513485135851368513785138851398514085141851428514385144851458514685147851488514985150851518515285153851548515585156851578515885159851608516185162851638516485165851668516785168851698517085171851728517385174851758517685177851788517985180851818518285183851848518585186851878518885189851908519185192851938519485195851968519785198851998520085201852028520385204852058520685207852088520985210852118521285213852148521585216852178521885219852208522185222852238522485225852268522785228852298523085231852328523385234852358523685237852388523985240852418524285243852448524585246852478524885249852508525185252852538525485255852568525785258852598526085261852628526385264852658526685267852688526985270852718527285273852748527585276852778527885279852808528185282852838528485285852868528785288852898529085291852928529385294852958529685297852988529985300853018530285303853048530585306853078530885309853108531185312853138531485315853168531785318853198532085321853228532385324853258532685327853288532985330853318533285333853348533585336853378533885339853408534185342853438534485345853468534785348853498535085351853528535385354853558535685357853588535985360853618536285363853648536585366853678536885369853708537185372853738537485375853768537785378853798538085381853828538385384853858538685387853888538985390853918539285393853948539585396853978539885399854008540185402854038540485405854068540785408854098541085411854128541385414854158541685417854188541985420854218542285423854248542585426854278542885429854308543185432854338543485435854368543785438854398544085441854428544385444854458544685447854488544985450854518545285453854548545585456854578545885459854608546185462854638546485465854668546785468854698547085471854728547385474854758547685477854788547985480854818548285483854848548585486854878548885489854908549185492854938549485495854968549785498854998550085501855028550385504855058550685507855088550985510855118551285513855148551585516855178551885519855208552185522855238552485525855268552785528855298553085531855328553385534855358553685537855388553985540855418554285543855448554585546855478554885549855508555185552855538555485555855568555785558855598556085561855628556385564855658556685567855688556985570855718557285573855748557585576855778557885579855808558185582855838558485585855868558785588855898559085591855928559385594855958559685597855988559985600856018560285603856048560585606856078560885609856108561185612856138561485615856168561785618856198562085621856228562385624856258562685627856288562985630856318563285633856348563585636856378563885639856408564185642856438564485645856468564785648856498565085651856528565385654856558565685657856588565985660856618566285663856648566585666856678566885669856708567185672856738567485675856768567785678856798568085681856828568385684856858568685687856888568985690856918569285693856948569585696856978569885699857008570185702857038570485705857068570785708857098571085711857128571385714857158571685717857188571985720857218572285723857248572585726857278572885729857308573185732857338573485735857368573785738857398574085741857428574385744857458574685747857488574985750857518575285753857548575585756857578575885759857608576185762857638576485765857668576785768857698577085771857728577385774857758577685777857788577985780857818578285783857848578585786857878578885789857908579185792857938579485795857968579785798857998580085801858028580385804858058580685807858088580985810858118581285813858148581585816858178581885819858208582185822858238582485825858268582785828858298583085831858328583385834858358583685837858388583985840858418584285843858448584585846858478584885849858508585185852858538585485855858568585785858858598586085861858628586385864858658586685867858688586985870858718587285873858748587585876858778587885879858808588185882858838588485885858868588785888858898589085891858928589385894858958589685897858988589985900859018590285903859048590585906859078590885909859108591185912859138591485915859168591785918859198592085921859228592385924859258592685927859288592985930859318593285933859348593585936859378593885939859408594185942859438594485945859468594785948859498595085951859528595385954859558595685957859588595985960859618596285963859648596585966859678596885969859708597185972859738597485975859768597785978859798598085981859828598385984859858598685987859888598985990859918599285993859948599585996859978599885999860008600186002860038600486005860068600786008860098601086011860128601386014860158601686017860188601986020860218602286023860248602586026860278602886029860308603186032860338603486035860368603786038860398604086041860428604386044860458604686047860488604986050860518605286053860548605586056860578605886059860608606186062860638606486065860668606786068860698607086071860728607386074860758607686077860788607986080860818608286083860848608586086860878608886089860908609186092860938609486095860968609786098860998610086101861028610386104861058610686107861088610986110861118611286113861148611586116861178611886119861208612186122861238612486125861268612786128861298613086131861328613386134861358613686137861388613986140861418614286143861448614586146861478614886149861508615186152861538615486155861568615786158861598616086161861628616386164861658616686167861688616986170861718617286173861748617586176861778617886179861808618186182861838618486185861868618786188861898619086191861928619386194861958619686197861988619986200862018620286203862048620586206862078620886209862108621186212862138621486215862168621786218862198622086221862228622386224862258622686227862288622986230862318623286233862348623586236862378623886239862408624186242862438624486245862468624786248862498625086251862528625386254862558625686257862588625986260862618626286263862648626586266862678626886269862708627186272862738627486275862768627786278862798628086281862828628386284862858628686287862888628986290862918629286293862948629586296862978629886299863008630186302863038630486305863068630786308863098631086311863128631386314863158631686317863188631986320863218632286323863248632586326863278632886329863308633186332863338633486335863368633786338863398634086341863428634386344863458634686347863488634986350863518635286353863548635586356863578635886359863608636186362863638636486365863668636786368863698637086371863728637386374863758637686377863788637986380863818638286383863848638586386863878638886389863908639186392863938639486395863968639786398863998640086401864028640386404864058640686407864088640986410864118641286413864148641586416864178641886419864208642186422864238642486425864268642786428864298643086431864328643386434864358643686437864388643986440864418644286443864448644586446864478644886449864508645186452864538645486455864568645786458864598646086461864628646386464864658646686467864688646986470864718647286473864748647586476864778647886479864808648186482864838648486485864868648786488864898649086491864928649386494864958649686497864988649986500865018650286503865048650586506865078650886509865108651186512865138651486515865168651786518865198652086521865228652386524865258652686527865288652986530865318653286533865348653586536865378653886539865408654186542865438654486545865468654786548865498655086551865528655386554865558655686557865588655986560865618656286563865648656586566865678656886569865708657186572865738657486575865768657786578865798658086581865828658386584865858658686587865888658986590865918659286593865948659586596865978659886599866008660186602866038660486605866068660786608866098661086611866128661386614866158661686617866188661986620866218662286623866248662586626866278662886629866308663186632866338663486635866368663786638866398664086641866428664386644866458664686647866488664986650866518665286653866548665586656866578665886659866608666186662866638666486665866668666786668866698667086671866728667386674866758667686677866788667986680866818668286683866848668586686866878668886689866908669186692866938669486695866968669786698866998670086701867028670386704867058670686707867088670986710867118671286713867148671586716867178671886719867208672186722867238672486725867268672786728867298673086731867328673386734867358673686737867388673986740867418674286743867448674586746867478674886749867508675186752867538675486755867568675786758867598676086761867628676386764867658676686767867688676986770867718677286773867748677586776867778677886779867808678186782867838678486785867868678786788867898679086791867928679386794867958679686797867988679986800868018680286803868048680586806868078680886809868108681186812868138681486815868168681786818868198682086821868228682386824868258682686827868288682986830868318683286833868348683586836868378683886839868408684186842868438684486845868468684786848868498685086851868528685386854868558685686857868588685986860868618686286863868648686586866868678686886869868708687186872868738687486875868768687786878868798688086881868828688386884868858688686887868888688986890868918689286893868948689586896868978689886899869008690186902869038690486905869068690786908869098691086911869128691386914869158691686917869188691986920869218692286923869248692586926869278692886929869308693186932869338693486935869368693786938869398694086941869428694386944869458694686947869488694986950869518695286953869548695586956869578695886959869608696186962869638696486965869668696786968869698697086971869728697386974869758697686977869788697986980869818698286983869848698586986869878698886989869908699186992869938699486995869968699786998869998700087001870028700387004870058700687007870088700987010870118701287013870148701587016870178701887019870208702187022870238702487025870268702787028870298703087031870328703387034870358703687037870388703987040870418704287043870448704587046870478704887049870508705187052870538705487055870568705787058870598706087061870628706387064870658706687067870688706987070870718707287073870748707587076870778707887079870808708187082870838708487085870868708787088870898709087091870928709387094870958709687097870988709987100871018710287103871048710587106871078710887109871108711187112871138711487115871168711787118871198712087121871228712387124871258712687127871288712987130871318713287133871348713587136871378713887139871408714187142871438714487145871468714787148871498715087151871528715387154871558715687157871588715987160871618716287163871648716587166871678716887169871708717187172871738717487175871768717787178871798718087181871828718387184871858718687187871888718987190871918719287193871948719587196871978719887199872008720187202872038720487205872068720787208872098721087211872128721387214872158721687217872188721987220872218722287223872248722587226872278722887229872308723187232872338723487235872368723787238872398724087241872428724387244872458724687247872488724987250872518725287253872548725587256872578725887259872608726187262872638726487265872668726787268872698727087271872728727387274872758727687277872788727987280872818728287283872848728587286872878728887289872908729187292872938729487295872968729787298872998730087301873028730387304873058730687307873088730987310873118731287313873148731587316873178731887319873208732187322873238732487325873268732787328873298733087331873328733387334873358733687337873388733987340873418734287343873448734587346873478734887349873508735187352873538735487355873568735787358873598736087361873628736387364873658736687367873688736987370873718737287373873748737587376873778737887379873808738187382873838738487385873868738787388873898739087391873928739387394873958739687397873988739987400874018740287403874048740587406874078740887409874108741187412874138741487415874168741787418874198742087421874228742387424874258742687427874288742987430874318743287433874348743587436874378743887439874408744187442874438744487445874468744787448874498745087451874528745387454874558745687457874588745987460874618746287463874648746587466874678746887469874708747187472874738747487475874768747787478874798748087481874828748387484874858748687487874888748987490874918749287493874948749587496874978749887499875008750187502875038750487505875068750787508875098751087511875128751387514875158751687517875188751987520875218752287523875248752587526875278752887529875308753187532875338753487535875368753787538875398754087541875428754387544875458754687547875488754987550875518755287553875548755587556875578755887559875608756187562875638756487565875668756787568875698757087571875728757387574875758757687577875788757987580875818758287583875848758587586875878758887589875908759187592875938759487595875968759787598875998760087601876028760387604876058760687607876088760987610876118761287613876148761587616876178761887619876208762187622876238762487625876268762787628876298763087631876328763387634876358763687637876388763987640876418764287643876448764587646876478764887649876508765187652876538765487655876568765787658876598766087661876628766387664876658766687667876688766987670876718767287673876748767587676876778767887679876808768187682876838768487685876868768787688876898769087691876928769387694876958769687697876988769987700877018770287703877048770587706877078770887709877108771187712877138771487715877168771787718877198772087721877228772387724877258772687727877288772987730877318773287733877348773587736877378773887739877408774187742877438774487745877468774787748877498775087751877528775387754877558775687757877588775987760877618776287763877648776587766877678776887769877708777187772877738777487775877768777787778877798778087781877828778387784877858778687787877888778987790877918779287793877948779587796877978779887799878008780187802878038780487805878068780787808878098781087811878128781387814878158781687817878188781987820878218782287823878248782587826878278782887829878308783187832878338783487835878368783787838878398784087841878428784387844878458784687847878488784987850878518785287853878548785587856878578785887859878608786187862878638786487865878668786787868878698787087871878728787387874878758787687877878788787987880878818788287883878848788587886878878788887889878908789187892878938789487895878968789787898878998790087901879028790387904879058790687907879088790987910879118791287913879148791587916879178791887919879208792187922879238792487925879268792787928879298793087931879328793387934879358793687937879388793987940879418794287943879448794587946879478794887949879508795187952879538795487955879568795787958879598796087961879628796387964879658796687967879688796987970879718797287973879748797587976879778797887979879808798187982879838798487985879868798787988879898799087991879928799387994879958799687997879988799988000880018800288003880048800588006880078800888009880108801188012880138801488015880168801788018880198802088021880228802388024880258802688027880288802988030880318803288033880348803588036880378803888039880408804188042880438804488045880468804788048880498805088051880528805388054880558805688057880588805988060880618806288063880648806588066880678806888069880708807188072880738807488075880768807788078880798808088081880828808388084880858808688087880888808988090880918809288093880948809588096880978809888099881008810188102881038810488105881068810788108881098811088111881128811388114881158811688117881188811988120881218812288123881248812588126881278812888129881308813188132881338813488135881368813788138881398814088141881428814388144881458814688147881488814988150881518815288153881548815588156881578815888159881608816188162881638816488165881668816788168881698817088171881728817388174881758817688177881788817988180881818818288183881848818588186881878818888189881908819188192881938819488195881968819788198881998820088201882028820388204882058820688207882088820988210882118821288213882148821588216882178821888219882208822188222882238822488225882268822788228882298823088231882328823388234882358823688237882388823988240882418824288243882448824588246882478824888249882508825188252882538825488255882568825788258882598826088261882628826388264882658826688267882688826988270882718827288273882748827588276882778827888279882808828188282882838828488285882868828788288882898829088291882928829388294882958829688297882988829988300883018830288303883048830588306883078830888309883108831188312883138831488315883168831788318883198832088321883228832388324883258832688327883288832988330883318833288333883348833588336883378833888339883408834188342883438834488345883468834788348883498835088351883528835388354883558835688357883588835988360883618836288363883648836588366883678836888369883708837188372883738837488375883768837788378883798838088381883828838388384883858838688387883888838988390883918839288393883948839588396883978839888399884008840188402884038840488405884068840788408884098841088411884128841388414884158841688417884188841988420884218842288423884248842588426884278842888429884308843188432884338843488435884368843788438884398844088441884428844388444884458844688447884488844988450884518845288453884548845588456884578845888459884608846188462884638846488465884668846788468884698847088471884728847388474884758847688477884788847988480884818848288483884848848588486884878848888489884908849188492884938849488495884968849788498884998850088501885028850388504885058850688507885088850988510885118851288513885148851588516885178851888519885208852188522885238852488525885268852788528885298853088531885328853388534885358853688537885388853988540885418854288543885448854588546885478854888549885508855188552885538855488555885568855788558885598856088561885628856388564885658856688567885688856988570885718857288573885748857588576885778857888579885808858188582885838858488585885868858788588885898859088591885928859388594885958859688597885988859988600886018860288603886048860588606886078860888609886108861188612886138861488615886168861788618886198862088621886228862388624886258862688627886288862988630886318863288633886348863588636886378863888639886408864188642886438864488645886468864788648886498865088651886528865388654886558865688657886588865988660886618866288663886648866588666886678866888669886708867188672886738867488675886768867788678886798868088681886828868388684886858868688687886888868988690886918869288693886948869588696886978869888699887008870188702887038870488705887068870788708887098871088711887128871388714887158871688717887188871988720887218872288723887248872588726887278872888729887308873188732887338873488735887368873788738887398874088741887428874388744887458874688747887488874988750887518875288753887548875588756887578875888759887608876188762887638876488765887668876788768887698877088771887728877388774887758877688777887788877988780887818878288783887848878588786887878878888789887908879188792887938879488795887968879788798887998880088801888028880388804888058880688807888088880988810888118881288813888148881588816888178881888819888208882188822888238882488825888268882788828888298883088831888328883388834888358883688837888388883988840888418884288843888448884588846888478884888849888508885188852888538885488855888568885788858888598886088861888628886388864888658886688867888688886988870888718887288873888748887588876888778887888879888808888188882888838888488885888868888788888888898889088891888928889388894888958889688897888988889988900889018890288903889048890588906889078890888909889108891188912889138891488915889168891788918889198892088921889228892388924889258892688927889288892988930889318893288933889348893588936889378893888939889408894188942889438894488945889468894788948889498895088951889528895388954889558895688957889588895988960889618896288963889648896588966889678896888969889708897188972889738897488975889768897788978889798898088981889828898388984889858898688987889888898988990889918899288993889948899588996889978899888999890008900189002890038900489005890068900789008890098901089011890128901389014890158901689017890188901989020890218902289023890248902589026890278902889029890308903189032890338903489035890368903789038890398904089041890428904389044890458904689047890488904989050890518905289053890548905589056890578905889059890608906189062890638906489065890668906789068890698907089071890728907389074890758907689077890788907989080890818908289083890848908589086890878908889089890908909189092890938909489095890968909789098890998910089101891028910389104891058910689107891088910989110891118911289113891148911589116891178911889119891208912189122891238912489125891268912789128891298913089131891328913389134891358913689137891388913989140891418914289143891448914589146891478914889149891508915189152891538915489155891568915789158891598916089161891628916389164891658916689167891688916989170891718917289173891748917589176891778917889179891808918189182891838918489185891868918789188891898919089191891928919389194891958919689197891988919989200892018920289203892048920589206892078920889209892108921189212892138921489215892168921789218892198922089221892228922389224892258922689227892288922989230892318923289233892348923589236892378923889239892408924189242892438924489245892468924789248892498925089251892528925389254892558925689257892588925989260892618926289263892648926589266892678926889269892708927189272892738927489275892768927789278892798928089281892828928389284892858928689287892888928989290892918929289293892948929589296892978929889299893008930189302893038930489305893068930789308893098931089311893128931389314893158931689317893188931989320893218932289323893248932589326893278932889329893308933189332893338933489335893368933789338893398934089341893428934389344893458934689347893488934989350893518935289353893548935589356893578935889359893608936189362893638936489365893668936789368893698937089371893728937389374893758937689377893788937989380893818938289383893848938589386893878938889389893908939189392893938939489395893968939789398893998940089401894028940389404894058940689407894088940989410894118941289413894148941589416894178941889419894208942189422894238942489425894268942789428894298943089431894328943389434894358943689437894388943989440894418944289443894448944589446894478944889449894508945189452894538945489455894568945789458894598946089461894628946389464894658946689467894688946989470894718947289473894748947589476894778947889479894808948189482894838948489485894868948789488894898949089491894928949389494894958949689497894988949989500895018950289503895048950589506895078950889509895108951189512895138951489515895168951789518895198952089521895228952389524895258952689527895288952989530895318953289533895348953589536895378953889539895408954189542895438954489545895468954789548895498955089551895528955389554895558955689557895588955989560895618956289563895648956589566895678956889569895708957189572895738957489575895768957789578895798958089581895828958389584895858958689587895888958989590895918959289593895948959589596895978959889599896008960189602896038960489605896068960789608896098961089611896128961389614896158961689617896188961989620896218962289623896248962589626896278962889629896308963189632896338963489635896368963789638896398964089641896428964389644896458964689647896488964989650896518965289653896548965589656896578965889659896608966189662896638966489665896668966789668896698967089671896728967389674896758967689677896788967989680896818968289683896848968589686896878968889689896908969189692896938969489695896968969789698896998970089701897028970389704897058970689707897088970989710897118971289713897148971589716897178971889719897208972189722897238972489725897268972789728897298973089731897328973389734897358973689737897388973989740897418974289743897448974589746897478974889749897508975189752897538975489755897568975789758897598976089761897628976389764897658976689767897688976989770897718977289773897748977589776897778977889779897808978189782897838978489785897868978789788897898979089791897928979389794897958979689797897988979989800898018980289803898048980589806898078980889809898108981189812898138981489815898168981789818898198982089821898228982389824898258982689827898288982989830898318983289833898348983589836898378983889839898408984189842898438984489845898468984789848898498985089851898528985389854898558985689857898588985989860898618986289863898648986589866898678986889869898708987189872898738987489875898768987789878898798988089881898828988389884898858988689887898888988989890898918989289893898948989589896898978989889899899008990189902899038990489905899068990789908899098991089911899128991389914899158991689917899188991989920899218992289923899248992589926899278992889929899308993189932899338993489935899368993789938899398994089941899428994389944899458994689947899488994989950899518995289953899548995589956899578995889959899608996189962899638996489965899668996789968899698997089971899728997389974899758997689977899788997989980899818998289983899848998589986899878998889989899908999189992899938999489995899968999789998899999000090001900029000390004900059000690007900089000990010900119001290013900149001590016900179001890019900209002190022900239002490025900269002790028900299003090031900329003390034900359003690037900389003990040900419004290043900449004590046900479004890049900509005190052900539005490055900569005790058900599006090061900629006390064900659006690067900689006990070900719007290073900749007590076900779007890079900809008190082900839008490085900869008790088900899009090091900929009390094900959009690097900989009990100901019010290103901049010590106901079010890109901109011190112901139011490115901169011790118901199012090121901229012390124901259012690127901289012990130901319013290133901349013590136901379013890139901409014190142901439014490145901469014790148901499015090151901529015390154901559015690157901589015990160901619016290163901649016590166901679016890169901709017190172901739017490175901769017790178901799018090181901829018390184901859018690187901889018990190901919019290193901949019590196901979019890199902009020190202902039020490205902069020790208902099021090211902129021390214902159021690217902189021990220902219022290223902249022590226902279022890229902309023190232902339023490235902369023790238902399024090241902429024390244902459024690247902489024990250902519025290253902549025590256902579025890259902609026190262902639026490265902669026790268902699027090271902729027390274902759027690277902789027990280902819028290283902849028590286902879028890289902909029190292902939029490295902969029790298902999030090301903029030390304903059030690307903089030990310903119031290313903149031590316903179031890319903209032190322903239032490325903269032790328903299033090331903329033390334903359033690337903389033990340903419034290343903449034590346903479034890349903509035190352903539035490355903569035790358903599036090361903629036390364903659036690367903689036990370903719037290373903749037590376903779037890379903809038190382903839038490385903869038790388903899039090391903929039390394903959039690397903989039990400904019040290403904049040590406904079040890409904109041190412904139041490415904169041790418904199042090421904229042390424904259042690427904289042990430904319043290433904349043590436904379043890439904409044190442904439044490445904469044790448904499045090451904529045390454904559045690457904589045990460904619046290463904649046590466904679046890469904709047190472904739047490475904769047790478904799048090481904829048390484904859048690487904889048990490904919049290493904949049590496904979049890499905009050190502905039050490505905069050790508905099051090511905129051390514905159051690517905189051990520905219052290523905249052590526905279052890529905309053190532905339053490535905369053790538905399054090541905429054390544905459054690547905489054990550905519055290553905549055590556905579055890559905609056190562905639056490565905669056790568905699057090571905729057390574905759057690577905789057990580905819058290583905849058590586905879058890589905909059190592905939059490595905969059790598905999060090601906029060390604906059060690607906089060990610906119061290613906149061590616906179061890619906209062190622906239062490625906269062790628906299063090631906329063390634906359063690637906389063990640906419064290643906449064590646906479064890649906509065190652906539065490655906569065790658906599066090661906629066390664906659066690667906689066990670906719067290673906749067590676906779067890679906809068190682906839068490685906869068790688906899069090691906929069390694906959069690697906989069990700907019070290703907049070590706907079070890709907109071190712907139071490715907169071790718907199072090721907229072390724907259072690727907289072990730907319073290733907349073590736907379073890739907409074190742907439074490745907469074790748907499075090751907529075390754907559075690757907589075990760907619076290763907649076590766907679076890769907709077190772907739077490775907769077790778907799078090781907829078390784907859078690787907889078990790907919079290793907949079590796907979079890799908009080190802908039080490805908069080790808908099081090811908129081390814908159081690817908189081990820908219082290823908249082590826908279082890829908309083190832908339083490835908369083790838908399084090841908429084390844908459084690847908489084990850908519085290853908549085590856908579085890859908609086190862908639086490865908669086790868908699087090871908729087390874908759087690877908789087990880908819088290883908849088590886908879088890889908909089190892908939089490895908969089790898908999090090901909029090390904909059090690907909089090990910909119091290913909149091590916909179091890919909209092190922909239092490925909269092790928909299093090931909329093390934909359093690937909389093990940909419094290943909449094590946909479094890949909509095190952909539095490955909569095790958909599096090961909629096390964909659096690967909689096990970909719097290973909749097590976909779097890979909809098190982909839098490985909869098790988909899099090991909929099390994909959099690997909989099991000910019100291003910049100591006910079100891009910109101191012910139101491015910169101791018910199102091021910229102391024910259102691027910289102991030910319103291033910349103591036910379103891039910409104191042910439104491045910469104791048910499105091051910529105391054910559105691057910589105991060910619106291063910649106591066910679106891069910709107191072910739107491075910769107791078910799108091081910829108391084910859108691087910889108991090910919109291093910949109591096910979109891099911009110191102911039110491105911069110791108911099111091111911129111391114911159111691117911189111991120911219112291123911249112591126911279112891129911309113191132911339113491135911369113791138911399114091141911429114391144911459114691147911489114991150911519115291153911549115591156911579115891159911609116191162911639116491165911669116791168911699117091171911729117391174911759117691177911789117991180911819118291183911849118591186911879118891189911909119191192911939119491195911969119791198911999120091201912029120391204912059120691207912089120991210912119121291213912149121591216912179121891219912209122191222912239122491225912269122791228912299123091231912329123391234912359123691237912389123991240912419124291243912449124591246912479124891249912509125191252912539125491255912569125791258912599126091261912629126391264912659126691267912689126991270912719127291273912749127591276912779127891279912809128191282912839128491285912869128791288912899129091291912929129391294912959129691297912989129991300913019130291303913049130591306913079130891309913109131191312913139131491315913169131791318913199132091321913229132391324913259132691327913289132991330913319133291333913349133591336913379133891339913409134191342913439134491345913469134791348913499135091351913529135391354913559135691357913589135991360913619136291363913649136591366913679136891369913709137191372913739137491375913769137791378913799138091381913829138391384913859138691387913889138991390913919139291393913949139591396913979139891399914009140191402914039140491405914069140791408914099141091411914129141391414914159141691417914189141991420914219142291423914249142591426914279142891429914309143191432914339143491435914369143791438914399144091441914429144391444914459144691447914489144991450914519145291453914549145591456914579145891459914609146191462914639146491465914669146791468914699147091471914729147391474914759147691477914789147991480914819148291483914849148591486914879148891489914909149191492914939149491495914969149791498914999150091501915029150391504915059150691507915089150991510915119151291513915149151591516915179151891519915209152191522915239152491525915269152791528915299153091531915329153391534915359153691537915389153991540915419154291543915449154591546915479154891549915509155191552915539155491555915569155791558915599156091561915629156391564915659156691567915689156991570915719157291573915749157591576915779157891579915809158191582915839158491585915869158791588915899159091591915929159391594915959159691597915989159991600916019160291603916049160591606916079160891609916109161191612916139161491615916169161791618916199162091621916229162391624916259162691627916289162991630916319163291633916349163591636916379163891639916409164191642916439164491645916469164791648916499165091651916529165391654916559165691657916589165991660916619166291663916649166591666916679166891669916709167191672916739167491675916769167791678916799168091681916829168391684916859168691687916889168991690916919169291693916949169591696916979169891699917009170191702917039170491705917069170791708917099171091711917129171391714917159171691717917189171991720917219172291723917249172591726917279172891729917309173191732917339173491735917369173791738917399174091741917429174391744917459174691747917489174991750917519175291753917549175591756917579175891759917609176191762917639176491765917669176791768917699177091771917729177391774917759177691777917789177991780917819178291783917849178591786917879178891789917909179191792917939179491795917969179791798917999180091801918029180391804918059180691807918089180991810918119181291813918149181591816918179181891819918209182191822918239182491825918269182791828918299183091831918329183391834918359183691837918389183991840918419184291843918449184591846918479184891849918509185191852918539185491855918569185791858918599186091861918629186391864918659186691867918689186991870918719187291873918749187591876918779187891879918809188191882918839188491885918869188791888918899189091891918929189391894918959189691897918989189991900919019190291903919049190591906919079190891909919109191191912919139191491915919169191791918919199192091921919229192391924919259192691927919289192991930919319193291933919349193591936919379193891939919409194191942919439194491945919469194791948919499195091951919529195391954919559195691957919589195991960919619196291963919649196591966919679196891969919709197191972919739197491975919769197791978919799198091981919829198391984919859198691987919889198991990919919199291993919949199591996919979199891999920009200192002920039200492005920069200792008920099201092011920129201392014920159201692017920189201992020920219202292023920249202592026920279202892029920309203192032920339203492035920369203792038920399204092041920429204392044920459204692047920489204992050920519205292053920549205592056920579205892059920609206192062920639206492065920669206792068920699207092071920729207392074920759207692077920789207992080920819208292083920849208592086920879208892089920909209192092920939209492095920969209792098920999210092101921029210392104921059210692107921089210992110921119211292113921149211592116921179211892119921209212192122921239212492125921269212792128921299213092131921329213392134921359213692137921389213992140921419214292143921449214592146921479214892149921509215192152921539215492155921569215792158921599216092161921629216392164921659216692167921689216992170921719217292173921749217592176921779217892179921809218192182921839218492185921869218792188921899219092191921929219392194921959219692197921989219992200922019220292203922049220592206922079220892209922109221192212922139221492215922169221792218922199222092221922229222392224922259222692227922289222992230922319223292233922349223592236922379223892239922409224192242922439224492245922469224792248922499225092251922529225392254922559225692257922589225992260922619226292263922649226592266922679226892269922709227192272922739227492275922769227792278922799228092281922829228392284922859228692287922889228992290922919229292293922949229592296922979229892299923009230192302923039230492305923069230792308923099231092311923129231392314923159231692317923189231992320923219232292323923249232592326923279232892329923309233192332923339233492335923369233792338923399234092341923429234392344923459234692347923489234992350923519235292353923549235592356923579235892359923609236192362923639236492365923669236792368923699237092371923729237392374923759237692377923789237992380923819238292383923849238592386923879238892389923909239192392923939239492395923969239792398923999240092401924029240392404924059240692407924089240992410924119241292413924149241592416924179241892419924209242192422924239242492425924269242792428924299243092431924329243392434924359243692437924389243992440924419244292443924449244592446924479244892449924509245192452924539245492455924569245792458924599246092461924629246392464924659246692467924689246992470924719247292473924749247592476924779247892479924809248192482924839248492485924869248792488924899249092491924929249392494924959249692497924989249992500925019250292503925049250592506925079250892509925109251192512925139251492515925169251792518925199252092521925229252392524925259252692527925289252992530925319253292533925349253592536925379253892539925409254192542925439254492545925469254792548925499255092551925529255392554925559255692557925589255992560925619256292563925649256592566925679256892569925709257192572925739257492575925769257792578925799258092581925829258392584925859258692587925889258992590925919259292593925949259592596925979259892599926009260192602926039260492605926069260792608926099261092611926129261392614926159261692617926189261992620926219262292623926249262592626926279262892629926309263192632926339263492635926369263792638926399264092641926429264392644926459264692647926489264992650926519265292653926549265592656926579265892659926609266192662926639266492665926669266792668926699267092671926729267392674926759267692677926789267992680926819268292683926849268592686926879268892689926909269192692926939269492695926969269792698926999270092701927029270392704927059270692707927089270992710927119271292713927149271592716927179271892719927209272192722927239272492725927269272792728927299273092731927329273392734927359273692737927389273992740927419274292743927449274592746927479274892749927509275192752927539275492755927569275792758927599276092761927629276392764927659276692767927689276992770927719277292773927749277592776927779277892779927809278192782927839278492785927869278792788927899279092791927929279392794927959279692797927989279992800928019280292803928049280592806928079280892809928109281192812928139281492815928169281792818928199282092821928229282392824928259282692827928289282992830928319283292833928349283592836928379283892839928409284192842928439284492845928469284792848928499285092851928529285392854928559285692857928589285992860928619286292863928649286592866928679286892869928709287192872928739287492875928769287792878928799288092881928829288392884928859288692887928889288992890928919289292893928949289592896928979289892899929009290192902929039290492905929069290792908929099291092911929129291392914929159291692917929189291992920929219292292923929249292592926929279292892929929309293192932929339293492935929369293792938929399294092941929429294392944929459294692947929489294992950929519295292953929549295592956929579295892959929609296192962929639296492965929669296792968929699297092971929729297392974929759297692977929789297992980929819298292983929849298592986929879298892989929909299192992929939299492995929969299792998929999300093001930029300393004930059300693007930089300993010930119301293013930149301593016930179301893019930209302193022930239302493025930269302793028930299303093031930329303393034930359303693037930389303993040930419304293043930449304593046930479304893049930509305193052930539305493055930569305793058930599306093061930629306393064930659306693067930689306993070930719307293073930749307593076930779307893079930809308193082930839308493085930869308793088930899309093091930929309393094930959309693097930989309993100931019310293103931049310593106931079310893109931109311193112931139311493115931169311793118931199312093121931229312393124931259312693127931289312993130931319313293133931349313593136931379313893139931409314193142931439314493145931469314793148931499315093151931529315393154931559315693157931589315993160931619316293163931649316593166931679316893169931709317193172931739317493175931769317793178931799318093181931829318393184931859318693187931889318993190931919319293193931949319593196931979319893199932009320193202932039320493205932069320793208932099321093211932129321393214932159321693217932189321993220932219322293223932249322593226932279322893229932309323193232932339323493235932369323793238932399324093241932429324393244932459324693247932489324993250932519325293253932549325593256932579325893259932609326193262932639326493265932669326793268932699327093271932729327393274932759327693277932789327993280932819328293283932849328593286932879328893289932909329193292932939329493295932969329793298932999330093301933029330393304933059330693307933089330993310933119331293313933149331593316933179331893319933209332193322933239332493325933269332793328933299333093331933329333393334933359333693337933389333993340933419334293343933449334593346933479334893349933509335193352933539335493355933569335793358933599336093361933629336393364933659336693367933689336993370933719337293373933749337593376933779337893379933809338193382933839338493385933869338793388933899339093391933929339393394933959339693397933989339993400934019340293403934049340593406934079340893409934109341193412934139341493415934169341793418934199342093421934229342393424934259342693427934289342993430934319343293433934349343593436934379343893439934409344193442934439344493445934469344793448934499345093451934529345393454934559345693457934589345993460934619346293463934649346593466934679346893469934709347193472934739347493475934769347793478934799348093481934829348393484934859348693487934889348993490934919349293493934949349593496934979349893499935009350193502935039350493505935069350793508935099351093511935129351393514935159351693517935189351993520935219352293523935249352593526935279352893529935309353193532935339353493535935369353793538935399354093541935429354393544935459354693547935489354993550935519355293553935549355593556935579355893559935609356193562935639356493565935669356793568935699357093571935729357393574935759357693577935789357993580935819358293583935849358593586935879358893589935909359193592935939359493595935969359793598935999360093601936029360393604936059360693607936089360993610936119361293613936149361593616936179361893619936209362193622936239362493625936269362793628936299363093631936329363393634936359363693637936389363993640936419364293643936449364593646936479364893649936509365193652936539365493655936569365793658936599366093661936629366393664936659366693667936689366993670936719367293673936749367593676936779367893679936809368193682936839368493685936869368793688936899369093691936929369393694936959369693697936989369993700937019370293703937049370593706937079370893709937109371193712937139371493715937169371793718937199372093721937229372393724937259372693727937289372993730937319373293733937349373593736937379373893739937409374193742937439374493745937469374793748937499375093751937529375393754937559375693757937589375993760937619376293763937649376593766937679376893769937709377193772937739377493775937769377793778937799378093781937829378393784937859378693787937889378993790937919379293793937949379593796937979379893799938009380193802938039380493805938069380793808938099381093811938129381393814938159381693817938189381993820938219382293823938249382593826938279382893829938309383193832938339383493835938369383793838938399384093841938429384393844938459384693847938489384993850938519385293853938549385593856938579385893859938609386193862938639386493865938669386793868938699387093871938729387393874938759387693877938789387993880938819388293883938849388593886938879388893889938909389193892938939389493895938969389793898938999390093901939029390393904939059390693907939089390993910939119391293913939149391593916939179391893919939209392193922939239392493925939269392793928939299393093931939329393393934939359393693937939389393993940939419394293943939449394593946939479394893949939509395193952939539395493955939569395793958939599396093961939629396393964939659396693967939689396993970939719397293973939749397593976939779397893979939809398193982939839398493985939869398793988939899399093991939929399393994939959399693997939989399994000940019400294003940049400594006940079400894009940109401194012940139401494015940169401794018940199402094021940229402394024940259402694027940289402994030940319403294033940349403594036940379403894039940409404194042940439404494045940469404794048940499405094051940529405394054940559405694057940589405994060940619406294063940649406594066940679406894069940709407194072940739407494075940769407794078940799408094081940829408394084940859408694087940889408994090940919409294093940949409594096940979409894099941009410194102941039410494105941069410794108941099411094111941129411394114941159411694117941189411994120941219412294123941249412594126941279412894129941309413194132941339413494135941369413794138941399414094141941429414394144941459414694147941489414994150941519415294153941549415594156941579415894159941609416194162941639416494165941669416794168941699417094171941729417394174941759417694177941789417994180941819418294183941849418594186941879418894189941909419194192941939419494195941969419794198941999420094201942029420394204942059420694207942089420994210942119421294213942149421594216942179421894219942209422194222942239422494225942269422794228942299423094231942329423394234942359423694237942389423994240942419424294243942449424594246942479424894249942509425194252942539425494255942569425794258942599426094261942629426394264942659426694267942689426994270942719427294273942749427594276942779427894279942809428194282942839428494285942869428794288942899429094291942929429394294942959429694297942989429994300943019430294303943049430594306943079430894309943109431194312943139431494315943169431794318943199432094321943229432394324943259432694327943289432994330943319433294333943349433594336943379433894339943409434194342943439434494345943469434794348943499435094351943529435394354943559435694357943589435994360943619436294363943649436594366943679436894369943709437194372943739437494375943769437794378943799438094381943829438394384943859438694387943889438994390943919439294393943949439594396943979439894399944009440194402944039440494405944069440794408944099441094411944129441394414944159441694417944189441994420944219442294423944249442594426944279442894429944309443194432944339443494435944369443794438944399444094441
  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. * Constant used as key code for Alt key
  1141. */
  1142. static readonly INPUT_ALT_KEY: number;
  1143. /**
  1144. * Constant used as key code for Ctrl key
  1145. */
  1146. static readonly INPUT_CTRL_KEY: number;
  1147. /**
  1148. * Constant used as key code for Meta key (Left Win, Left Cmd)
  1149. */
  1150. static readonly INPUT_META_KEY1: number;
  1151. /**
  1152. * Constant used as key code for Meta key (Right Win)
  1153. */
  1154. static readonly INPUT_META_KEY2: number;
  1155. /**
  1156. * Constant used as key code for Meta key (Right Win, Right Cmd)
  1157. */
  1158. static readonly INPUT_META_KEY3: number;
  1159. /**
  1160. * Constant used as key code for Shift key
  1161. */
  1162. static readonly INPUT_SHIFT_KEY: number;
  1163. }
  1164. }
  1165. declare module BABYLON {
  1166. /** @hidden */
  1167. export interface HardwareTextureWrapper {
  1168. underlyingResource: any;
  1169. set(hardwareTexture: any): void;
  1170. setUsage(textureSource: number, generateMipMaps: boolean, isCube: boolean, width: number, height: number): void;
  1171. reset(): void;
  1172. release(): void;
  1173. }
  1174. }
  1175. declare module BABYLON {
  1176. /**
  1177. * This represents the required contract to create a new type of texture loader.
  1178. */
  1179. export interface IInternalTextureLoader {
  1180. /**
  1181. * Defines whether the loader supports cascade loading the different faces.
  1182. */
  1183. supportCascades: boolean;
  1184. /**
  1185. * This returns if the loader support the current file information.
  1186. * @param extension defines the file extension of the file being loaded
  1187. * @param mimeType defines the optional mime type of the file being loaded
  1188. * @returns true if the loader can load the specified file
  1189. */
  1190. canLoad(extension: string, mimeType?: string): boolean;
  1191. /**
  1192. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1193. * @param data contains the texture data
  1194. * @param texture defines the BabylonJS internal texture
  1195. * @param createPolynomials will be true if polynomials have been requested
  1196. * @param onLoad defines the callback to trigger once the texture is ready
  1197. * @param onError defines the callback to trigger in case of error
  1198. * @param options options to be passed to the loader
  1199. */
  1200. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, options?: any): void;
  1201. /**
  1202. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1203. * @param data contains the texture data
  1204. * @param texture defines the BabylonJS internal texture
  1205. * @param callback defines the method to call once ready to upload
  1206. * @param options options to be passed to the loader
  1207. */
  1208. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void, options?: any): void;
  1209. }
  1210. }
  1211. declare module BABYLON {
  1212. /**
  1213. * @hidden
  1214. */
  1215. export interface IColor4Like {
  1216. r: float;
  1217. g: float;
  1218. b: float;
  1219. a: float;
  1220. }
  1221. /**
  1222. * @hidden
  1223. */
  1224. export interface IColor3Like {
  1225. r: float;
  1226. g: float;
  1227. b: float;
  1228. }
  1229. /**
  1230. * @hidden
  1231. */
  1232. export interface IVector4Like {
  1233. x: float;
  1234. y: float;
  1235. z: float;
  1236. w: float;
  1237. }
  1238. /**
  1239. * @hidden
  1240. */
  1241. export interface IVector3Like {
  1242. x: float;
  1243. y: float;
  1244. z: float;
  1245. }
  1246. /**
  1247. * @hidden
  1248. */
  1249. export interface IVector2Like {
  1250. x: float;
  1251. y: float;
  1252. }
  1253. /**
  1254. * @hidden
  1255. */
  1256. export interface IMatrixLike {
  1257. toArray(): DeepImmutable<Float32Array | Array<number>>;
  1258. updateFlag: int;
  1259. }
  1260. /**
  1261. * @hidden
  1262. */
  1263. export interface IViewportLike {
  1264. x: float;
  1265. y: float;
  1266. width: float;
  1267. height: float;
  1268. }
  1269. /**
  1270. * @hidden
  1271. */
  1272. export interface IPlaneLike {
  1273. normal: IVector3Like;
  1274. d: float;
  1275. normalize(): void;
  1276. }
  1277. }
  1278. declare module BABYLON {
  1279. /**
  1280. * Class used to store and describe the pipeline context associated with an effect
  1281. */
  1282. export interface IPipelineContext {
  1283. /**
  1284. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1285. */
  1286. isAsync: boolean;
  1287. /**
  1288. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1289. */
  1290. isReady: boolean;
  1291. /** @hidden */
  1292. _name?: string;
  1293. /** @hidden */
  1294. _getVertexShaderCode(): string | null;
  1295. /** @hidden */
  1296. _getFragmentShaderCode(): string | null;
  1297. /** @hidden */
  1298. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1299. /** @hidden */
  1300. _fillEffectInformation(effect: Effect, uniformBuffersNames: {
  1301. [key: string]: number;
  1302. }, uniformsNames: string[], uniforms: {
  1303. [key: string]: Nullable<WebGLUniformLocation>;
  1304. }, samplerList: string[], samplers: {
  1305. [key: string]: number;
  1306. }, attributesNames: string[], attributes: number[]): void;
  1307. /** Releases the resources associated with the pipeline. */
  1308. dispose(): void;
  1309. /**
  1310. * Sets an integer value on a uniform variable.
  1311. * @param uniformName Name of the variable.
  1312. * @param value Value to be set.
  1313. */
  1314. setInt(uniformName: string, value: number): void;
  1315. /**
  1316. * Sets an int2 value on a uniform variable.
  1317. * @param uniformName Name of the variable.
  1318. * @param x First int in int2.
  1319. * @param y Second int in int2.
  1320. */
  1321. setInt2(uniformName: string, x: number, y: number): void;
  1322. /**
  1323. * Sets an int3 value on a uniform variable.
  1324. * @param uniformName Name of the variable.
  1325. * @param x First int in int3.
  1326. * @param y Second int in int3.
  1327. * @param z Third int in int3.
  1328. */
  1329. setInt3(uniformName: string, x: number, y: number, z: number): void;
  1330. /**
  1331. * Sets an int4 value on a uniform variable.
  1332. * @param uniformName Name of the variable.
  1333. * @param x First int in int4.
  1334. * @param y Second int in int4.
  1335. * @param z Third int in int4.
  1336. * @param w Fourth int in int4.
  1337. */
  1338. setInt4(uniformName: string, x: number, y: number, z: number, w: number): void;
  1339. /**
  1340. * Sets an int array on a uniform variable.
  1341. * @param uniformName Name of the variable.
  1342. * @param array array to be set.
  1343. */
  1344. setIntArray(uniformName: string, array: Int32Array): void;
  1345. /**
  1346. * 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)
  1347. * @param uniformName Name of the variable.
  1348. * @param array array to be set.
  1349. */
  1350. setIntArray2(uniformName: string, array: Int32Array): void;
  1351. /**
  1352. * 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)
  1353. * @param uniformName Name of the variable.
  1354. * @param array array to be set.
  1355. */
  1356. setIntArray3(uniformName: string, array: Int32Array): void;
  1357. /**
  1358. * 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)
  1359. * @param uniformName Name of the variable.
  1360. * @param array array to be set.
  1361. */
  1362. setIntArray4(uniformName: string, array: Int32Array): void;
  1363. /**
  1364. * Sets an array on a uniform variable.
  1365. * @param uniformName Name of the variable.
  1366. * @param array array to be set.
  1367. */
  1368. setArray(uniformName: string, array: number[] | Float32Array): void;
  1369. /**
  1370. * 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)
  1371. * @param uniformName Name of the variable.
  1372. * @param array array to be set.
  1373. */
  1374. setArray2(uniformName: string, array: number[] | Float32Array): void;
  1375. /**
  1376. * 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)
  1377. * @param uniformName Name of the variable.
  1378. * @param array array to be set.
  1379. */
  1380. setArray3(uniformName: string, array: number[] | Float32Array): void;
  1381. /**
  1382. * 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)
  1383. * @param uniformName Name of the variable.
  1384. * @param array array to be set.
  1385. */
  1386. setArray4(uniformName: string, array: number[] | Float32Array): void;
  1387. /**
  1388. * Sets matrices on a uniform variable.
  1389. * @param uniformName Name of the variable.
  1390. * @param matrices matrices to be set.
  1391. */
  1392. setMatrices(uniformName: string, matrices: Float32Array): void;
  1393. /**
  1394. * Sets matrix on a uniform variable.
  1395. * @param uniformName Name of the variable.
  1396. * @param matrix matrix to be set.
  1397. */
  1398. setMatrix(uniformName: string, matrix: IMatrixLike): void;
  1399. /**
  1400. * 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)
  1401. * @param uniformName Name of the variable.
  1402. * @param matrix matrix to be set.
  1403. */
  1404. setMatrix3x3(uniformName: string, matrix: Float32Array): void;
  1405. /**
  1406. * Sets a 2x2 matrix on a uniform variable. (Specified as [1,2,3,4] will result in [1,2][3,4] matrix)
  1407. * @param uniformName Name of the variable.
  1408. * @param matrix matrix to be set.
  1409. */
  1410. setMatrix2x2(uniformName: string, matrix: Float32Array): void;
  1411. /**
  1412. * Sets a float on a uniform variable.
  1413. * @param uniformName Name of the variable.
  1414. * @param value value to be set.
  1415. */
  1416. setFloat(uniformName: string, value: number): void;
  1417. /**
  1418. * Sets a Vector2 on a uniform variable.
  1419. * @param uniformName Name of the variable.
  1420. * @param vector2 vector2 to be set.
  1421. */
  1422. setVector2(uniformName: string, vector2: IVector2Like): void;
  1423. /**
  1424. * Sets a float2 on a uniform variable.
  1425. * @param uniformName Name of the variable.
  1426. * @param x First float in float2.
  1427. * @param y Second float in float2.
  1428. */
  1429. setFloat2(uniformName: string, x: number, y: number): void;
  1430. /**
  1431. * Sets a Vector3 on a uniform variable.
  1432. * @param uniformName Name of the variable.
  1433. * @param vector3 Value to be set.
  1434. */
  1435. setVector3(uniformName: string, vector3: IVector3Like): void;
  1436. /**
  1437. * Sets a float3 on a uniform variable.
  1438. * @param uniformName Name of the variable.
  1439. * @param x First float in float3.
  1440. * @param y Second float in float3.
  1441. * @param z Third float in float3.
  1442. */
  1443. setFloat3(uniformName: string, x: number, y: number, z: number): void;
  1444. /**
  1445. * Sets a Vector4 on a uniform variable.
  1446. * @param uniformName Name of the variable.
  1447. * @param vector4 Value to be set.
  1448. */
  1449. setVector4(uniformName: string, vector4: IVector4Like): void;
  1450. /**
  1451. * Sets a float4 on a uniform variable.
  1452. * @param uniformName Name of the variable.
  1453. * @param x First float in float4.
  1454. * @param y Second float in float4.
  1455. * @param z Third float in float4.
  1456. * @param w Fourth float in float4.
  1457. */
  1458. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): void;
  1459. /**
  1460. * Sets a Color3 on a uniform variable.
  1461. * @param uniformName Name of the variable.
  1462. * @param color3 Value to be set.
  1463. */
  1464. setColor3(uniformName: string, color3: IColor3Like): void;
  1465. /**
  1466. * Sets a Color4 on a uniform variable.
  1467. * @param uniformName Name of the variable.
  1468. * @param color3 Value to be set.
  1469. * @param alpha Alpha value to be set.
  1470. */
  1471. setColor4(uniformName: string, color3: IColor3Like, alpha: number): void;
  1472. /**
  1473. * Sets a Color4 on a uniform variable
  1474. * @param uniformName defines the name of the variable
  1475. * @param color4 defines the value to be set
  1476. */
  1477. setDirectColor4(uniformName: string, color4: IColor4Like): void;
  1478. }
  1479. }
  1480. declare module BABYLON {
  1481. /**
  1482. * Class used to store gfx data (like WebGLBuffer)
  1483. */
  1484. export class DataBuffer {
  1485. private static _Counter;
  1486. /**
  1487. * Gets or sets the number of objects referencing this buffer
  1488. */
  1489. references: number;
  1490. /** Gets or sets the size of the underlying buffer */
  1491. capacity: number;
  1492. /**
  1493. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1494. */
  1495. is32Bits: boolean;
  1496. /**
  1497. * Gets the underlying buffer
  1498. */
  1499. get underlyingResource(): any;
  1500. /**
  1501. * Gets the unique id of this buffer
  1502. */
  1503. readonly uniqueId: number;
  1504. /**
  1505. * Constructs the buffer
  1506. */
  1507. constructor();
  1508. }
  1509. }
  1510. declare module BABYLON {
  1511. /** @hidden */
  1512. export interface IShaderProcessor {
  1513. attributeProcessor?: (attribute: string, preProcessors: {
  1514. [key: string]: string;
  1515. }, processingContext: Nullable<ShaderProcessingContext>) => string;
  1516. varyingProcessor?: (varying: string, isFragment: boolean, preProcessors: {
  1517. [key: string]: string;
  1518. }, processingContext: Nullable<ShaderProcessingContext>) => string;
  1519. uniformProcessor?: (uniform: string, isFragment: boolean, preProcessors: {
  1520. [key: string]: string;
  1521. }, processingContext: Nullable<ShaderProcessingContext>) => string;
  1522. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  1523. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  1524. lineProcessor?: (line: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  1525. preProcessor?: (code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  1526. postProcessor?: (code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>, engine: ThinEngine) => string;
  1527. initializeShaders?: (processingContext: Nullable<ShaderProcessingContext>) => void;
  1528. finalizeShaders?: (vertexCode: string, fragmentCode: string, processingContext: Nullable<ShaderProcessingContext>) => {
  1529. vertexCode: string;
  1530. fragmentCode: string;
  1531. };
  1532. }
  1533. }
  1534. declare module BABYLON {
  1535. /** @hidden */
  1536. export interface ShaderProcessingContext {
  1537. }
  1538. /** @hidden */
  1539. export interface ProcessingOptions {
  1540. defines: string[];
  1541. indexParameters: any;
  1542. isFragment: boolean;
  1543. shouldUseHighPrecisionShader: boolean;
  1544. supportsUniformBuffers: boolean;
  1545. shadersRepository: string;
  1546. includesShadersStore: {
  1547. [key: string]: string;
  1548. };
  1549. processor: Nullable<IShaderProcessor>;
  1550. version: string;
  1551. platformName: string;
  1552. lookForClosingBracketForUniformBuffer?: boolean;
  1553. processingContext: Nullable<ShaderProcessingContext>;
  1554. }
  1555. }
  1556. declare module BABYLON {
  1557. /** @hidden */
  1558. export class ShaderCodeNode {
  1559. line: string;
  1560. children: ShaderCodeNode[];
  1561. additionalDefineKey?: string;
  1562. additionalDefineValue?: string;
  1563. isValid(preprocessors: {
  1564. [key: string]: string;
  1565. }): boolean;
  1566. process(preprocessors: {
  1567. [key: string]: string;
  1568. }, options: ProcessingOptions): string;
  1569. }
  1570. }
  1571. declare module BABYLON {
  1572. /** @hidden */
  1573. export class ShaderCodeCursor {
  1574. private _lines;
  1575. lineIndex: number;
  1576. get currentLine(): string;
  1577. get canRead(): boolean;
  1578. set lines(value: string[]);
  1579. }
  1580. }
  1581. declare module BABYLON {
  1582. /** @hidden */
  1583. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1584. process(preprocessors: {
  1585. [key: string]: string;
  1586. }, options: ProcessingOptions): string;
  1587. }
  1588. }
  1589. declare module BABYLON {
  1590. /** @hidden */
  1591. export class ShaderDefineExpression {
  1592. isTrue(preprocessors: {
  1593. [key: string]: string;
  1594. }): boolean;
  1595. private static _OperatorPriority;
  1596. private static _Stack;
  1597. static postfixToInfix(postfix: string[]): string;
  1598. static infixToPostfix(infix: string): string[];
  1599. }
  1600. }
  1601. declare module BABYLON {
  1602. /** @hidden */
  1603. export class ShaderCodeTestNode extends ShaderCodeNode {
  1604. testExpression: ShaderDefineExpression;
  1605. isValid(preprocessors: {
  1606. [key: string]: string;
  1607. }): boolean;
  1608. }
  1609. }
  1610. declare module BABYLON {
  1611. /** @hidden */
  1612. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1613. define: string;
  1614. not: boolean;
  1615. constructor(define: string, not?: boolean);
  1616. isTrue(preprocessors: {
  1617. [key: string]: string;
  1618. }): boolean;
  1619. }
  1620. }
  1621. declare module BABYLON {
  1622. /** @hidden */
  1623. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1624. leftOperand: ShaderDefineExpression;
  1625. rightOperand: ShaderDefineExpression;
  1626. isTrue(preprocessors: {
  1627. [key: string]: string;
  1628. }): boolean;
  1629. }
  1630. }
  1631. declare module BABYLON {
  1632. /** @hidden */
  1633. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1634. leftOperand: ShaderDefineExpression;
  1635. rightOperand: ShaderDefineExpression;
  1636. isTrue(preprocessors: {
  1637. [key: string]: string;
  1638. }): boolean;
  1639. }
  1640. }
  1641. declare module BABYLON {
  1642. /** @hidden */
  1643. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1644. define: string;
  1645. operand: string;
  1646. testValue: string;
  1647. constructor(define: string, operand: string, testValue: string);
  1648. isTrue(preprocessors: {
  1649. [key: string]: string;
  1650. }): boolean;
  1651. }
  1652. }
  1653. declare module BABYLON {
  1654. /**
  1655. * Class used to enable access to offline support
  1656. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1657. */
  1658. export interface IOfflineProvider {
  1659. /**
  1660. * Gets a boolean indicating if scene must be saved in the database
  1661. */
  1662. enableSceneOffline: boolean;
  1663. /**
  1664. * Gets a boolean indicating if textures must be saved in the database
  1665. */
  1666. enableTexturesOffline: boolean;
  1667. /**
  1668. * Open the offline support and make it available
  1669. * @param successCallback defines the callback to call on success
  1670. * @param errorCallback defines the callback to call on error
  1671. */
  1672. open(successCallback: () => void, errorCallback: () => void): void;
  1673. /**
  1674. * Loads an image from the offline support
  1675. * @param url defines the url to load from
  1676. * @param image defines the target DOM image
  1677. */
  1678. loadImage(url: string, image: HTMLImageElement): void;
  1679. /**
  1680. * Loads a file from offline support
  1681. * @param url defines the URL to load from
  1682. * @param sceneLoaded defines a callback to call on success
  1683. * @param progressCallBack defines a callback to call when progress changed
  1684. * @param errorCallback defines a callback to call on error
  1685. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1686. */
  1687. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1688. }
  1689. }
  1690. declare module BABYLON {
  1691. /**
  1692. * Class used to help managing file picking and drag'n'drop
  1693. * File Storage
  1694. */
  1695. export class FilesInputStore {
  1696. /**
  1697. * List of files ready to be loaded
  1698. */
  1699. static FilesToLoad: {
  1700. [key: string]: File;
  1701. };
  1702. }
  1703. }
  1704. declare module BABYLON {
  1705. /**
  1706. * Class used to define a retry strategy when error happens while loading assets
  1707. */
  1708. export class RetryStrategy {
  1709. /**
  1710. * Function used to defines an exponential back off strategy
  1711. * @param maxRetries defines the maximum number of retries (3 by default)
  1712. * @param baseInterval defines the interval between retries
  1713. * @returns the strategy function to use
  1714. */
  1715. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1716. }
  1717. }
  1718. declare module BABYLON {
  1719. /**
  1720. * @ignore
  1721. * Application error to support additional information when loading a file
  1722. */
  1723. export abstract class BaseError extends Error {
  1724. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1725. }
  1726. }
  1727. declare module BABYLON {
  1728. /** @ignore */
  1729. export class LoadFileError extends BaseError {
  1730. request?: WebRequest;
  1731. file?: File;
  1732. /**
  1733. * Creates a new LoadFileError
  1734. * @param message defines the message of the error
  1735. * @param request defines the optional web request
  1736. * @param file defines the optional file
  1737. */
  1738. constructor(message: string, object?: WebRequest | File);
  1739. }
  1740. /** @ignore */
  1741. export class RequestFileError extends BaseError {
  1742. request: WebRequest;
  1743. /**
  1744. * Creates a new LoadFileError
  1745. * @param message defines the message of the error
  1746. * @param request defines the optional web request
  1747. */
  1748. constructor(message: string, request: WebRequest);
  1749. }
  1750. /** @ignore */
  1751. export class ReadFileError extends BaseError {
  1752. file: File;
  1753. /**
  1754. * Creates a new ReadFileError
  1755. * @param message defines the message of the error
  1756. * @param file defines the optional file
  1757. */
  1758. constructor(message: string, file: File);
  1759. }
  1760. /**
  1761. * @hidden
  1762. */
  1763. export class FileTools {
  1764. /**
  1765. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1766. */
  1767. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1768. /**
  1769. * Gets or sets the base URL to use to load assets
  1770. */
  1771. static BaseUrl: string;
  1772. /**
  1773. * Default behaviour for cors in the application.
  1774. * It can be a string if the expected behavior is identical in the entire app.
  1775. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1776. */
  1777. static CorsBehavior: string | ((url: string | string[]) => string);
  1778. /**
  1779. * Gets or sets a function used to pre-process url before using them to load assets
  1780. */
  1781. static PreprocessUrl: (url: string) => string;
  1782. /**
  1783. * Removes unwanted characters from an url
  1784. * @param url defines the url to clean
  1785. * @returns the cleaned url
  1786. */
  1787. private static _CleanUrl;
  1788. /**
  1789. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1790. * @param url define the url we are trying
  1791. * @param element define the dom element where to configure the cors policy
  1792. */
  1793. static SetCorsBehavior(url: string | string[], element: {
  1794. crossOrigin: string | null;
  1795. }): void;
  1796. /**
  1797. * Loads an image as an HTMLImageElement.
  1798. * @param input url string, ArrayBuffer, or Blob to load
  1799. * @param onLoad callback called when the image successfully loads
  1800. * @param onError callback called when the image fails to load
  1801. * @param offlineProvider offline provider for caching
  1802. * @param mimeType optional mime type
  1803. * @returns the HTMLImageElement of the loaded image
  1804. */
  1805. 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>;
  1806. /**
  1807. * Reads a file from a File object
  1808. * @param file defines the file to load
  1809. * @param onSuccess defines the callback to call when data is loaded
  1810. * @param onProgress defines the callback to call during loading process
  1811. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1812. * @param onError defines the callback to call when an error occurs
  1813. * @returns a file request object
  1814. */
  1815. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1816. /**
  1817. * Loads a file from a url
  1818. * @param url url to load
  1819. * @param onSuccess callback called when the file successfully loads
  1820. * @param onProgress callback called while file is loading (if the server supports this mode)
  1821. * @param offlineProvider defines the offline provider for caching
  1822. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1823. * @param onError callback called when the file fails to load
  1824. * @returns a file request object
  1825. */
  1826. 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;
  1827. /**
  1828. * Loads a file
  1829. * @param url url to load
  1830. * @param onSuccess callback called when the file successfully loads
  1831. * @param onProgress callback called while file is loading (if the server supports this mode)
  1832. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1833. * @param onError callback called when the file fails to load
  1834. * @param onOpened callback called when the web request is opened
  1835. * @returns a file request object
  1836. */
  1837. 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;
  1838. /**
  1839. * Checks if the loaded document was accessed via `file:`-Protocol.
  1840. * @returns boolean
  1841. */
  1842. static IsFileURL(): boolean;
  1843. }
  1844. }
  1845. declare module BABYLON {
  1846. /** @hidden */
  1847. export class ShaderProcessor {
  1848. static Initialize(options: ProcessingOptions): void;
  1849. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void, engine: ThinEngine): void;
  1850. static Finalize(vertexCode: string, fragmentCode: string, options: ProcessingOptions): {
  1851. vertexCode: string;
  1852. fragmentCode: string;
  1853. };
  1854. private static _ProcessPrecision;
  1855. private static _ExtractOperation;
  1856. private static _BuildSubExpression;
  1857. private static _BuildExpression;
  1858. private static _MoveCursorWithinIf;
  1859. private static _MoveCursor;
  1860. private static _EvaluatePreProcessors;
  1861. private static _PreparePreProcessors;
  1862. private static _ProcessShaderConversion;
  1863. private static _ProcessIncludes;
  1864. /**
  1865. * Loads a file from a url
  1866. * @param url url to load
  1867. * @param onSuccess callback called when the file successfully loads
  1868. * @param onProgress callback called while file is loading (if the server supports this mode)
  1869. * @param offlineProvider defines the offline provider for caching
  1870. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1871. * @param onError callback called when the file fails to load
  1872. * @returns a file request object
  1873. * @hidden
  1874. */
  1875. 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;
  1876. }
  1877. }
  1878. declare module BABYLON {
  1879. /**
  1880. * Interface used to define common properties for effect fallbacks
  1881. */
  1882. export interface IEffectFallbacks {
  1883. /**
  1884. * Removes the defines that should be removed when falling back.
  1885. * @param currentDefines defines the current define statements for the shader.
  1886. * @param effect defines the current effect we try to compile
  1887. * @returns The resulting defines with defines of the current rank removed.
  1888. */
  1889. reduce(currentDefines: string, effect: Effect): string;
  1890. /**
  1891. * Removes the fallback from the bound mesh.
  1892. */
  1893. unBindMesh(): void;
  1894. /**
  1895. * Checks to see if more fallbacks are still available.
  1896. */
  1897. hasMoreFallbacks: boolean;
  1898. }
  1899. }
  1900. declare module BABYLON {
  1901. /**
  1902. * Interface for the size containing width and height
  1903. */
  1904. export interface ISize {
  1905. /**
  1906. * Width
  1907. */
  1908. width: number;
  1909. /**
  1910. * Heighht
  1911. */
  1912. height: number;
  1913. }
  1914. /**
  1915. * Size containing widht and height
  1916. */
  1917. export class Size implements ISize {
  1918. /**
  1919. * Width
  1920. */
  1921. width: number;
  1922. /**
  1923. * Height
  1924. */
  1925. height: number;
  1926. /**
  1927. * Creates a Size object from the given width and height (floats).
  1928. * @param width width of the new size
  1929. * @param height height of the new size
  1930. */
  1931. constructor(width: number, height: number);
  1932. /**
  1933. * Returns a string with the Size width and height
  1934. * @returns a string with the Size width and height
  1935. */
  1936. toString(): string;
  1937. /**
  1938. * "Size"
  1939. * @returns the string "Size"
  1940. */
  1941. getClassName(): string;
  1942. /**
  1943. * Returns the Size hash code.
  1944. * @returns a hash code for a unique width and height
  1945. */
  1946. getHashCode(): number;
  1947. /**
  1948. * Updates the current size from the given one.
  1949. * @param src the given size
  1950. */
  1951. copyFrom(src: Size): void;
  1952. /**
  1953. * Updates in place the current Size from the given floats.
  1954. * @param width width of the new size
  1955. * @param height height of the new size
  1956. * @returns the updated Size.
  1957. */
  1958. copyFromFloats(width: number, height: number): Size;
  1959. /**
  1960. * Updates in place the current Size from the given floats.
  1961. * @param width width to set
  1962. * @param height height to set
  1963. * @returns the updated Size.
  1964. */
  1965. set(width: number, height: number): Size;
  1966. /**
  1967. * Multiplies the width and height by numbers
  1968. * @param w factor to multiple the width by
  1969. * @param h factor to multiple the height by
  1970. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  1971. */
  1972. multiplyByFloats(w: number, h: number): Size;
  1973. /**
  1974. * Clones the size
  1975. * @returns a new Size copied from the given one.
  1976. */
  1977. clone(): Size;
  1978. /**
  1979. * True if the current Size and the given one width and height are strictly equal.
  1980. * @param other the other size to compare against
  1981. * @returns True if the current Size and the given one width and height are strictly equal.
  1982. */
  1983. equals(other: Size): boolean;
  1984. /**
  1985. * The surface of the Size : width * height (float).
  1986. */
  1987. get surface(): number;
  1988. /**
  1989. * Create a new size of zero
  1990. * @returns a new Size set to (0.0, 0.0)
  1991. */
  1992. static Zero(): Size;
  1993. /**
  1994. * Sums the width and height of two sizes
  1995. * @param otherSize size to add to this size
  1996. * @returns a new Size set as the addition result of the current Size and the given one.
  1997. */
  1998. add(otherSize: Size): Size;
  1999. /**
  2000. * Subtracts the width and height of two
  2001. * @param otherSize size to subtract to this size
  2002. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2003. */
  2004. subtract(otherSize: Size): Size;
  2005. /**
  2006. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2007. * @param start starting size to lerp between
  2008. * @param end end size to lerp between
  2009. * @param amount amount to lerp between the start and end values
  2010. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2011. */
  2012. static Lerp(start: Size, end: Size, amount: number): Size;
  2013. }
  2014. }
  2015. declare module BABYLON {
  2016. /**
  2017. * Base class of all the textures in babylon.
  2018. * It groups all the common properties required to work with Thin Engine.
  2019. */
  2020. export class ThinTexture {
  2021. protected _wrapU: number;
  2022. /**
  2023. * | Value | Type | Description |
  2024. * | ----- | ------------------ | ----------- |
  2025. * | 0 | CLAMP_ADDRESSMODE | |
  2026. * | 1 | WRAP_ADDRESSMODE | |
  2027. * | 2 | MIRROR_ADDRESSMODE | |
  2028. */
  2029. get wrapU(): number;
  2030. set wrapU(value: number);
  2031. protected _wrapV: number;
  2032. /**
  2033. * | Value | Type | Description |
  2034. * | ----- | ------------------ | ----------- |
  2035. * | 0 | CLAMP_ADDRESSMODE | |
  2036. * | 1 | WRAP_ADDRESSMODE | |
  2037. * | 2 | MIRROR_ADDRESSMODE | |
  2038. */
  2039. get wrapV(): number;
  2040. set wrapV(value: number);
  2041. /**
  2042. * | Value | Type | Description |
  2043. * | ----- | ------------------ | ----------- |
  2044. * | 0 | CLAMP_ADDRESSMODE | |
  2045. * | 1 | WRAP_ADDRESSMODE | |
  2046. * | 2 | MIRROR_ADDRESSMODE | |
  2047. */
  2048. wrapR: number;
  2049. /**
  2050. * With compliant hardware and browser (supporting anisotropic filtering)
  2051. * this defines the level of anisotropic filtering in the texture.
  2052. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  2053. */
  2054. anisotropicFilteringLevel: number;
  2055. /**
  2056. * Define the current state of the loading sequence when in delayed load mode.
  2057. */
  2058. delayLoadState: number;
  2059. /**
  2060. * How a texture is mapped.
  2061. * Unused in thin texture mode.
  2062. */
  2063. get coordinatesMode(): number;
  2064. /**
  2065. * Define if the texture is a cube texture or if false a 2d texture.
  2066. */
  2067. get isCube(): boolean;
  2068. set isCube(value: boolean);
  2069. /**
  2070. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  2071. */
  2072. get is3D(): boolean;
  2073. set is3D(value: boolean);
  2074. /**
  2075. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  2076. */
  2077. get is2DArray(): boolean;
  2078. set is2DArray(value: boolean);
  2079. /**
  2080. * Get the class name of the texture.
  2081. * @returns "ThinTexture"
  2082. */
  2083. getClassName(): string;
  2084. /** @hidden */
  2085. _texture: Nullable<InternalTexture>;
  2086. protected _engine: Nullable<ThinEngine>;
  2087. private _cachedSize;
  2088. private _cachedBaseSize;
  2089. /**
  2090. * Instantiates a new ThinTexture.
  2091. * Base class of all the textures in babylon.
  2092. * This can be used as an internal texture wrapper in ThinEngine to benefit from the cache
  2093. * @param internalTexture Define the internalTexture to wrap
  2094. */
  2095. constructor(internalTexture: Nullable<InternalTexture>);
  2096. /**
  2097. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  2098. * @returns true if fully ready
  2099. */
  2100. isReady(): boolean;
  2101. /**
  2102. * Triggers the load sequence in delayed load mode.
  2103. */
  2104. delayLoad(): void;
  2105. /**
  2106. * Get the underlying lower level texture from Babylon.
  2107. * @returns the internal texture
  2108. */
  2109. getInternalTexture(): Nullable<InternalTexture>;
  2110. /**
  2111. * Get the size of the texture.
  2112. * @returns the texture size.
  2113. */
  2114. getSize(): ISize;
  2115. /**
  2116. * Get the base size of the texture.
  2117. * It can be different from the size if the texture has been resized for POT for instance
  2118. * @returns the base size
  2119. */
  2120. getBaseSize(): ISize;
  2121. /**
  2122. * Update the sampling mode of the texture.
  2123. * Default is Trilinear mode.
  2124. *
  2125. * | Value | Type | Description |
  2126. * | ----- | ------------------ | ----------- |
  2127. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  2128. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  2129. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  2130. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  2131. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  2132. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  2133. * | 7 | NEAREST_LINEAR | |
  2134. * | 8 | NEAREST_NEAREST | |
  2135. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  2136. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  2137. * | 11 | LINEAR_LINEAR | |
  2138. * | 12 | LINEAR_NEAREST | |
  2139. *
  2140. * > _mag_: magnification filter (close to the viewer)
  2141. * > _min_: minification filter (far from the viewer)
  2142. * > _mip_: filter used between mip map levels
  2143. *@param samplingMode Define the new sampling mode of the texture
  2144. */
  2145. updateSamplingMode(samplingMode: number): void;
  2146. /**
  2147. * Release and destroy the underlying lower level texture aka internalTexture.
  2148. */
  2149. releaseInternalTexture(): void;
  2150. /**
  2151. * Dispose the texture and release its associated resources.
  2152. */
  2153. dispose(): void;
  2154. }
  2155. }
  2156. declare module BABYLON {
  2157. /**
  2158. * Defines an array and its length.
  2159. * It can be helpful to group result from both Arrays and smart arrays in one structure.
  2160. */
  2161. export interface ISmartArrayLike<T> {
  2162. /**
  2163. * The data of the array.
  2164. */
  2165. data: Array<T>;
  2166. /**
  2167. * The active length of the array.
  2168. */
  2169. length: number;
  2170. }
  2171. /**
  2172. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  2173. */
  2174. export class SmartArray<T> implements ISmartArrayLike<T> {
  2175. /**
  2176. * The full set of data from the array.
  2177. */
  2178. data: Array<T>;
  2179. /**
  2180. * The active length of the array.
  2181. */
  2182. length: number;
  2183. protected _id: number;
  2184. /**
  2185. * Instantiates a Smart Array.
  2186. * @param capacity defines the default capacity of the array.
  2187. */
  2188. constructor(capacity: number);
  2189. /**
  2190. * Pushes a value at the end of the active data.
  2191. * @param value defines the object to push in the array.
  2192. */
  2193. push(value: T): void;
  2194. /**
  2195. * Iterates over the active data and apply the lambda to them.
  2196. * @param func defines the action to apply on each value.
  2197. */
  2198. forEach(func: (content: T) => void): void;
  2199. /**
  2200. * Sorts the full sets of data.
  2201. * @param compareFn defines the comparison function to apply.
  2202. */
  2203. sort(compareFn: (a: T, b: T) => number): void;
  2204. /**
  2205. * Resets the active data to an empty array.
  2206. */
  2207. reset(): void;
  2208. /**
  2209. * Releases all the data from the array as well as the array.
  2210. */
  2211. dispose(): void;
  2212. /**
  2213. * Concats the active data with a given array.
  2214. * @param array defines the data to concatenate with.
  2215. */
  2216. concat(array: any): void;
  2217. /**
  2218. * Returns the position of a value in the active data.
  2219. * @param value defines the value to find the index for
  2220. * @returns the index if found in the active data otherwise -1
  2221. */
  2222. indexOf(value: T): number;
  2223. /**
  2224. * Returns whether an element is part of the active data.
  2225. * @param value defines the value to look for
  2226. * @returns true if found in the active data otherwise false
  2227. */
  2228. contains(value: T): boolean;
  2229. private static _GlobalId;
  2230. }
  2231. /**
  2232. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  2233. * The data in this array can only be present once
  2234. */
  2235. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  2236. private _duplicateId;
  2237. /**
  2238. * Pushes a value at the end of the active data.
  2239. * THIS DOES NOT PREVENT DUPPLICATE DATA
  2240. * @param value defines the object to push in the array.
  2241. */
  2242. push(value: T): void;
  2243. /**
  2244. * Pushes a value at the end of the active data.
  2245. * If the data is already present, it won t be added again
  2246. * @param value defines the object to push in the array.
  2247. * @returns true if added false if it was already present
  2248. */
  2249. pushNoDuplicate(value: T): boolean;
  2250. /**
  2251. * Resets the active data to an empty array.
  2252. */
  2253. reset(): void;
  2254. /**
  2255. * Concats the active data with a given array.
  2256. * This ensures no duplicate will be present in the result.
  2257. * @param array defines the data to concatenate with.
  2258. */
  2259. concatWithNoDuplicate(array: any): void;
  2260. }
  2261. }
  2262. declare module BABYLON {
  2263. /**
  2264. * Class used to evaluate queries containing `and` and `or` operators
  2265. */
  2266. export class AndOrNotEvaluator {
  2267. /**
  2268. * Evaluate a query
  2269. * @param query defines the query to evaluate
  2270. * @param evaluateCallback defines the callback used to filter result
  2271. * @returns true if the query matches
  2272. */
  2273. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  2274. private static _HandleParenthesisContent;
  2275. private static _SimplifyNegation;
  2276. }
  2277. }
  2278. declare module BABYLON {
  2279. /**
  2280. * Class used to store custom tags
  2281. */
  2282. export class Tags {
  2283. /**
  2284. * Adds support for tags on the given object
  2285. * @param obj defines the object to use
  2286. */
  2287. static EnableFor(obj: any): void;
  2288. /**
  2289. * Removes tags support
  2290. * @param obj defines the object to use
  2291. */
  2292. static DisableFor(obj: any): void;
  2293. /**
  2294. * Gets a boolean indicating if the given object has tags
  2295. * @param obj defines the object to use
  2296. * @returns a boolean
  2297. */
  2298. static HasTags(obj: any): boolean;
  2299. /**
  2300. * Gets the tags available on a given object
  2301. * @param obj defines the object to use
  2302. * @param asString defines if the tags must be returned as a string instead of an array of strings
  2303. * @returns the tags
  2304. */
  2305. static GetTags(obj: any, asString?: boolean): any;
  2306. /**
  2307. * Adds tags to an object
  2308. * @param obj defines the object to use
  2309. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  2310. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  2311. */
  2312. static AddTagsTo(obj: any, tagsString: string): void;
  2313. /**
  2314. * @hidden
  2315. */
  2316. static _AddTagTo(obj: any, tag: string): void;
  2317. /**
  2318. * Removes specific tags from a specific object
  2319. * @param obj defines the object to use
  2320. * @param tagsString defines the tags to remove
  2321. */
  2322. static RemoveTagsFrom(obj: any, tagsString: string): void;
  2323. /**
  2324. * @hidden
  2325. */
  2326. static _RemoveTagFrom(obj: any, tag: string): void;
  2327. /**
  2328. * Defines if tags hosted on an object match a given query
  2329. * @param obj defines the object to use
  2330. * @param tagsQuery defines the tag query
  2331. * @returns a boolean
  2332. */
  2333. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  2334. }
  2335. }
  2336. declare module BABYLON {
  2337. /**
  2338. * Scalar computation library
  2339. */
  2340. export class Scalar {
  2341. /**
  2342. * Two pi constants convenient for computation.
  2343. */
  2344. static TwoPi: number;
  2345. /**
  2346. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  2347. * @param a number
  2348. * @param b number
  2349. * @param epsilon (default = 1.401298E-45)
  2350. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  2351. */
  2352. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  2353. /**
  2354. * Returns a string : the upper case translation of the number i to hexadecimal.
  2355. * @param i number
  2356. * @returns the upper case translation of the number i to hexadecimal.
  2357. */
  2358. static ToHex(i: number): string;
  2359. /**
  2360. * Returns -1 if value is negative and +1 is value is positive.
  2361. * @param value the value
  2362. * @returns the value itself if it's equal to zero.
  2363. */
  2364. static Sign(value: number): number;
  2365. /**
  2366. * Returns the value itself if it's between min and max.
  2367. * Returns min if the value is lower than min.
  2368. * Returns max if the value is greater than max.
  2369. * @param value the value to clmap
  2370. * @param min the min value to clamp to (default: 0)
  2371. * @param max the max value to clamp to (default: 1)
  2372. * @returns the clamped value
  2373. */
  2374. static Clamp(value: number, min?: number, max?: number): number;
  2375. /**
  2376. * the log2 of value.
  2377. * @param value the value to compute log2 of
  2378. * @returns the log2 of value.
  2379. */
  2380. static Log2(value: number): number;
  2381. /**
  2382. * the floor part of a log2 value.
  2383. * @param value the value to compute log2 of
  2384. * @returns the log2 of value.
  2385. */
  2386. static ILog2(value: number): number;
  2387. /**
  2388. * Loops the value, so that it is never larger than length and never smaller than 0.
  2389. *
  2390. * This is similar to the modulo operator but it works with floating point numbers.
  2391. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  2392. * With t = 5 and length = 2.5, the result would be 0.0.
  2393. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  2394. * @param value the value
  2395. * @param length the length
  2396. * @returns the looped value
  2397. */
  2398. static Repeat(value: number, length: number): number;
  2399. /**
  2400. * Normalize the value between 0.0 and 1.0 using min and max values
  2401. * @param value value to normalize
  2402. * @param min max to normalize between
  2403. * @param max min to normalize between
  2404. * @returns the normalized value
  2405. */
  2406. static Normalize(value: number, min: number, max: number): number;
  2407. /**
  2408. * Denormalize the value from 0.0 and 1.0 using min and max values
  2409. * @param normalized value to denormalize
  2410. * @param min max to denormalize between
  2411. * @param max min to denormalize between
  2412. * @returns the denormalized value
  2413. */
  2414. static Denormalize(normalized: number, min: number, max: number): number;
  2415. /**
  2416. * Calculates the shortest difference between two given angles given in degrees.
  2417. * @param current current angle in degrees
  2418. * @param target target angle in degrees
  2419. * @returns the delta
  2420. */
  2421. static DeltaAngle(current: number, target: number): number;
  2422. /**
  2423. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  2424. * @param tx value
  2425. * @param length length
  2426. * @returns The returned value will move back and forth between 0 and length
  2427. */
  2428. static PingPong(tx: number, length: number): number;
  2429. /**
  2430. * Interpolates between min and max with smoothing at the limits.
  2431. *
  2432. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  2433. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  2434. * @param from from
  2435. * @param to to
  2436. * @param tx value
  2437. * @returns the smooth stepped value
  2438. */
  2439. static SmoothStep(from: number, to: number, tx: number): number;
  2440. /**
  2441. * Moves a value current towards target.
  2442. *
  2443. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  2444. * Negative values of maxDelta pushes the value away from target.
  2445. * @param current current value
  2446. * @param target target value
  2447. * @param maxDelta max distance to move
  2448. * @returns resulting value
  2449. */
  2450. static MoveTowards(current: number, target: number, maxDelta: number): number;
  2451. /**
  2452. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  2453. *
  2454. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  2455. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  2456. * @param current current value
  2457. * @param target target value
  2458. * @param maxDelta max distance to move
  2459. * @returns resulting angle
  2460. */
  2461. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  2462. /**
  2463. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  2464. * @param start start value
  2465. * @param end target value
  2466. * @param amount amount to lerp between
  2467. * @returns the lerped value
  2468. */
  2469. static Lerp(start: number, end: number, amount: number): number;
  2470. /**
  2471. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  2472. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  2473. * @param start start value
  2474. * @param end target value
  2475. * @param amount amount to lerp between
  2476. * @returns the lerped value
  2477. */
  2478. static LerpAngle(start: number, end: number, amount: number): number;
  2479. /**
  2480. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  2481. * @param a start value
  2482. * @param b target value
  2483. * @param value value between a and b
  2484. * @returns the inverseLerp value
  2485. */
  2486. static InverseLerp(a: number, b: number, value: number): number;
  2487. /**
  2488. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  2489. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  2490. * @param value1 spline value
  2491. * @param tangent1 spline value
  2492. * @param value2 spline value
  2493. * @param tangent2 spline value
  2494. * @param amount input value
  2495. * @returns hermite result
  2496. */
  2497. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  2498. /**
  2499. * Returns a random float number between and min and max values
  2500. * @param min min value of random
  2501. * @param max max value of random
  2502. * @returns random value
  2503. */
  2504. static RandomRange(min: number, max: number): number;
  2505. /**
  2506. * This function returns percentage of a number in a given range.
  2507. *
  2508. * RangeToPercent(40,20,60) will return 0.5 (50%)
  2509. * RangeToPercent(34,0,100) will return 0.34 (34%)
  2510. * @param number to convert to percentage
  2511. * @param min min range
  2512. * @param max max range
  2513. * @returns the percentage
  2514. */
  2515. static RangeToPercent(number: number, min: number, max: number): number;
  2516. /**
  2517. * This function returns number that corresponds to the percentage in a given range.
  2518. *
  2519. * PercentToRange(0.34,0,100) will return 34.
  2520. * @param percent to convert to number
  2521. * @param min min range
  2522. * @param max max range
  2523. * @returns the number
  2524. */
  2525. static PercentToRange(percent: number, min: number, max: number): number;
  2526. /**
  2527. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  2528. * @param angle The angle to normalize in radian.
  2529. * @return The converted angle.
  2530. */
  2531. static NormalizeRadians(angle: number): number;
  2532. }
  2533. }
  2534. declare module BABYLON {
  2535. /**
  2536. * Constant used to convert a value to gamma space
  2537. * @ignorenaming
  2538. */
  2539. export const ToGammaSpace: number;
  2540. /**
  2541. * Constant used to convert a value to linear space
  2542. * @ignorenaming
  2543. */
  2544. export const ToLinearSpace = 2.2;
  2545. /**
  2546. * Constant used to define the minimal number value in Babylon.js
  2547. * @ignorenaming
  2548. */
  2549. let Epsilon: number;
  2550. }
  2551. declare module BABYLON {
  2552. /**
  2553. * Class used to represent a viewport on screen
  2554. */
  2555. export class Viewport {
  2556. /** viewport left coordinate */
  2557. x: number;
  2558. /** viewport top coordinate */
  2559. y: number;
  2560. /**viewport width */
  2561. width: number;
  2562. /** viewport height */
  2563. height: number;
  2564. /**
  2565. * Creates a Viewport object located at (x, y) and sized (width, height)
  2566. * @param x defines viewport left coordinate
  2567. * @param y defines viewport top coordinate
  2568. * @param width defines the viewport width
  2569. * @param height defines the viewport height
  2570. */
  2571. constructor(
  2572. /** viewport left coordinate */
  2573. x: number,
  2574. /** viewport top coordinate */
  2575. y: number,
  2576. /**viewport width */
  2577. width: number,
  2578. /** viewport height */
  2579. height: number);
  2580. /**
  2581. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  2582. * @param renderWidth defines the rendering width
  2583. * @param renderHeight defines the rendering height
  2584. * @returns a new Viewport
  2585. */
  2586. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  2587. /**
  2588. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  2589. * @param renderWidth defines the rendering width
  2590. * @param renderHeight defines the rendering height
  2591. * @param ref defines the target viewport
  2592. * @returns the current viewport
  2593. */
  2594. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  2595. /**
  2596. * Returns a new Viewport copied from the current one
  2597. * @returns a new Viewport
  2598. */
  2599. clone(): Viewport;
  2600. }
  2601. }
  2602. declare module BABYLON {
  2603. /**
  2604. * Class containing a set of static utilities functions for arrays.
  2605. */
  2606. export class ArrayTools {
  2607. /**
  2608. * Returns an array of the given size filled with element built from the given constructor and the parameters
  2609. * @param size the number of element to construct and put in the array
  2610. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  2611. * @returns a new array filled with new objects
  2612. */
  2613. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  2614. }
  2615. }
  2616. declare module BABYLON {
  2617. /**
  2618. * Represents a plane by the equation ax + by + cz + d = 0
  2619. */
  2620. export class Plane {
  2621. private static _TmpMatrix;
  2622. /**
  2623. * Normal of the plane (a,b,c)
  2624. */
  2625. normal: Vector3;
  2626. /**
  2627. * d component of the plane
  2628. */
  2629. d: number;
  2630. /**
  2631. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  2632. * @param a a component of the plane
  2633. * @param b b component of the plane
  2634. * @param c c component of the plane
  2635. * @param d d component of the plane
  2636. */
  2637. constructor(a: number, b: number, c: number, d: number);
  2638. /**
  2639. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  2640. */
  2641. asArray(): number[];
  2642. /**
  2643. * @returns a new plane copied from the current Plane.
  2644. */
  2645. clone(): Plane;
  2646. /**
  2647. * @returns the string "Plane".
  2648. */
  2649. getClassName(): string;
  2650. /**
  2651. * @returns the Plane hash code.
  2652. */
  2653. getHashCode(): number;
  2654. /**
  2655. * Normalize the current Plane in place.
  2656. * @returns the updated Plane.
  2657. */
  2658. normalize(): Plane;
  2659. /**
  2660. * Applies a transformation the plane and returns the result
  2661. * @param transformation the transformation matrix to be applied to the plane
  2662. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  2663. */
  2664. transform(transformation: DeepImmutable<Matrix>): Plane;
  2665. /**
  2666. * Compute the dot product between the point and the plane normal
  2667. * @param point point to calculate the dot product with
  2668. * @returns the dot product (float) of the point coordinates and the plane normal.
  2669. */
  2670. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2671. /**
  2672. * Updates the current Plane from the plane defined by the three given points.
  2673. * @param point1 one of the points used to contruct the plane
  2674. * @param point2 one of the points used to contruct the plane
  2675. * @param point3 one of the points used to contruct the plane
  2676. * @returns the updated Plane.
  2677. */
  2678. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2679. /**
  2680. * 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).
  2681. * Note that for this function to work as expected you should make sure that:
  2682. * - direction and the plane normal are normalized
  2683. * - epsilon is a number just bigger than -1, something like -0.99 for eg
  2684. * @param direction the direction to check if the plane is facing
  2685. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2686. * @returns True if the plane is facing the given direction
  2687. */
  2688. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2689. /**
  2690. * Calculates the distance to a point
  2691. * @param point point to calculate distance to
  2692. * @returns the signed distance (float) from the given point to the Plane.
  2693. */
  2694. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2695. /**
  2696. * Creates a plane from an array
  2697. * @param array the array to create a plane from
  2698. * @returns a new Plane from the given array.
  2699. */
  2700. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2701. /**
  2702. * Creates a plane from three points
  2703. * @param point1 point used to create the plane
  2704. * @param point2 point used to create the plane
  2705. * @param point3 point used to create the plane
  2706. * @returns a new Plane defined by the three given points.
  2707. */
  2708. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2709. /**
  2710. * Creates a plane from an origin point and a normal
  2711. * @param origin origin of the plane to be constructed
  2712. * @param normal normal of the plane to be constructed
  2713. * @returns a new Plane the normal vector to this plane at the given origin point.
  2714. * Note : the vector "normal" is updated because normalized.
  2715. */
  2716. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2717. /**
  2718. * Calculates the distance from a plane and a point
  2719. * @param origin origin of the plane to be constructed
  2720. * @param normal normal of the plane to be constructed
  2721. * @param point point to calculate distance to
  2722. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2723. */
  2724. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2725. }
  2726. }
  2727. declare module BABYLON {
  2728. /** @hidden */
  2729. export class PerformanceConfigurator {
  2730. /** @hidden */
  2731. static MatrixUse64Bits: boolean;
  2732. /** @hidden */
  2733. static MatrixTrackPrecisionChange: boolean;
  2734. /** @hidden */
  2735. static MatrixCurrentType: any;
  2736. /** @hidden */
  2737. static MatrixTrackedMatrices: Array<any> | null;
  2738. /** @hidden */
  2739. static SetMatrixPrecision(use64bits: boolean): void;
  2740. }
  2741. }
  2742. declare module BABYLON {
  2743. /**
  2744. * Class representing a vector containing 2 coordinates
  2745. */
  2746. export class Vector2 {
  2747. /** defines the first coordinate */
  2748. x: number;
  2749. /** defines the second coordinate */
  2750. y: number;
  2751. /**
  2752. * Creates a new Vector2 from the given x and y coordinates
  2753. * @param x defines the first coordinate
  2754. * @param y defines the second coordinate
  2755. */
  2756. constructor(
  2757. /** defines the first coordinate */
  2758. x?: number,
  2759. /** defines the second coordinate */
  2760. y?: number);
  2761. /**
  2762. * Gets a string with the Vector2 coordinates
  2763. * @returns a string with the Vector2 coordinates
  2764. */
  2765. toString(): string;
  2766. /**
  2767. * Gets class name
  2768. * @returns the string "Vector2"
  2769. */
  2770. getClassName(): string;
  2771. /**
  2772. * Gets current vector hash code
  2773. * @returns the Vector2 hash code as a number
  2774. */
  2775. getHashCode(): number;
  2776. /**
  2777. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2778. * @param array defines the source array
  2779. * @param index defines the offset in source array
  2780. * @returns the current Vector2
  2781. */
  2782. toArray(array: FloatArray, index?: number): Vector2;
  2783. /**
  2784. * Update the current vector from an array
  2785. * @param array defines the destination array
  2786. * @param index defines the offset in the destination array
  2787. * @returns the current Vector3
  2788. */
  2789. fromArray(array: FloatArray, index?: number): Vector2;
  2790. /**
  2791. * Copy the current vector to an array
  2792. * @returns a new array with 2 elements: the Vector2 coordinates.
  2793. */
  2794. asArray(): number[];
  2795. /**
  2796. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2797. * @param source defines the source Vector2
  2798. * @returns the current updated Vector2
  2799. */
  2800. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2801. /**
  2802. * Sets the Vector2 coordinates with the given floats
  2803. * @param x defines the first coordinate
  2804. * @param y defines the second coordinate
  2805. * @returns the current updated Vector2
  2806. */
  2807. copyFromFloats(x: number, y: number): Vector2;
  2808. /**
  2809. * Sets the Vector2 coordinates with the given floats
  2810. * @param x defines the first coordinate
  2811. * @param y defines the second coordinate
  2812. * @returns the current updated Vector2
  2813. */
  2814. set(x: number, y: number): Vector2;
  2815. /**
  2816. * Add another vector with the current one
  2817. * @param otherVector defines the other vector
  2818. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2819. */
  2820. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2821. /**
  2822. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2823. * @param otherVector defines the other vector
  2824. * @param result defines the target vector
  2825. * @returns the unmodified current Vector2
  2826. */
  2827. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2828. /**
  2829. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2830. * @param otherVector defines the other vector
  2831. * @returns the current updated Vector2
  2832. */
  2833. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2834. /**
  2835. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2836. * @param otherVector defines the other vector
  2837. * @returns a new Vector2
  2838. */
  2839. addVector3(otherVector: Vector3): Vector2;
  2840. /**
  2841. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2842. * @param otherVector defines the other vector
  2843. * @returns a new Vector2
  2844. */
  2845. subtract(otherVector: Vector2): Vector2;
  2846. /**
  2847. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2848. * @param otherVector defines the other vector
  2849. * @param result defines the target vector
  2850. * @returns the unmodified current Vector2
  2851. */
  2852. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2853. /**
  2854. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2855. * @param otherVector defines the other vector
  2856. * @returns the current updated Vector2
  2857. */
  2858. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2859. /**
  2860. * Multiplies in place the current Vector2 coordinates by the given ones
  2861. * @param otherVector defines the other vector
  2862. * @returns the current updated Vector2
  2863. */
  2864. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2865. /**
  2866. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2867. * @param otherVector defines the other vector
  2868. * @returns a new Vector2
  2869. */
  2870. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2871. /**
  2872. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2873. * @param otherVector defines the other vector
  2874. * @param result defines the target vector
  2875. * @returns the unmodified current Vector2
  2876. */
  2877. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2878. /**
  2879. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2880. * @param x defines the first coordinate
  2881. * @param y defines the second coordinate
  2882. * @returns a new Vector2
  2883. */
  2884. multiplyByFloats(x: number, y: number): Vector2;
  2885. /**
  2886. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2887. * @param otherVector defines the other vector
  2888. * @returns a new Vector2
  2889. */
  2890. divide(otherVector: Vector2): Vector2;
  2891. /**
  2892. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2893. * @param otherVector defines the other vector
  2894. * @param result defines the target vector
  2895. * @returns the unmodified current Vector2
  2896. */
  2897. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2898. /**
  2899. * Divides the current Vector2 coordinates by the given ones
  2900. * @param otherVector defines the other vector
  2901. * @returns the current updated Vector2
  2902. */
  2903. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2904. /**
  2905. * Gets a new Vector2 with current Vector2 negated coordinates
  2906. * @returns a new Vector2
  2907. */
  2908. negate(): Vector2;
  2909. /**
  2910. * Negate this vector in place
  2911. * @returns this
  2912. */
  2913. negateInPlace(): Vector2;
  2914. /**
  2915. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2916. * @param result defines the Vector3 object where to store the result
  2917. * @returns the current Vector2
  2918. */
  2919. negateToRef(result: Vector2): Vector2;
  2920. /**
  2921. * Multiply the Vector2 coordinates by scale
  2922. * @param scale defines the scaling factor
  2923. * @returns the current updated Vector2
  2924. */
  2925. scaleInPlace(scale: number): Vector2;
  2926. /**
  2927. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2928. * @param scale defines the scaling factor
  2929. * @returns a new Vector2
  2930. */
  2931. scale(scale: number): Vector2;
  2932. /**
  2933. * Scale the current Vector2 values by a factor to a given Vector2
  2934. * @param scale defines the scale factor
  2935. * @param result defines the Vector2 object where to store the result
  2936. * @returns the unmodified current Vector2
  2937. */
  2938. scaleToRef(scale: number, result: Vector2): Vector2;
  2939. /**
  2940. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2941. * @param scale defines the scale factor
  2942. * @param result defines the Vector2 object where to store the result
  2943. * @returns the unmodified current Vector2
  2944. */
  2945. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2946. /**
  2947. * Gets a boolean if two vectors are equals
  2948. * @param otherVector defines the other vector
  2949. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2950. */
  2951. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2952. /**
  2953. * Gets a boolean if two vectors are equals (using an epsilon value)
  2954. * @param otherVector defines the other vector
  2955. * @param epsilon defines the minimal distance to consider equality
  2956. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2957. */
  2958. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2959. /**
  2960. * Gets a new Vector2 from current Vector2 floored values
  2961. * @returns a new Vector2
  2962. */
  2963. floor(): Vector2;
  2964. /**
  2965. * Gets a new Vector2 from current Vector2 floored values
  2966. * @returns a new Vector2
  2967. */
  2968. fract(): Vector2;
  2969. /**
  2970. * Gets the length of the vector
  2971. * @returns the vector length (float)
  2972. */
  2973. length(): number;
  2974. /**
  2975. * Gets the vector squared length
  2976. * @returns the vector squared length (float)
  2977. */
  2978. lengthSquared(): number;
  2979. /**
  2980. * Normalize the vector
  2981. * @returns the current updated Vector2
  2982. */
  2983. normalize(): Vector2;
  2984. /**
  2985. * Gets a new Vector2 copied from the Vector2
  2986. * @returns a new Vector2
  2987. */
  2988. clone(): Vector2;
  2989. /**
  2990. * Gets a new Vector2(0, 0)
  2991. * @returns a new Vector2
  2992. */
  2993. static Zero(): Vector2;
  2994. /**
  2995. * Gets a new Vector2(1, 1)
  2996. * @returns a new Vector2
  2997. */
  2998. static One(): Vector2;
  2999. /**
  3000. * Gets a new Vector2 set from the given index element of the given array
  3001. * @param array defines the data source
  3002. * @param offset defines the offset in the data source
  3003. * @returns a new Vector2
  3004. */
  3005. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  3006. /**
  3007. * Sets "result" from the given index element of the given array
  3008. * @param array defines the data source
  3009. * @param offset defines the offset in the data source
  3010. * @param result defines the target vector
  3011. */
  3012. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  3013. /**
  3014. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  3015. * @param value1 defines 1st point of control
  3016. * @param value2 defines 2nd point of control
  3017. * @param value3 defines 3rd point of control
  3018. * @param value4 defines 4th point of control
  3019. * @param amount defines the interpolation factor
  3020. * @returns a new Vector2
  3021. */
  3022. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  3023. /**
  3024. * 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".
  3025. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  3026. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  3027. * @param value defines the value to clamp
  3028. * @param min defines the lower limit
  3029. * @param max defines the upper limit
  3030. * @returns a new Vector2
  3031. */
  3032. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  3033. /**
  3034. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  3035. * @param value1 defines the 1st control point
  3036. * @param tangent1 defines the outgoing tangent
  3037. * @param value2 defines the 2nd control point
  3038. * @param tangent2 defines the incoming tangent
  3039. * @param amount defines the interpolation factor
  3040. * @returns a new Vector2
  3041. */
  3042. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  3043. /**
  3044. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  3045. * @param start defines the start vector
  3046. * @param end defines the end vector
  3047. * @param amount defines the interpolation factor
  3048. * @returns a new Vector2
  3049. */
  3050. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  3051. /**
  3052. * Gets the dot product of the vector "left" and the vector "right"
  3053. * @param left defines first vector
  3054. * @param right defines second vector
  3055. * @returns the dot product (float)
  3056. */
  3057. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  3058. /**
  3059. * Returns a new Vector2 equal to the normalized given vector
  3060. * @param vector defines the vector to normalize
  3061. * @returns a new Vector2
  3062. */
  3063. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  3064. /**
  3065. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  3066. * @param left defines 1st vector
  3067. * @param right defines 2nd vector
  3068. * @returns a new Vector2
  3069. */
  3070. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  3071. /**
  3072. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  3073. * @param left defines 1st vector
  3074. * @param right defines 2nd vector
  3075. * @returns a new Vector2
  3076. */
  3077. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  3078. /**
  3079. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  3080. * @param vector defines the vector to transform
  3081. * @param transformation defines the matrix to apply
  3082. * @returns a new Vector2
  3083. */
  3084. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  3085. /**
  3086. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  3087. * @param vector defines the vector to transform
  3088. * @param transformation defines the matrix to apply
  3089. * @param result defines the target vector
  3090. */
  3091. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  3092. /**
  3093. * Determines if a given vector is included in a triangle
  3094. * @param p defines the vector to test
  3095. * @param p0 defines 1st triangle point
  3096. * @param p1 defines 2nd triangle point
  3097. * @param p2 defines 3rd triangle point
  3098. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  3099. */
  3100. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  3101. /**
  3102. * Gets the distance between the vectors "value1" and "value2"
  3103. * @param value1 defines first vector
  3104. * @param value2 defines second vector
  3105. * @returns the distance between vectors
  3106. */
  3107. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  3108. /**
  3109. * Returns the squared distance between the vectors "value1" and "value2"
  3110. * @param value1 defines first vector
  3111. * @param value2 defines second vector
  3112. * @returns the squared distance between vectors
  3113. */
  3114. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  3115. /**
  3116. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  3117. * @param value1 defines first vector
  3118. * @param value2 defines second vector
  3119. * @returns a new Vector2
  3120. */
  3121. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  3122. /**
  3123. * Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
  3124. * @param value1 defines first vector
  3125. * @param value2 defines second vector
  3126. * @param ref defines third vector
  3127. * @returns ref
  3128. */
  3129. static CenterToRef(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, ref: DeepImmutable<Vector2>): Vector2;
  3130. /**
  3131. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  3132. * @param p defines the middle point
  3133. * @param segA defines one point of the segment
  3134. * @param segB defines the other point of the segment
  3135. * @returns the shortest distance
  3136. */
  3137. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  3138. }
  3139. /**
  3140. * Class used to store (x,y,z) vector representation
  3141. * A Vector3 is the main object used in 3D geometry
  3142. * It can represent etiher the coordinates of a point the space, either a direction
  3143. * Reminder: js uses a left handed forward facing system
  3144. */
  3145. export class Vector3 {
  3146. private static _UpReadOnly;
  3147. private static _ZeroReadOnly;
  3148. /** @hidden */
  3149. _x: number;
  3150. /** @hidden */
  3151. _y: number;
  3152. /** @hidden */
  3153. _z: number;
  3154. /** @hidden */
  3155. _isDirty: boolean;
  3156. /** Gets or sets the x coordinate */
  3157. get x(): number;
  3158. set x(value: number);
  3159. /** Gets or sets the y coordinate */
  3160. get y(): number;
  3161. set y(value: number);
  3162. /** Gets or sets the z coordinate */
  3163. get z(): number;
  3164. set z(value: number);
  3165. /**
  3166. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  3167. * @param x defines the first coordinates (on X axis)
  3168. * @param y defines the second coordinates (on Y axis)
  3169. * @param z defines the third coordinates (on Z axis)
  3170. */
  3171. constructor(x?: number, y?: number, z?: number);
  3172. /**
  3173. * Creates a string representation of the Vector3
  3174. * @returns a string with the Vector3 coordinates.
  3175. */
  3176. toString(): string;
  3177. /**
  3178. * Gets the class name
  3179. * @returns the string "Vector3"
  3180. */
  3181. getClassName(): string;
  3182. /**
  3183. * Creates the Vector3 hash code
  3184. * @returns a number which tends to be unique between Vector3 instances
  3185. */
  3186. getHashCode(): number;
  3187. /**
  3188. * Creates an array containing three elements : the coordinates of the Vector3
  3189. * @returns a new array of numbers
  3190. */
  3191. asArray(): number[];
  3192. /**
  3193. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  3194. * @param array defines the destination array
  3195. * @param index defines the offset in the destination array
  3196. * @returns the current Vector3
  3197. */
  3198. toArray(array: FloatArray, index?: number): Vector3;
  3199. /**
  3200. * Update the current vector from an array
  3201. * @param array defines the destination array
  3202. * @param index defines the offset in the destination array
  3203. * @returns the current Vector3
  3204. */
  3205. fromArray(array: FloatArray, index?: number): Vector3;
  3206. /**
  3207. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  3208. * @returns a new Quaternion object, computed from the Vector3 coordinates
  3209. */
  3210. toQuaternion(): Quaternion;
  3211. /**
  3212. * Adds the given vector to the current Vector3
  3213. * @param otherVector defines the second operand
  3214. * @returns the current updated Vector3
  3215. */
  3216. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  3217. /**
  3218. * Adds the given coordinates to the current Vector3
  3219. * @param x defines the x coordinate of the operand
  3220. * @param y defines the y coordinate of the operand
  3221. * @param z defines the z coordinate of the operand
  3222. * @returns the current updated Vector3
  3223. */
  3224. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  3225. /**
  3226. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  3227. * @param otherVector defines the second operand
  3228. * @returns the resulting Vector3
  3229. */
  3230. add(otherVector: DeepImmutable<Vector3>): Vector3;
  3231. /**
  3232. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  3233. * @param otherVector defines the second operand
  3234. * @param result defines the Vector3 object where to store the result
  3235. * @returns the current Vector3
  3236. */
  3237. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3238. /**
  3239. * Subtract the given vector from the current Vector3
  3240. * @param otherVector defines the second operand
  3241. * @returns the current updated Vector3
  3242. */
  3243. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  3244. /**
  3245. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  3246. * @param otherVector defines the second operand
  3247. * @returns the resulting Vector3
  3248. */
  3249. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  3250. /**
  3251. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  3252. * @param otherVector defines the second operand
  3253. * @param result defines the Vector3 object where to store the result
  3254. * @returns the current Vector3
  3255. */
  3256. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3257. /**
  3258. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  3259. * @param x defines the x coordinate of the operand
  3260. * @param y defines the y coordinate of the operand
  3261. * @param z defines the z coordinate of the operand
  3262. * @returns the resulting Vector3
  3263. */
  3264. subtractFromFloats(x: number, y: number, z: number): Vector3;
  3265. /**
  3266. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  3267. * @param x defines the x coordinate of the operand
  3268. * @param y defines the y coordinate of the operand
  3269. * @param z defines the z coordinate of the operand
  3270. * @param result defines the Vector3 object where to store the result
  3271. * @returns the current Vector3
  3272. */
  3273. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  3274. /**
  3275. * Gets a new Vector3 set with the current Vector3 negated coordinates
  3276. * @returns a new Vector3
  3277. */
  3278. negate(): Vector3;
  3279. /**
  3280. * Negate this vector in place
  3281. * @returns this
  3282. */
  3283. negateInPlace(): Vector3;
  3284. /**
  3285. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  3286. * @param result defines the Vector3 object where to store the result
  3287. * @returns the current Vector3
  3288. */
  3289. negateToRef(result: Vector3): Vector3;
  3290. /**
  3291. * Multiplies the Vector3 coordinates by the float "scale"
  3292. * @param scale defines the multiplier factor
  3293. * @returns the current updated Vector3
  3294. */
  3295. scaleInPlace(scale: number): Vector3;
  3296. /**
  3297. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  3298. * @param scale defines the multiplier factor
  3299. * @returns a new Vector3
  3300. */
  3301. scale(scale: number): Vector3;
  3302. /**
  3303. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  3304. * @param scale defines the multiplier factor
  3305. * @param result defines the Vector3 object where to store the result
  3306. * @returns the current Vector3
  3307. */
  3308. scaleToRef(scale: number, result: Vector3): Vector3;
  3309. /**
  3310. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  3311. * @param scale defines the scale factor
  3312. * @param result defines the Vector3 object where to store the result
  3313. * @returns the unmodified current Vector3
  3314. */
  3315. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  3316. /**
  3317. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  3318. * @param origin defines the origin of the projection ray
  3319. * @param plane defines the plane to project to
  3320. * @returns the projected vector3
  3321. */
  3322. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  3323. /**
  3324. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  3325. * @param origin defines the origin of the projection ray
  3326. * @param plane defines the plane to project to
  3327. * @param result defines the Vector3 where to store the result
  3328. */
  3329. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  3330. /**
  3331. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  3332. * @param otherVector defines the second operand
  3333. * @returns true if both vectors are equals
  3334. */
  3335. equals(otherVector: DeepImmutable<Vector3>): boolean;
  3336. /**
  3337. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  3338. * @param otherVector defines the second operand
  3339. * @param epsilon defines the minimal distance to define values as equals
  3340. * @returns true if both vectors are distant less than epsilon
  3341. */
  3342. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  3343. /**
  3344. * Returns true if the current Vector3 coordinates equals the given floats
  3345. * @param x defines the x coordinate of the operand
  3346. * @param y defines the y coordinate of the operand
  3347. * @param z defines the z coordinate of the operand
  3348. * @returns true if both vectors are equals
  3349. */
  3350. equalsToFloats(x: number, y: number, z: number): boolean;
  3351. /**
  3352. * Multiplies the current Vector3 coordinates by the given ones
  3353. * @param otherVector defines the second operand
  3354. * @returns the current updated Vector3
  3355. */
  3356. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  3357. /**
  3358. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  3359. * @param otherVector defines the second operand
  3360. * @returns the new Vector3
  3361. */
  3362. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  3363. /**
  3364. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  3365. * @param otherVector defines the second operand
  3366. * @param result defines the Vector3 object where to store the result
  3367. * @returns the current Vector3
  3368. */
  3369. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3370. /**
  3371. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  3372. * @param x defines the x coordinate of the operand
  3373. * @param y defines the y coordinate of the operand
  3374. * @param z defines the z coordinate of the operand
  3375. * @returns the new Vector3
  3376. */
  3377. multiplyByFloats(x: number, y: number, z: number): Vector3;
  3378. /**
  3379. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  3380. * @param otherVector defines the second operand
  3381. * @returns the new Vector3
  3382. */
  3383. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  3384. /**
  3385. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  3386. * @param otherVector defines the second operand
  3387. * @param result defines the Vector3 object where to store the result
  3388. * @returns the current Vector3
  3389. */
  3390. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3391. /**
  3392. * Divides the current Vector3 coordinates by the given ones.
  3393. * @param otherVector defines the second operand
  3394. * @returns the current updated Vector3
  3395. */
  3396. divideInPlace(otherVector: Vector3): Vector3;
  3397. /**
  3398. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  3399. * @param other defines the second operand
  3400. * @returns the current updated Vector3
  3401. */
  3402. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  3403. /**
  3404. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  3405. * @param other defines the second operand
  3406. * @returns the current updated Vector3
  3407. */
  3408. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  3409. /**
  3410. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  3411. * @param x defines the x coordinate of the operand
  3412. * @param y defines the y coordinate of the operand
  3413. * @param z defines the z coordinate of the operand
  3414. * @returns the current updated Vector3
  3415. */
  3416. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  3417. /**
  3418. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  3419. * @param x defines the x coordinate of the operand
  3420. * @param y defines the y coordinate of the operand
  3421. * @param z defines the z coordinate of the operand
  3422. * @returns the current updated Vector3
  3423. */
  3424. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  3425. /**
  3426. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  3427. * Check if is non uniform within a certain amount of decimal places to account for this
  3428. * @param epsilon the amount the values can differ
  3429. * @returns if the the vector is non uniform to a certain number of decimal places
  3430. */
  3431. isNonUniformWithinEpsilon(epsilon: number): boolean;
  3432. /**
  3433. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  3434. */
  3435. get isNonUniform(): boolean;
  3436. /**
  3437. * Gets a new Vector3 from current Vector3 floored values
  3438. * @returns a new Vector3
  3439. */
  3440. floor(): Vector3;
  3441. /**
  3442. * Gets a new Vector3 from current Vector3 floored values
  3443. * @returns a new Vector3
  3444. */
  3445. fract(): Vector3;
  3446. /**
  3447. * Gets the length of the Vector3
  3448. * @returns the length of the Vector3
  3449. */
  3450. length(): number;
  3451. /**
  3452. * Gets the squared length of the Vector3
  3453. * @returns squared length of the Vector3
  3454. */
  3455. lengthSquared(): number;
  3456. /**
  3457. * Normalize the current Vector3.
  3458. * Please note that this is an in place operation.
  3459. * @returns the current updated Vector3
  3460. */
  3461. normalize(): Vector3;
  3462. /**
  3463. * Reorders the x y z properties of the vector in place
  3464. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  3465. * @returns the current updated vector
  3466. */
  3467. reorderInPlace(order: string): this;
  3468. /**
  3469. * Rotates the vector around 0,0,0 by a quaternion
  3470. * @param quaternion the rotation quaternion
  3471. * @param result vector to store the result
  3472. * @returns the resulting vector
  3473. */
  3474. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  3475. /**
  3476. * Rotates a vector around a given point
  3477. * @param quaternion the rotation quaternion
  3478. * @param point the point to rotate around
  3479. * @param result vector to store the result
  3480. * @returns the resulting vector
  3481. */
  3482. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  3483. /**
  3484. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  3485. * The cross product is then orthogonal to both current and "other"
  3486. * @param other defines the right operand
  3487. * @returns the cross product
  3488. */
  3489. cross(other: Vector3): Vector3;
  3490. /**
  3491. * Normalize the current Vector3 with the given input length.
  3492. * Please note that this is an in place operation.
  3493. * @param len the length of the vector
  3494. * @returns the current updated Vector3
  3495. */
  3496. normalizeFromLength(len: number): Vector3;
  3497. /**
  3498. * Normalize the current Vector3 to a new vector
  3499. * @returns the new Vector3
  3500. */
  3501. normalizeToNew(): Vector3;
  3502. /**
  3503. * Normalize the current Vector3 to the reference
  3504. * @param reference define the Vector3 to update
  3505. * @returns the updated Vector3
  3506. */
  3507. normalizeToRef(reference: Vector3): Vector3;
  3508. /**
  3509. * Creates a new Vector3 copied from the current Vector3
  3510. * @returns the new Vector3
  3511. */
  3512. clone(): Vector3;
  3513. /**
  3514. * Copies the given vector coordinates to the current Vector3 ones
  3515. * @param source defines the source Vector3
  3516. * @returns the current updated Vector3
  3517. */
  3518. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  3519. /**
  3520. * Copies the given floats to the current Vector3 coordinates
  3521. * @param x defines the x coordinate of the operand
  3522. * @param y defines the y coordinate of the operand
  3523. * @param z defines the z coordinate of the operand
  3524. * @returns the current updated Vector3
  3525. */
  3526. copyFromFloats(x: number, y: number, z: number): Vector3;
  3527. /**
  3528. * Copies the given floats to the current Vector3 coordinates
  3529. * @param x defines the x coordinate of the operand
  3530. * @param y defines the y coordinate of the operand
  3531. * @param z defines the z coordinate of the operand
  3532. * @returns the current updated Vector3
  3533. */
  3534. set(x: number, y: number, z: number): Vector3;
  3535. /**
  3536. * Copies the given float to the current Vector3 coordinates
  3537. * @param v defines the x, y and z coordinates of the operand
  3538. * @returns the current updated Vector3
  3539. */
  3540. setAll(v: number): Vector3;
  3541. /**
  3542. * Get the clip factor between two vectors
  3543. * @param vector0 defines the first operand
  3544. * @param vector1 defines the second operand
  3545. * @param axis defines the axis to use
  3546. * @param size defines the size along the axis
  3547. * @returns the clip factor
  3548. */
  3549. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  3550. /**
  3551. * Get angle between two vectors
  3552. * @param vector0 angle between vector0 and vector1
  3553. * @param vector1 angle between vector0 and vector1
  3554. * @param normal direction of the normal
  3555. * @return the angle between vector0 and vector1
  3556. */
  3557. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  3558. /**
  3559. * Returns a new Vector3 set from the index "offset" of the given array
  3560. * @param array defines the source array
  3561. * @param offset defines the offset in the source array
  3562. * @returns the new Vector3
  3563. */
  3564. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  3565. /**
  3566. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  3567. * @param array defines the source array
  3568. * @param offset defines the offset in the source array
  3569. * @returns the new Vector3
  3570. * @deprecated Please use FromArray instead.
  3571. */
  3572. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  3573. /**
  3574. * Sets the given vector "result" with the element values from the index "offset" of the given array
  3575. * @param array defines the source array
  3576. * @param offset defines the offset in the source array
  3577. * @param result defines the Vector3 where to store the result
  3578. */
  3579. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  3580. /**
  3581. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  3582. * @param array defines the source array
  3583. * @param offset defines the offset in the source array
  3584. * @param result defines the Vector3 where to store the result
  3585. * @deprecated Please use FromArrayToRef instead.
  3586. */
  3587. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  3588. /**
  3589. * Sets the given vector "result" with the given floats.
  3590. * @param x defines the x coordinate of the source
  3591. * @param y defines the y coordinate of the source
  3592. * @param z defines the z coordinate of the source
  3593. * @param result defines the Vector3 where to store the result
  3594. */
  3595. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  3596. /**
  3597. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  3598. * @returns a new empty Vector3
  3599. */
  3600. static Zero(): Vector3;
  3601. /**
  3602. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  3603. * @returns a new unit Vector3
  3604. */
  3605. static One(): Vector3;
  3606. /**
  3607. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  3608. * @returns a new up Vector3
  3609. */
  3610. static Up(): Vector3;
  3611. /**
  3612. * Gets a up Vector3 that must not be updated
  3613. */
  3614. static get UpReadOnly(): DeepImmutable<Vector3>;
  3615. /**
  3616. * Gets a zero Vector3 that must not be updated
  3617. */
  3618. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  3619. /**
  3620. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  3621. * @returns a new down Vector3
  3622. */
  3623. static Down(): Vector3;
  3624. /**
  3625. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  3626. * @param rightHandedSystem is the scene right-handed (negative z)
  3627. * @returns a new forward Vector3
  3628. */
  3629. static Forward(rightHandedSystem?: boolean): Vector3;
  3630. /**
  3631. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  3632. * @param rightHandedSystem is the scene right-handed (negative-z)
  3633. * @returns a new forward Vector3
  3634. */
  3635. static Backward(rightHandedSystem?: boolean): Vector3;
  3636. /**
  3637. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  3638. * @returns a new right Vector3
  3639. */
  3640. static Right(): Vector3;
  3641. /**
  3642. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  3643. * @returns a new left Vector3
  3644. */
  3645. static Left(): Vector3;
  3646. /**
  3647. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  3648. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3649. * @param vector defines the Vector3 to transform
  3650. * @param transformation defines the transformation matrix
  3651. * @returns the transformed Vector3
  3652. */
  3653. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3654. /**
  3655. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  3656. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3657. * @param vector defines the Vector3 to transform
  3658. * @param transformation defines the transformation matrix
  3659. * @param result defines the Vector3 where to store the result
  3660. */
  3661. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3662. /**
  3663. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  3664. * This method computes tranformed coordinates only, not transformed direction vectors
  3665. * @param x define the x coordinate of the source vector
  3666. * @param y define the y coordinate of the source vector
  3667. * @param z define the z coordinate of the source vector
  3668. * @param transformation defines the transformation matrix
  3669. * @param result defines the Vector3 where to store the result
  3670. */
  3671. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3672. /**
  3673. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  3674. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3675. * @param vector defines the Vector3 to transform
  3676. * @param transformation defines the transformation matrix
  3677. * @returns the new Vector3
  3678. */
  3679. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3680. /**
  3681. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  3682. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3683. * @param vector defines the Vector3 to transform
  3684. * @param transformation defines the transformation matrix
  3685. * @param result defines the Vector3 where to store the result
  3686. */
  3687. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3688. /**
  3689. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  3690. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3691. * @param x define the x coordinate of the source vector
  3692. * @param y define the y coordinate of the source vector
  3693. * @param z define the z coordinate of the source vector
  3694. * @param transformation defines the transformation matrix
  3695. * @param result defines the Vector3 where to store the result
  3696. */
  3697. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3698. /**
  3699. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3700. * @param value1 defines the first control point
  3701. * @param value2 defines the second control point
  3702. * @param value3 defines the third control point
  3703. * @param value4 defines the fourth control point
  3704. * @param amount defines the amount on the spline to use
  3705. * @returns the new Vector3
  3706. */
  3707. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3708. /**
  3709. * 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"
  3710. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3711. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3712. * @param value defines the current value
  3713. * @param min defines the lower range value
  3714. * @param max defines the upper range value
  3715. * @returns the new Vector3
  3716. */
  3717. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3718. /**
  3719. * 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"
  3720. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3721. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3722. * @param value defines the current value
  3723. * @param min defines the lower range value
  3724. * @param max defines the upper range value
  3725. * @param result defines the Vector3 where to store the result
  3726. */
  3727. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3728. /**
  3729. * Checks if a given vector is inside a specific range
  3730. * @param v defines the vector to test
  3731. * @param min defines the minimum range
  3732. * @param max defines the maximum range
  3733. */
  3734. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3735. /**
  3736. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3737. * @param value1 defines the first control point
  3738. * @param tangent1 defines the first tangent vector
  3739. * @param value2 defines the second control point
  3740. * @param tangent2 defines the second tangent vector
  3741. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3742. * @returns the new Vector3
  3743. */
  3744. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3745. /**
  3746. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3747. * @param start defines the start value
  3748. * @param end defines the end value
  3749. * @param amount max defines amount between both (between 0 and 1)
  3750. * @returns the new Vector3
  3751. */
  3752. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3753. /**
  3754. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3755. * @param start defines the start value
  3756. * @param end defines the end value
  3757. * @param amount max defines amount between both (between 0 and 1)
  3758. * @param result defines the Vector3 where to store the result
  3759. */
  3760. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3761. /**
  3762. * Returns the dot product (float) between the vectors "left" and "right"
  3763. * @param left defines the left operand
  3764. * @param right defines the right operand
  3765. * @returns the dot product
  3766. */
  3767. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3768. /**
  3769. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3770. * The cross product is then orthogonal to both "left" and "right"
  3771. * @param left defines the left operand
  3772. * @param right defines the right operand
  3773. * @returns the cross product
  3774. */
  3775. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3776. /**
  3777. * Sets the given vector "result" with the cross product of "left" and "right"
  3778. * The cross product is then orthogonal to both "left" and "right"
  3779. * @param left defines the left operand
  3780. * @param right defines the right operand
  3781. * @param result defines the Vector3 where to store the result
  3782. */
  3783. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3784. /**
  3785. * Returns a new Vector3 as the normalization of the given vector
  3786. * @param vector defines the Vector3 to normalize
  3787. * @returns the new Vector3
  3788. */
  3789. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3790. /**
  3791. * Sets the given vector "result" with the normalization of the given first vector
  3792. * @param vector defines the Vector3 to normalize
  3793. * @param result defines the Vector3 where to store the result
  3794. */
  3795. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3796. /**
  3797. * Project a Vector3 onto screen space
  3798. * @param vector defines the Vector3 to project
  3799. * @param world defines the world matrix to use
  3800. * @param transform defines the transform (view x projection) matrix to use
  3801. * @param viewport defines the screen viewport to use
  3802. * @returns the new Vector3
  3803. */
  3804. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3805. /**
  3806. * Project a Vector3 onto screen space to reference
  3807. * @param vector defines the Vector3 to project
  3808. * @param world defines the world matrix to use
  3809. * @param transform defines the transform (view x projection) matrix to use
  3810. * @param viewport defines the screen viewport to use
  3811. * @param result the vector in which the screen space will be stored
  3812. * @returns the new Vector3
  3813. */
  3814. static ProjectToRef(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>, result: DeepImmutable<Vector3>): Vector3;
  3815. /** @hidden */
  3816. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3817. /**
  3818. * Unproject from screen space to object space
  3819. * @param source defines the screen space Vector3 to use
  3820. * @param viewportWidth defines the current width of the viewport
  3821. * @param viewportHeight defines the current height of the viewport
  3822. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3823. * @param transform defines the transform (view x projection) matrix to use
  3824. * @returns the new Vector3
  3825. */
  3826. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3827. /**
  3828. * Unproject from screen space to object space
  3829. * @param source defines the screen space Vector3 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. * @returns the new Vector3
  3836. */
  3837. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3838. /**
  3839. * Unproject from screen space to object space
  3840. * @param source defines the screen space Vector3 to use
  3841. * @param viewportWidth defines the current width of the viewport
  3842. * @param viewportHeight defines the current height of the viewport
  3843. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3844. * @param view defines the view matrix to use
  3845. * @param projection defines the projection matrix to use
  3846. * @param result defines the Vector3 where to store the result
  3847. */
  3848. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3849. /**
  3850. * Unproject from screen space to object space
  3851. * @param sourceX defines the screen space x coordinate to use
  3852. * @param sourceY defines the screen space y coordinate to use
  3853. * @param sourceZ defines the screen space z coordinate to use
  3854. * @param viewportWidth defines the current width of the viewport
  3855. * @param viewportHeight defines the current height of the viewport
  3856. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3857. * @param view defines the view matrix to use
  3858. * @param projection defines the projection matrix to use
  3859. * @param result defines the Vector3 where to store the result
  3860. */
  3861. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3862. /**
  3863. * Gets the minimal coordinate values between two Vector3
  3864. * @param left defines the first operand
  3865. * @param right defines the second operand
  3866. * @returns the new Vector3
  3867. */
  3868. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3869. /**
  3870. * Gets the maximal coordinate values between two Vector3
  3871. * @param left defines the first operand
  3872. * @param right defines the second operand
  3873. * @returns the new Vector3
  3874. */
  3875. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3876. /**
  3877. * Returns the distance between the vectors "value1" and "value2"
  3878. * @param value1 defines the first operand
  3879. * @param value2 defines the second operand
  3880. * @returns the distance
  3881. */
  3882. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3883. /**
  3884. * Returns the squared distance between the vectors "value1" and "value2"
  3885. * @param value1 defines the first operand
  3886. * @param value2 defines the second operand
  3887. * @returns the squared distance
  3888. */
  3889. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3890. /**
  3891. * Returns a new Vector3 located at the center between "value1" and "value2"
  3892. * @param value1 defines the first operand
  3893. * @param value2 defines the second operand
  3894. * @returns the new Vector3
  3895. */
  3896. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3897. /**
  3898. * Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
  3899. * @param value1 defines first vector
  3900. * @param value2 defines second vector
  3901. * @param ref defines third vector
  3902. * @returns ref
  3903. */
  3904. static CenterToRef(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, ref: DeepImmutable<Vector3>): Vector3;
  3905. /**
  3906. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3907. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3908. * to something in order to rotate it from its local system to the given target system
  3909. * Note: axis1, axis2 and axis3 are normalized during this operation
  3910. * @param axis1 defines the first axis
  3911. * @param axis2 defines the second axis
  3912. * @param axis3 defines the third axis
  3913. * @returns a new Vector3
  3914. */
  3915. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3916. /**
  3917. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3918. * @param axis1 defines the first axis
  3919. * @param axis2 defines the second axis
  3920. * @param axis3 defines the third axis
  3921. * @param ref defines the Vector3 where to store the result
  3922. */
  3923. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3924. }
  3925. /**
  3926. * Vector4 class created for EulerAngle class conversion to Quaternion
  3927. */
  3928. export class Vector4 {
  3929. /** x value of the vector */
  3930. x: number;
  3931. /** y value of the vector */
  3932. y: number;
  3933. /** z value of the vector */
  3934. z: number;
  3935. /** w value of the vector */
  3936. w: number;
  3937. /**
  3938. * Creates a Vector4 object from the given floats.
  3939. * @param x x value of the vector
  3940. * @param y y value of the vector
  3941. * @param z z value of the vector
  3942. * @param w w value of the vector
  3943. */
  3944. constructor(
  3945. /** x value of the vector */
  3946. x: number,
  3947. /** y value of the vector */
  3948. y: number,
  3949. /** z value of the vector */
  3950. z: number,
  3951. /** w value of the vector */
  3952. w: number);
  3953. /**
  3954. * Returns the string with the Vector4 coordinates.
  3955. * @returns a string containing all the vector values
  3956. */
  3957. toString(): string;
  3958. /**
  3959. * Returns the string "Vector4".
  3960. * @returns "Vector4"
  3961. */
  3962. getClassName(): string;
  3963. /**
  3964. * Returns the Vector4 hash code.
  3965. * @returns a unique hash code
  3966. */
  3967. getHashCode(): number;
  3968. /**
  3969. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3970. * @returns the resulting array
  3971. */
  3972. asArray(): number[];
  3973. /**
  3974. * Populates the given array from the given index with the Vector4 coordinates.
  3975. * @param array array to populate
  3976. * @param index index of the array to start at (default: 0)
  3977. * @returns the Vector4.
  3978. */
  3979. toArray(array: FloatArray, index?: number): Vector4;
  3980. /**
  3981. * Update the current vector from an array
  3982. * @param array defines the destination array
  3983. * @param index defines the offset in the destination array
  3984. * @returns the current Vector3
  3985. */
  3986. fromArray(array: FloatArray, index?: number): Vector4;
  3987. /**
  3988. * Adds the given vector to the current Vector4.
  3989. * @param otherVector the vector to add
  3990. * @returns the updated Vector4.
  3991. */
  3992. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3993. /**
  3994. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3995. * @param otherVector the vector to add
  3996. * @returns the resulting vector
  3997. */
  3998. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3999. /**
  4000. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  4001. * @param otherVector the vector to add
  4002. * @param result the vector to store the result
  4003. * @returns the current Vector4.
  4004. */
  4005. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  4006. /**
  4007. * Subtract in place the given vector from the current Vector4.
  4008. * @param otherVector the vector to subtract
  4009. * @returns the updated Vector4.
  4010. */
  4011. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  4012. /**
  4013. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  4014. * @param otherVector the vector to add
  4015. * @returns the new vector with the result
  4016. */
  4017. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  4018. /**
  4019. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  4020. * @param otherVector the vector to subtract
  4021. * @param result the vector to store the result
  4022. * @returns the current Vector4.
  4023. */
  4024. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  4025. /**
  4026. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  4027. */
  4028. /**
  4029. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  4030. * @param x value to subtract
  4031. * @param y value to subtract
  4032. * @param z value to subtract
  4033. * @param w value to subtract
  4034. * @returns new vector containing the result
  4035. */
  4036. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  4037. /**
  4038. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  4039. * @param x value to subtract
  4040. * @param y value to subtract
  4041. * @param z value to subtract
  4042. * @param w value to subtract
  4043. * @param result the vector to store the result in
  4044. * @returns the current Vector4.
  4045. */
  4046. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  4047. /**
  4048. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  4049. * @returns a new vector with the negated values
  4050. */
  4051. negate(): Vector4;
  4052. /**
  4053. * Negate this vector in place
  4054. * @returns this
  4055. */
  4056. negateInPlace(): Vector4;
  4057. /**
  4058. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  4059. * @param result defines the Vector3 object where to store the result
  4060. * @returns the current Vector4
  4061. */
  4062. negateToRef(result: Vector4): Vector4;
  4063. /**
  4064. * Multiplies the current Vector4 coordinates by scale (float).
  4065. * @param scale the number to scale with
  4066. * @returns the updated Vector4.
  4067. */
  4068. scaleInPlace(scale: number): Vector4;
  4069. /**
  4070. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  4071. * @param scale the number to scale with
  4072. * @returns a new vector with the result
  4073. */
  4074. scale(scale: number): Vector4;
  4075. /**
  4076. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  4077. * @param scale the number to scale with
  4078. * @param result a vector to store the result in
  4079. * @returns the current Vector4.
  4080. */
  4081. scaleToRef(scale: number, result: Vector4): Vector4;
  4082. /**
  4083. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  4084. * @param scale defines the scale factor
  4085. * @param result defines the Vector4 object where to store the result
  4086. * @returns the unmodified current Vector4
  4087. */
  4088. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  4089. /**
  4090. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  4091. * @param otherVector the vector to compare against
  4092. * @returns true if they are equal
  4093. */
  4094. equals(otherVector: DeepImmutable<Vector4>): boolean;
  4095. /**
  4096. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  4097. * @param otherVector vector to compare against
  4098. * @param epsilon (Default: very small number)
  4099. * @returns true if they are equal
  4100. */
  4101. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  4102. /**
  4103. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  4104. * @param x x value to compare against
  4105. * @param y y value to compare against
  4106. * @param z z value to compare against
  4107. * @param w w value to compare against
  4108. * @returns true if equal
  4109. */
  4110. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  4111. /**
  4112. * Multiplies in place the current Vector4 by the given one.
  4113. * @param otherVector vector to multiple with
  4114. * @returns the updated Vector4.
  4115. */
  4116. multiplyInPlace(otherVector: Vector4): Vector4;
  4117. /**
  4118. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  4119. * @param otherVector vector to multiple with
  4120. * @returns resulting new vector
  4121. */
  4122. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  4123. /**
  4124. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  4125. * @param otherVector vector to multiple with
  4126. * @param result vector to store the result
  4127. * @returns the current Vector4.
  4128. */
  4129. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  4130. /**
  4131. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  4132. * @param x x value multiply with
  4133. * @param y y value multiply with
  4134. * @param z z value multiply with
  4135. * @param w w value multiply with
  4136. * @returns resulting new vector
  4137. */
  4138. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  4139. /**
  4140. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  4141. * @param otherVector vector to devide with
  4142. * @returns resulting new vector
  4143. */
  4144. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  4145. /**
  4146. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  4147. * @param otherVector vector to devide with
  4148. * @param result vector to store the result
  4149. * @returns the current Vector4.
  4150. */
  4151. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  4152. /**
  4153. * Divides the current Vector3 coordinates by the given ones.
  4154. * @param otherVector vector to devide with
  4155. * @returns the updated Vector3.
  4156. */
  4157. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  4158. /**
  4159. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  4160. * @param other defines the second operand
  4161. * @returns the current updated Vector4
  4162. */
  4163. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  4164. /**
  4165. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  4166. * @param other defines the second operand
  4167. * @returns the current updated Vector4
  4168. */
  4169. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  4170. /**
  4171. * Gets a new Vector4 from current Vector4 floored values
  4172. * @returns a new Vector4
  4173. */
  4174. floor(): Vector4;
  4175. /**
  4176. * Gets a new Vector4 from current Vector3 floored values
  4177. * @returns a new Vector4
  4178. */
  4179. fract(): Vector4;
  4180. /**
  4181. * Returns the Vector4 length (float).
  4182. * @returns the length
  4183. */
  4184. length(): number;
  4185. /**
  4186. * Returns the Vector4 squared length (float).
  4187. * @returns the length squared
  4188. */
  4189. lengthSquared(): number;
  4190. /**
  4191. * Normalizes in place the Vector4.
  4192. * @returns the updated Vector4.
  4193. */
  4194. normalize(): Vector4;
  4195. /**
  4196. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  4197. * @returns this converted to a new vector3
  4198. */
  4199. toVector3(): Vector3;
  4200. /**
  4201. * Returns a new Vector4 copied from the current one.
  4202. * @returns the new cloned vector
  4203. */
  4204. clone(): Vector4;
  4205. /**
  4206. * Updates the current Vector4 with the given one coordinates.
  4207. * @param source the source vector to copy from
  4208. * @returns the updated Vector4.
  4209. */
  4210. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  4211. /**
  4212. * Updates the current Vector4 coordinates with the given floats.
  4213. * @param x float to copy from
  4214. * @param y float to copy from
  4215. * @param z float to copy from
  4216. * @param w float to copy from
  4217. * @returns the updated Vector4.
  4218. */
  4219. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  4220. /**
  4221. * Updates the current Vector4 coordinates with the given floats.
  4222. * @param x float to set from
  4223. * @param y float to set from
  4224. * @param z float to set from
  4225. * @param w float to set from
  4226. * @returns the updated Vector4.
  4227. */
  4228. set(x: number, y: number, z: number, w: number): Vector4;
  4229. /**
  4230. * Copies the given float to the current Vector3 coordinates
  4231. * @param v defines the x, y, z and w coordinates of the operand
  4232. * @returns the current updated Vector3
  4233. */
  4234. setAll(v: number): Vector4;
  4235. /**
  4236. * Returns a new Vector4 set from the starting index of the given array.
  4237. * @param array the array to pull values from
  4238. * @param offset the offset into the array to start at
  4239. * @returns the new vector
  4240. */
  4241. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  4242. /**
  4243. * Updates the given vector "result" from the starting index of the given array.
  4244. * @param array the array to pull values from
  4245. * @param offset the offset into the array to start at
  4246. * @param result the vector to store the result in
  4247. */
  4248. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  4249. /**
  4250. * Updates the given vector "result" from the starting index of the given Float32Array.
  4251. * @param array the array to pull values from
  4252. * @param offset the offset into the array to start at
  4253. * @param result the vector to store the result in
  4254. */
  4255. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  4256. /**
  4257. * Updates the given vector "result" coordinates from the given floats.
  4258. * @param x float to set from
  4259. * @param y float to set from
  4260. * @param z float to set from
  4261. * @param w float to set from
  4262. * @param result the vector to the floats in
  4263. */
  4264. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  4265. /**
  4266. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  4267. * @returns the new vector
  4268. */
  4269. static Zero(): Vector4;
  4270. /**
  4271. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  4272. * @returns the new vector
  4273. */
  4274. static One(): Vector4;
  4275. /**
  4276. * Returns a new normalized Vector4 from the given one.
  4277. * @param vector the vector to normalize
  4278. * @returns the vector
  4279. */
  4280. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  4281. /**
  4282. * Updates the given vector "result" from the normalization of the given one.
  4283. * @param vector the vector to normalize
  4284. * @param result the vector to store the result in
  4285. */
  4286. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  4287. /**
  4288. * Returns a vector with the minimum values from the left and right vectors
  4289. * @param left left vector to minimize
  4290. * @param right right vector to minimize
  4291. * @returns a new vector with the minimum of the left and right vector values
  4292. */
  4293. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  4294. /**
  4295. * Returns a vector with the maximum values from the left and right vectors
  4296. * @param left left vector to maximize
  4297. * @param right right vector to maximize
  4298. * @returns a new vector with the maximum of the left and right vector values
  4299. */
  4300. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  4301. /**
  4302. * Returns the distance (float) between the vectors "value1" and "value2".
  4303. * @param value1 value to calulate the distance between
  4304. * @param value2 value to calulate the distance between
  4305. * @return the distance between the two vectors
  4306. */
  4307. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  4308. /**
  4309. * Returns the squared distance (float) between the vectors "value1" and "value2".
  4310. * @param value1 value to calulate the distance between
  4311. * @param value2 value to calulate the distance between
  4312. * @return the distance between the two vectors squared
  4313. */
  4314. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  4315. /**
  4316. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  4317. * @param value1 value to calulate the center between
  4318. * @param value2 value to calulate the center between
  4319. * @return the center between the two vectors
  4320. */
  4321. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  4322. /**
  4323. * Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
  4324. * @param value1 defines first vector
  4325. * @param value2 defines second vector
  4326. * @param ref defines third vector
  4327. * @returns ref
  4328. */
  4329. static CenterToRef(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>, ref: DeepImmutable<Vector4>): Vector4;
  4330. /**
  4331. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  4332. * This methods computes transformed normalized direction vectors only.
  4333. * @param vector the vector to transform
  4334. * @param transformation the transformation matrix to apply
  4335. * @returns the new vector
  4336. */
  4337. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  4338. /**
  4339. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  4340. * This methods computes transformed normalized direction vectors only.
  4341. * @param vector the vector to transform
  4342. * @param transformation the transformation matrix to apply
  4343. * @param result the vector to store the result in
  4344. */
  4345. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  4346. /**
  4347. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  4348. * This methods computes transformed normalized direction vectors only.
  4349. * @param x value to transform
  4350. * @param y value to transform
  4351. * @param z value to transform
  4352. * @param w value to transform
  4353. * @param transformation the transformation matrix to apply
  4354. * @param result the vector to store the results in
  4355. */
  4356. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  4357. /**
  4358. * Creates a new Vector4 from a Vector3
  4359. * @param source defines the source data
  4360. * @param w defines the 4th component (default is 0)
  4361. * @returns a new Vector4
  4362. */
  4363. static FromVector3(source: Vector3, w?: number): Vector4;
  4364. }
  4365. /**
  4366. * Class used to store quaternion data
  4367. * @see https://en.wikipedia.org/wiki/Quaternion
  4368. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  4369. */
  4370. export class Quaternion {
  4371. /** @hidden */
  4372. _x: number;
  4373. /** @hidden */
  4374. _y: number;
  4375. /** @hidden */
  4376. _z: number;
  4377. /** @hidden */
  4378. _w: number;
  4379. /** @hidden */
  4380. _isDirty: boolean;
  4381. /** Gets or sets the x coordinate */
  4382. get x(): number;
  4383. set x(value: number);
  4384. /** Gets or sets the y coordinate */
  4385. get y(): number;
  4386. set y(value: number);
  4387. /** Gets or sets the z coordinate */
  4388. get z(): number;
  4389. set z(value: number);
  4390. /** Gets or sets the w coordinate */
  4391. get w(): number;
  4392. set w(value: number);
  4393. /**
  4394. * Creates a new Quaternion from the given floats
  4395. * @param x defines the first component (0 by default)
  4396. * @param y defines the second component (0 by default)
  4397. * @param z defines the third component (0 by default)
  4398. * @param w defines the fourth component (1.0 by default)
  4399. */
  4400. constructor(x?: number, y?: number, z?: number, w?: number);
  4401. /**
  4402. * Gets a string representation for the current quaternion
  4403. * @returns a string with the Quaternion coordinates
  4404. */
  4405. toString(): string;
  4406. /**
  4407. * Gets the class name of the quaternion
  4408. * @returns the string "Quaternion"
  4409. */
  4410. getClassName(): string;
  4411. /**
  4412. * Gets a hash code for this quaternion
  4413. * @returns the quaternion hash code
  4414. */
  4415. getHashCode(): number;
  4416. /**
  4417. * Copy the quaternion to an array
  4418. * @returns a new array populated with 4 elements from the quaternion coordinates
  4419. */
  4420. asArray(): number[];
  4421. /**
  4422. * Check if two quaternions are equals
  4423. * @param otherQuaternion defines the second operand
  4424. * @return true if the current quaternion and the given one coordinates are strictly equals
  4425. */
  4426. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  4427. /**
  4428. * Gets a boolean if two quaternions are equals (using an epsilon value)
  4429. * @param otherQuaternion defines the other quaternion
  4430. * @param epsilon defines the minimal distance to consider equality
  4431. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  4432. */
  4433. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  4434. /**
  4435. * Clone the current quaternion
  4436. * @returns a new quaternion copied from the current one
  4437. */
  4438. clone(): Quaternion;
  4439. /**
  4440. * Copy a quaternion to the current one
  4441. * @param other defines the other quaternion
  4442. * @returns the updated current quaternion
  4443. */
  4444. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  4445. /**
  4446. * Updates the current quaternion with the given float coordinates
  4447. * @param x defines the x coordinate
  4448. * @param y defines the y coordinate
  4449. * @param z defines the z coordinate
  4450. * @param w defines the w coordinate
  4451. * @returns the updated current quaternion
  4452. */
  4453. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  4454. /**
  4455. * Updates the current quaternion from the given float coordinates
  4456. * @param x defines the x coordinate
  4457. * @param y defines the y coordinate
  4458. * @param z defines the z coordinate
  4459. * @param w defines the w coordinate
  4460. * @returns the updated current quaternion
  4461. */
  4462. set(x: number, y: number, z: number, w: number): Quaternion;
  4463. /**
  4464. * Adds two quaternions
  4465. * @param other defines the second operand
  4466. * @returns a new quaternion as the addition result of the given one and the current quaternion
  4467. */
  4468. add(other: DeepImmutable<Quaternion>): Quaternion;
  4469. /**
  4470. * Add a quaternion to the current one
  4471. * @param other defines the quaternion to add
  4472. * @returns the current quaternion
  4473. */
  4474. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  4475. /**
  4476. * Subtract two quaternions
  4477. * @param other defines the second operand
  4478. * @returns a new quaternion as the subtraction result of the given one from the current one
  4479. */
  4480. subtract(other: Quaternion): Quaternion;
  4481. /**
  4482. * Multiplies the current quaternion by a scale factor
  4483. * @param value defines the scale factor
  4484. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  4485. */
  4486. scale(value: number): Quaternion;
  4487. /**
  4488. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  4489. * @param scale defines the scale factor
  4490. * @param result defines the Quaternion object where to store the result
  4491. * @returns the unmodified current quaternion
  4492. */
  4493. scaleToRef(scale: number, result: Quaternion): Quaternion;
  4494. /**
  4495. * Multiplies in place the current quaternion by a scale factor
  4496. * @param value defines the scale factor
  4497. * @returns the current modified quaternion
  4498. */
  4499. scaleInPlace(value: number): Quaternion;
  4500. /**
  4501. * Scale the current quaternion values by a factor and add the result to a given quaternion
  4502. * @param scale defines the scale factor
  4503. * @param result defines the Quaternion object where to store the result
  4504. * @returns the unmodified current quaternion
  4505. */
  4506. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  4507. /**
  4508. * Multiplies two quaternions
  4509. * @param q1 defines the second operand
  4510. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  4511. */
  4512. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  4513. /**
  4514. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  4515. * @param q1 defines the second operand
  4516. * @param result defines the target quaternion
  4517. * @returns the current quaternion
  4518. */
  4519. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  4520. /**
  4521. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  4522. * @param q1 defines the second operand
  4523. * @returns the currentupdated quaternion
  4524. */
  4525. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  4526. /**
  4527. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  4528. * @param ref defines the target quaternion
  4529. * @returns the current quaternion
  4530. */
  4531. conjugateToRef(ref: Quaternion): Quaternion;
  4532. /**
  4533. * Conjugates in place (1-q) the current quaternion
  4534. * @returns the current updated quaternion
  4535. */
  4536. conjugateInPlace(): Quaternion;
  4537. /**
  4538. * Conjugates in place (1-q) the current quaternion
  4539. * @returns a new quaternion
  4540. */
  4541. conjugate(): Quaternion;
  4542. /**
  4543. * Gets length of current quaternion
  4544. * @returns the quaternion length (float)
  4545. */
  4546. length(): number;
  4547. /**
  4548. * Normalize in place the current quaternion
  4549. * @returns the current updated quaternion
  4550. */
  4551. normalize(): Quaternion;
  4552. /**
  4553. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  4554. * @param order is a reserved parameter and is ignored for now
  4555. * @returns a new Vector3 containing the Euler angles
  4556. */
  4557. toEulerAngles(order?: string): Vector3;
  4558. /**
  4559. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  4560. * @param result defines the vector which will be filled with the Euler angles
  4561. * @returns the current unchanged quaternion
  4562. */
  4563. toEulerAnglesToRef(result: Vector3): Quaternion;
  4564. /**
  4565. * Updates the given rotation matrix with the current quaternion values
  4566. * @param result defines the target matrix
  4567. * @returns the current unchanged quaternion
  4568. */
  4569. toRotationMatrix(result: Matrix): Quaternion;
  4570. /**
  4571. * Updates the current quaternion from the given rotation matrix values
  4572. * @param matrix defines the source matrix
  4573. * @returns the current updated quaternion
  4574. */
  4575. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  4576. /**
  4577. * Creates a new quaternion from a rotation matrix
  4578. * @param matrix defines the source matrix
  4579. * @returns a new quaternion created from the given rotation matrix values
  4580. */
  4581. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  4582. /**
  4583. * Updates the given quaternion with the given rotation matrix values
  4584. * @param matrix defines the source matrix
  4585. * @param result defines the target quaternion
  4586. */
  4587. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  4588. /**
  4589. * Returns the dot product (float) between the quaternions "left" and "right"
  4590. * @param left defines the left operand
  4591. * @param right defines the right operand
  4592. * @returns the dot product
  4593. */
  4594. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  4595. /**
  4596. * Checks if the two quaternions are close to each other
  4597. * @param quat0 defines the first quaternion to check
  4598. * @param quat1 defines the second quaternion to check
  4599. * @returns true if the two quaternions are close to each other
  4600. */
  4601. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  4602. /**
  4603. * Creates an empty quaternion
  4604. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  4605. */
  4606. static Zero(): Quaternion;
  4607. /**
  4608. * Inverse a given quaternion
  4609. * @param q defines the source quaternion
  4610. * @returns a new quaternion as the inverted current quaternion
  4611. */
  4612. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  4613. /**
  4614. * Inverse a given quaternion
  4615. * @param q defines the source quaternion
  4616. * @param result the quaternion the result will be stored in
  4617. * @returns the result quaternion
  4618. */
  4619. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  4620. /**
  4621. * Creates an identity quaternion
  4622. * @returns the identity quaternion
  4623. */
  4624. static Identity(): Quaternion;
  4625. /**
  4626. * Gets a boolean indicating if the given quaternion is identity
  4627. * @param quaternion defines the quaternion to check
  4628. * @returns true if the quaternion is identity
  4629. */
  4630. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  4631. /**
  4632. * Creates a quaternion from a rotation around an axis
  4633. * @param axis defines the axis to use
  4634. * @param angle defines the angle to use
  4635. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  4636. */
  4637. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  4638. /**
  4639. * Creates a rotation around an axis and stores it into the given quaternion
  4640. * @param axis defines the axis to use
  4641. * @param angle defines the angle to use
  4642. * @param result defines the target quaternion
  4643. * @returns the target quaternion
  4644. */
  4645. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  4646. /**
  4647. * Creates a new quaternion from data stored into an array
  4648. * @param array defines the data source
  4649. * @param offset defines the offset in the source array where the data starts
  4650. * @returns a new quaternion
  4651. */
  4652. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  4653. /**
  4654. * Updates the given quaternion "result" from the starting index of the given array.
  4655. * @param array the array to pull values from
  4656. * @param offset the offset into the array to start at
  4657. * @param result the quaternion to store the result in
  4658. */
  4659. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  4660. /**
  4661. * Create a quaternion from Euler rotation angles
  4662. * @param x Pitch
  4663. * @param y Yaw
  4664. * @param z Roll
  4665. * @returns the new Quaternion
  4666. */
  4667. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  4668. /**
  4669. * Updates a quaternion from Euler rotation angles
  4670. * @param x Pitch
  4671. * @param y Yaw
  4672. * @param z Roll
  4673. * @param result the quaternion to store the result
  4674. * @returns the updated quaternion
  4675. */
  4676. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  4677. /**
  4678. * Create a quaternion from Euler rotation vector
  4679. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4680. * @returns the new Quaternion
  4681. */
  4682. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  4683. /**
  4684. * Updates a quaternion from Euler rotation vector
  4685. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4686. * @param result the quaternion to store the result
  4687. * @returns the updated quaternion
  4688. */
  4689. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4690. /**
  4691. * Updates a quaternion so that it rotates vector vecFrom to vector vecTo
  4692. * @param vecFrom defines the direction vector from which to rotate
  4693. * @param vecTo defines the direction vector to which to rotate
  4694. * @param result the quaternion to store the result
  4695. * @returns the updated quaternion
  4696. */
  4697. static FromUnitVectorsToRef(vecFrom: DeepImmutable<Vector3>, vecTo: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4698. /**
  4699. * Creates a new quaternion from the given Euler float angles (y, x, z)
  4700. * @param yaw defines the rotation around Y axis
  4701. * @param pitch defines the rotation around X axis
  4702. * @param roll defines the rotation around Z axis
  4703. * @returns the new quaternion
  4704. */
  4705. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  4706. /**
  4707. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  4708. * @param yaw defines the rotation around Y axis
  4709. * @param pitch defines the rotation around X axis
  4710. * @param roll defines the rotation around Z axis
  4711. * @param result defines the target quaternion
  4712. */
  4713. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  4714. /**
  4715. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  4716. * @param alpha defines the rotation around first axis
  4717. * @param beta defines the rotation around second axis
  4718. * @param gamma defines the rotation around third axis
  4719. * @returns the new quaternion
  4720. */
  4721. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  4722. /**
  4723. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  4724. * @param alpha defines the rotation around first axis
  4725. * @param beta defines the rotation around second axis
  4726. * @param gamma defines the rotation around third axis
  4727. * @param result defines the target quaternion
  4728. */
  4729. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4730. /**
  4731. * 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)
  4732. * @param axis1 defines the first axis
  4733. * @param axis2 defines the second axis
  4734. * @param axis3 defines the third axis
  4735. * @returns the new quaternion
  4736. */
  4737. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4738. /**
  4739. * 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
  4740. * @param axis1 defines the first axis
  4741. * @param axis2 defines the second axis
  4742. * @param axis3 defines the third axis
  4743. * @param ref defines the target quaternion
  4744. */
  4745. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4746. /**
  4747. * Interpolates between two quaternions
  4748. * @param left defines first quaternion
  4749. * @param right defines second quaternion
  4750. * @param amount defines the gradient to use
  4751. * @returns the new interpolated quaternion
  4752. */
  4753. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4754. /**
  4755. * Interpolates between two quaternions and stores it into a target quaternion
  4756. * @param left defines first quaternion
  4757. * @param right defines second quaternion
  4758. * @param amount defines the gradient to use
  4759. * @param result defines the target quaternion
  4760. */
  4761. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4762. /**
  4763. * Interpolate between two quaternions using Hermite interpolation
  4764. * @param value1 defines first quaternion
  4765. * @param tangent1 defines the incoming tangent
  4766. * @param value2 defines second quaternion
  4767. * @param tangent2 defines the outgoing tangent
  4768. * @param amount defines the target quaternion
  4769. * @returns the new interpolated quaternion
  4770. */
  4771. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4772. }
  4773. /**
  4774. * Class used to store matrix data (4x4)
  4775. */
  4776. export class Matrix {
  4777. /**
  4778. * Gets the precision of matrix computations
  4779. */
  4780. static get Use64Bits(): boolean;
  4781. private static _updateFlagSeed;
  4782. private static _identityReadOnly;
  4783. private _isIdentity;
  4784. private _isIdentityDirty;
  4785. private _isIdentity3x2;
  4786. private _isIdentity3x2Dirty;
  4787. /**
  4788. * Gets the update flag of the matrix which is an unique number for the matrix.
  4789. * It will be incremented every time the matrix data change.
  4790. * You can use it to speed the comparison between two versions of the same matrix.
  4791. */
  4792. updateFlag: number;
  4793. private readonly _m;
  4794. /**
  4795. * Gets the internal data of the matrix
  4796. */
  4797. get m(): DeepImmutable<Float32Array | Array<number>>;
  4798. /** @hidden */
  4799. _markAsUpdated(): void;
  4800. /** @hidden */
  4801. private _updateIdentityStatus;
  4802. /**
  4803. * Creates an empty matrix (filled with zeros)
  4804. */
  4805. constructor();
  4806. /**
  4807. * Check if the current matrix is identity
  4808. * @returns true is the matrix is the identity matrix
  4809. */
  4810. isIdentity(): boolean;
  4811. /**
  4812. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4813. * @returns true is the matrix is the identity matrix
  4814. */
  4815. isIdentityAs3x2(): boolean;
  4816. /**
  4817. * Gets the determinant of the matrix
  4818. * @returns the matrix determinant
  4819. */
  4820. determinant(): number;
  4821. /**
  4822. * Returns the matrix as a Float32Array or Array<number>
  4823. * @returns the matrix underlying array
  4824. */
  4825. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4826. /**
  4827. * Returns the matrix as a Float32Array or Array<number>
  4828. * @returns the matrix underlying array.
  4829. */
  4830. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4831. /**
  4832. * Inverts the current matrix in place
  4833. * @returns the current inverted matrix
  4834. */
  4835. invert(): Matrix;
  4836. /**
  4837. * Sets all the matrix elements to zero
  4838. * @returns the current matrix
  4839. */
  4840. reset(): Matrix;
  4841. /**
  4842. * Adds the current matrix with a second one
  4843. * @param other defines the matrix to add
  4844. * @returns a new matrix as the addition of the current matrix and the given one
  4845. */
  4846. add(other: DeepImmutable<Matrix>): Matrix;
  4847. /**
  4848. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4849. * @param other defines the matrix to add
  4850. * @param result defines the target matrix
  4851. * @returns the current matrix
  4852. */
  4853. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4854. /**
  4855. * Adds in place the given matrix to the current matrix
  4856. * @param other defines the second operand
  4857. * @returns the current updated matrix
  4858. */
  4859. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4860. /**
  4861. * Sets the given matrix to the current inverted Matrix
  4862. * @param other defines the target matrix
  4863. * @returns the unmodified current matrix
  4864. */
  4865. invertToRef(other: Matrix): Matrix;
  4866. /**
  4867. * add a value at the specified position in the current Matrix
  4868. * @param index the index of the value within the matrix. between 0 and 15.
  4869. * @param value the value to be added
  4870. * @returns the current updated matrix
  4871. */
  4872. addAtIndex(index: number, value: number): Matrix;
  4873. /**
  4874. * mutiply the specified position in the current Matrix by a value
  4875. * @param index the index of the value within the matrix. between 0 and 15.
  4876. * @param value the value to be added
  4877. * @returns the current updated matrix
  4878. */
  4879. multiplyAtIndex(index: number, value: number): Matrix;
  4880. /**
  4881. * Inserts the translation vector (using 3 floats) in the current matrix
  4882. * @param x defines the 1st component of the translation
  4883. * @param y defines the 2nd component of the translation
  4884. * @param z defines the 3rd component of the translation
  4885. * @returns the current updated matrix
  4886. */
  4887. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4888. /**
  4889. * Adds the translation vector (using 3 floats) in the current matrix
  4890. * @param x defines the 1st component of the translation
  4891. * @param y defines the 2nd component of the translation
  4892. * @param z defines the 3rd component of the translation
  4893. * @returns the current updated matrix
  4894. */
  4895. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4896. /**
  4897. * Inserts the translation vector in the current matrix
  4898. * @param vector3 defines the translation to insert
  4899. * @returns the current updated matrix
  4900. */
  4901. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4902. /**
  4903. * Gets the translation value of the current matrix
  4904. * @returns a new Vector3 as the extracted translation from the matrix
  4905. */
  4906. getTranslation(): Vector3;
  4907. /**
  4908. * Fill a Vector3 with the extracted translation from the matrix
  4909. * @param result defines the Vector3 where to store the translation
  4910. * @returns the current matrix
  4911. */
  4912. getTranslationToRef(result: Vector3): Matrix;
  4913. /**
  4914. * Remove rotation and scaling part from the matrix
  4915. * @returns the updated matrix
  4916. */
  4917. removeRotationAndScaling(): Matrix;
  4918. /**
  4919. * Multiply two matrices
  4920. * @param other defines the second operand
  4921. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4922. */
  4923. multiply(other: DeepImmutable<Matrix>): Matrix;
  4924. /**
  4925. * Copy the current matrix from the given one
  4926. * @param other defines the source matrix
  4927. * @returns the current updated matrix
  4928. */
  4929. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4930. /**
  4931. * Populates the given array from the starting index with the current matrix values
  4932. * @param array defines the target array
  4933. * @param offset defines the offset in the target array where to start storing values
  4934. * @returns the current matrix
  4935. */
  4936. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4937. /**
  4938. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4939. * @param other defines the second operand
  4940. * @param result defines the matrix where to store the multiplication
  4941. * @returns the current matrix
  4942. */
  4943. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4944. /**
  4945. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4946. * @param other defines the second operand
  4947. * @param result defines the array where to store the multiplication
  4948. * @param offset defines the offset in the target array where to start storing values
  4949. * @returns the current matrix
  4950. */
  4951. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4952. /**
  4953. * Check equality between this matrix and a second one
  4954. * @param value defines the second matrix to compare
  4955. * @returns true is the current matrix and the given one values are strictly equal
  4956. */
  4957. equals(value: DeepImmutable<Matrix>): boolean;
  4958. /**
  4959. * Clone the current matrix
  4960. * @returns a new matrix from the current matrix
  4961. */
  4962. clone(): Matrix;
  4963. /**
  4964. * Returns the name of the current matrix class
  4965. * @returns the string "Matrix"
  4966. */
  4967. getClassName(): string;
  4968. /**
  4969. * Gets the hash code of the current matrix
  4970. * @returns the hash code
  4971. */
  4972. getHashCode(): number;
  4973. /**
  4974. * Decomposes the current Matrix into a translation, rotation and scaling components
  4975. * @param scale defines the scale vector3 given as a reference to update
  4976. * @param rotation defines the rotation quaternion given as a reference to update
  4977. * @param translation defines the translation vector3 given as a reference to update
  4978. * @returns true if operation was successful
  4979. */
  4980. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4981. /**
  4982. * Gets specific row of the matrix
  4983. * @param index defines the number of the row to get
  4984. * @returns the index-th row of the current matrix as a new Vector4
  4985. */
  4986. getRow(index: number): Nullable<Vector4>;
  4987. /**
  4988. * Sets the index-th row of the current matrix to the vector4 values
  4989. * @param index defines the number of the row to set
  4990. * @param row defines the target vector4
  4991. * @returns the updated current matrix
  4992. */
  4993. setRow(index: number, row: Vector4): Matrix;
  4994. /**
  4995. * Compute the transpose of the matrix
  4996. * @returns the new transposed matrix
  4997. */
  4998. transpose(): Matrix;
  4999. /**
  5000. * Compute the transpose of the matrix and store it in a given matrix
  5001. * @param result defines the target matrix
  5002. * @returns the current matrix
  5003. */
  5004. transposeToRef(result: Matrix): Matrix;
  5005. /**
  5006. * Sets the index-th row of the current matrix with the given 4 x float values
  5007. * @param index defines the row index
  5008. * @param x defines the x component to set
  5009. * @param y defines the y component to set
  5010. * @param z defines the z component to set
  5011. * @param w defines the w component to set
  5012. * @returns the updated current matrix
  5013. */
  5014. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  5015. /**
  5016. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  5017. * @param scale defines the scale factor
  5018. * @returns a new matrix
  5019. */
  5020. scale(scale: number): Matrix;
  5021. /**
  5022. * Scale the current matrix values by a factor to a given result matrix
  5023. * @param scale defines the scale factor
  5024. * @param result defines the matrix to store the result
  5025. * @returns the current matrix
  5026. */
  5027. scaleToRef(scale: number, result: Matrix): Matrix;
  5028. /**
  5029. * Scale the current matrix values by a factor and add the result to a given matrix
  5030. * @param scale defines the scale factor
  5031. * @param result defines the Matrix to store the result
  5032. * @returns the current matrix
  5033. */
  5034. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  5035. /**
  5036. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  5037. * @param ref matrix to store the result
  5038. */
  5039. toNormalMatrix(ref: Matrix): void;
  5040. /**
  5041. * Gets only rotation part of the current matrix
  5042. * @returns a new matrix sets to the extracted rotation matrix from the current one
  5043. */
  5044. getRotationMatrix(): Matrix;
  5045. /**
  5046. * Extracts the rotation matrix from the current one and sets it as the given "result"
  5047. * @param result defines the target matrix to store data to
  5048. * @returns the current matrix
  5049. */
  5050. getRotationMatrixToRef(result: Matrix): Matrix;
  5051. /**
  5052. * Toggles model matrix from being right handed to left handed in place and vice versa
  5053. */
  5054. toggleModelMatrixHandInPlace(): void;
  5055. /**
  5056. * Toggles projection matrix from being right handed to left handed in place and vice versa
  5057. */
  5058. toggleProjectionMatrixHandInPlace(): void;
  5059. /**
  5060. * Creates a matrix from an array
  5061. * @param array defines the source array
  5062. * @param offset defines an offset in the source array
  5063. * @returns a new Matrix set from the starting index of the given array
  5064. */
  5065. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  5066. /**
  5067. * Copy the content of an array into a given matrix
  5068. * @param array defines the source array
  5069. * @param offset defines an offset in the source array
  5070. * @param result defines the target matrix
  5071. */
  5072. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  5073. /**
  5074. * Stores an array into a matrix after having multiplied each component by a given factor
  5075. * @param array defines the source array
  5076. * @param offset defines the offset in the source array
  5077. * @param scale defines the scaling factor
  5078. * @param result defines the target matrix
  5079. */
  5080. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  5081. /**
  5082. * Gets an identity matrix that must not be updated
  5083. */
  5084. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  5085. /**
  5086. * Stores a list of values (16) inside a given matrix
  5087. * @param initialM11 defines 1st value of 1st row
  5088. * @param initialM12 defines 2nd value of 1st row
  5089. * @param initialM13 defines 3rd value of 1st row
  5090. * @param initialM14 defines 4th value of 1st row
  5091. * @param initialM21 defines 1st value of 2nd row
  5092. * @param initialM22 defines 2nd value of 2nd row
  5093. * @param initialM23 defines 3rd value of 2nd row
  5094. * @param initialM24 defines 4th value of 2nd row
  5095. * @param initialM31 defines 1st value of 3rd row
  5096. * @param initialM32 defines 2nd value of 3rd row
  5097. * @param initialM33 defines 3rd value of 3rd row
  5098. * @param initialM34 defines 4th value of 3rd row
  5099. * @param initialM41 defines 1st value of 4th row
  5100. * @param initialM42 defines 2nd value of 4th row
  5101. * @param initialM43 defines 3rd value of 4th row
  5102. * @param initialM44 defines 4th value of 4th row
  5103. * @param result defines the target matrix
  5104. */
  5105. 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;
  5106. /**
  5107. * Creates new matrix from a list of values (16)
  5108. * @param initialM11 defines 1st value of 1st row
  5109. * @param initialM12 defines 2nd value of 1st row
  5110. * @param initialM13 defines 3rd value of 1st row
  5111. * @param initialM14 defines 4th value of 1st row
  5112. * @param initialM21 defines 1st value of 2nd row
  5113. * @param initialM22 defines 2nd value of 2nd row
  5114. * @param initialM23 defines 3rd value of 2nd row
  5115. * @param initialM24 defines 4th value of 2nd row
  5116. * @param initialM31 defines 1st value of 3rd row
  5117. * @param initialM32 defines 2nd value of 3rd row
  5118. * @param initialM33 defines 3rd value of 3rd row
  5119. * @param initialM34 defines 4th value of 3rd row
  5120. * @param initialM41 defines 1st value of 4th row
  5121. * @param initialM42 defines 2nd value of 4th row
  5122. * @param initialM43 defines 3rd value of 4th row
  5123. * @param initialM44 defines 4th value of 4th row
  5124. * @returns the new matrix
  5125. */
  5126. 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;
  5127. /**
  5128. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  5129. * @param scale defines the scale vector3
  5130. * @param rotation defines the rotation quaternion
  5131. * @param translation defines the translation vector3
  5132. * @returns a new matrix
  5133. */
  5134. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  5135. /**
  5136. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  5137. * @param scale defines the scale vector3
  5138. * @param rotation defines the rotation quaternion
  5139. * @param translation defines the translation vector3
  5140. * @param result defines the target matrix
  5141. */
  5142. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  5143. /**
  5144. * Creates a new identity matrix
  5145. * @returns a new identity matrix
  5146. */
  5147. static Identity(): Matrix;
  5148. /**
  5149. * Creates a new identity matrix and stores the result in a given matrix
  5150. * @param result defines the target matrix
  5151. */
  5152. static IdentityToRef(result: Matrix): void;
  5153. /**
  5154. * Creates a new zero matrix
  5155. * @returns a new zero matrix
  5156. */
  5157. static Zero(): Matrix;
  5158. /**
  5159. * Creates a new rotation matrix for "angle" radians around the X axis
  5160. * @param angle defines the angle (in radians) to use
  5161. * @return the new matrix
  5162. */
  5163. static RotationX(angle: number): Matrix;
  5164. /**
  5165. * Creates a new matrix as the invert of a given matrix
  5166. * @param source defines the source matrix
  5167. * @returns the new matrix
  5168. */
  5169. static Invert(source: DeepImmutable<Matrix>): Matrix;
  5170. /**
  5171. * Creates a new rotation matrix for "angle" radians around the X 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 RotationXToRef(angle: number, result: Matrix): void;
  5176. /**
  5177. * Creates a new rotation matrix for "angle" radians around the Y axis
  5178. * @param angle defines the angle (in radians) to use
  5179. * @return the new matrix
  5180. */
  5181. static RotationY(angle: number): Matrix;
  5182. /**
  5183. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  5184. * @param angle defines the angle (in radians) to use
  5185. * @param result defines the target matrix
  5186. */
  5187. static RotationYToRef(angle: number, result: Matrix): void;
  5188. /**
  5189. * Creates a new rotation matrix for "angle" radians around the Z axis
  5190. * @param angle defines the angle (in radians) to use
  5191. * @return the new matrix
  5192. */
  5193. static RotationZ(angle: number): Matrix;
  5194. /**
  5195. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  5196. * @param angle defines the angle (in radians) to use
  5197. * @param result defines the target matrix
  5198. */
  5199. static RotationZToRef(angle: number, result: Matrix): void;
  5200. /**
  5201. * Creates a new rotation matrix for "angle" radians around the given axis
  5202. * @param axis defines the axis to use
  5203. * @param angle defines the angle (in radians) to use
  5204. * @return the new matrix
  5205. */
  5206. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  5207. /**
  5208. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  5209. * @param axis defines the axis to use
  5210. * @param angle defines the angle (in radians) to use
  5211. * @param result defines the target matrix
  5212. */
  5213. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  5214. /**
  5215. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  5216. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  5217. * @param from defines the vector to align
  5218. * @param to defines the vector to align to
  5219. * @param result defines the target matrix
  5220. */
  5221. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  5222. /**
  5223. * Creates a rotation matrix
  5224. * @param yaw defines the yaw angle in radians (Y axis)
  5225. * @param pitch defines the pitch angle in radians (X axis)
  5226. * @param roll defines the roll angle in radians (Z axis)
  5227. * @returns the new rotation matrix
  5228. */
  5229. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  5230. /**
  5231. * Creates a rotation matrix and stores it in a given matrix
  5232. * @param yaw defines the yaw angle in radians (Y axis)
  5233. * @param pitch defines the pitch angle in radians (X axis)
  5234. * @param roll defines the roll angle in radians (Z axis)
  5235. * @param result defines the target matrix
  5236. */
  5237. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  5238. /**
  5239. * Creates a scaling matrix
  5240. * @param x defines the scale factor on X axis
  5241. * @param y defines the scale factor on Y axis
  5242. * @param z defines the scale factor on Z axis
  5243. * @returns the new matrix
  5244. */
  5245. static Scaling(x: number, y: number, z: number): Matrix;
  5246. /**
  5247. * Creates a scaling matrix and stores it in a given matrix
  5248. * @param x defines the scale factor on X axis
  5249. * @param y defines the scale factor on Y axis
  5250. * @param z defines the scale factor on Z axis
  5251. * @param result defines the target matrix
  5252. */
  5253. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  5254. /**
  5255. * Creates a translation matrix
  5256. * @param x defines the translation on X axis
  5257. * @param y defines the translation on Y axis
  5258. * @param z defines the translationon Z axis
  5259. * @returns the new matrix
  5260. */
  5261. static Translation(x: number, y: number, z: number): Matrix;
  5262. /**
  5263. * Creates a translation matrix and stores it in a given matrix
  5264. * @param x defines the translation on X axis
  5265. * @param y defines the translation on Y axis
  5266. * @param z defines the translationon Z axis
  5267. * @param result defines the target matrix
  5268. */
  5269. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  5270. /**
  5271. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  5272. * @param startValue defines the start value
  5273. * @param endValue defines the end value
  5274. * @param gradient defines the gradient factor
  5275. * @returns the new matrix
  5276. */
  5277. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  5278. /**
  5279. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  5280. * @param startValue defines the start value
  5281. * @param endValue defines the end value
  5282. * @param gradient defines the gradient factor
  5283. * @param result defines the Matrix object where to store data
  5284. */
  5285. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  5286. /**
  5287. * Builds a new matrix whose values are computed by:
  5288. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  5289. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  5290. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  5291. * @param startValue defines the first matrix
  5292. * @param endValue defines the second matrix
  5293. * @param gradient defines the gradient between the two matrices
  5294. * @returns the new matrix
  5295. */
  5296. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  5297. /**
  5298. * Update a matrix to values which are computed by:
  5299. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  5300. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  5301. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  5302. * @param startValue defines the first matrix
  5303. * @param endValue defines the second matrix
  5304. * @param gradient defines the gradient between the two matrices
  5305. * @param result defines the target matrix
  5306. */
  5307. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  5308. /**
  5309. * 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"
  5310. * This function works in left handed mode
  5311. * @param eye defines the final position of the entity
  5312. * @param target defines where the entity should look at
  5313. * @param up defines the up vector for the entity
  5314. * @returns the new matrix
  5315. */
  5316. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  5317. /**
  5318. * 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".
  5319. * This function works in left handed mode
  5320. * @param eye defines the final position of the entity
  5321. * @param target defines where the entity should look at
  5322. * @param up defines the up vector for the entity
  5323. * @param result defines the target matrix
  5324. */
  5325. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  5326. /**
  5327. * 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"
  5328. * This function works in right handed mode
  5329. * @param eye defines the final position of the entity
  5330. * @param target defines where the entity should look at
  5331. * @param up defines the up vector for the entity
  5332. * @returns the new matrix
  5333. */
  5334. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  5335. /**
  5336. * 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".
  5337. * This function works in right handed mode
  5338. * @param eye defines the final position of the entity
  5339. * @param target defines where the entity should look at
  5340. * @param up defines the up vector for the entity
  5341. * @param result defines the target matrix
  5342. */
  5343. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  5344. /**
  5345. * Create a left-handed orthographic projection matrix
  5346. * @param width defines the viewport width
  5347. * @param height defines the viewport height
  5348. * @param znear defines the near clip plane
  5349. * @param zfar defines the far clip plane
  5350. * @returns a new matrix as a left-handed orthographic projection matrix
  5351. */
  5352. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  5353. /**
  5354. * Store a left-handed orthographic projection to a given matrix
  5355. * @param width defines the viewport width
  5356. * @param height defines the viewport height
  5357. * @param znear defines the near clip plane
  5358. * @param zfar defines the far clip plane
  5359. * @param result defines the target matrix
  5360. */
  5361. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  5362. /**
  5363. * Create a left-handed orthographic projection matrix
  5364. * @param left defines the viewport left coordinate
  5365. * @param right defines the viewport right coordinate
  5366. * @param bottom defines the viewport bottom coordinate
  5367. * @param top defines the viewport top coordinate
  5368. * @param znear defines the near clip plane
  5369. * @param zfar defines the far clip plane
  5370. * @returns a new matrix as a left-handed orthographic projection matrix
  5371. */
  5372. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  5373. /**
  5374. * Stores a left-handed orthographic projection into a given matrix
  5375. * @param left defines the viewport left coordinate
  5376. * @param right defines the viewport right coordinate
  5377. * @param bottom defines the viewport bottom coordinate
  5378. * @param top defines the viewport top coordinate
  5379. * @param znear defines the near clip plane
  5380. * @param zfar defines the far clip plane
  5381. * @param result defines the target matrix
  5382. */
  5383. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  5384. /**
  5385. * Creates a right-handed orthographic projection matrix
  5386. * @param left defines the viewport left coordinate
  5387. * @param right defines the viewport right coordinate
  5388. * @param bottom defines the viewport bottom coordinate
  5389. * @param top defines the viewport top coordinate
  5390. * @param znear defines the near clip plane
  5391. * @param zfar defines the far clip plane
  5392. * @returns a new matrix as a right-handed orthographic projection matrix
  5393. */
  5394. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  5395. /**
  5396. * Stores a right-handed orthographic projection into a given matrix
  5397. * @param left defines the viewport left coordinate
  5398. * @param right defines the viewport right coordinate
  5399. * @param bottom defines the viewport bottom coordinate
  5400. * @param top defines the viewport top coordinate
  5401. * @param znear defines the near clip plane
  5402. * @param zfar defines the far clip plane
  5403. * @param result defines the target matrix
  5404. */
  5405. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  5406. /**
  5407. * Creates a left-handed perspective projection matrix
  5408. * @param width defines the viewport width
  5409. * @param height defines the viewport height
  5410. * @param znear defines the near clip plane
  5411. * @param zfar defines the far clip plane
  5412. * @returns a new matrix as a left-handed perspective projection matrix
  5413. */
  5414. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  5415. /**
  5416. * Creates a left-handed perspective projection matrix
  5417. * @param fov defines the horizontal field of view
  5418. * @param aspect defines the aspect ratio
  5419. * @param znear defines the near clip plane
  5420. * @param zfar defines the far clip plane
  5421. * @returns a new matrix as a left-handed perspective projection matrix
  5422. */
  5423. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  5424. /**
  5425. * Stores a left-handed perspective projection into a given matrix
  5426. * @param fov defines the horizontal field of view
  5427. * @param aspect defines the aspect ratio
  5428. * @param znear defines the near clip plane
  5429. * @param zfar defines the far clip plane
  5430. * @param result defines the target matrix
  5431. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5432. */
  5433. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5434. /**
  5435. * Stores a left-handed perspective projection into a given matrix with depth reversed
  5436. * @param fov defines the horizontal field of view
  5437. * @param aspect defines the aspect ratio
  5438. * @param znear defines the near clip plane
  5439. * @param zfar not used as infinity is used as far clip
  5440. * @param result defines the target matrix
  5441. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5442. */
  5443. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5444. /**
  5445. * Creates a right-handed perspective projection matrix
  5446. * @param fov defines the horizontal field of view
  5447. * @param aspect defines the aspect ratio
  5448. * @param znear defines the near clip plane
  5449. * @param zfar defines the far clip plane
  5450. * @returns a new matrix as a right-handed perspective projection matrix
  5451. */
  5452. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  5453. /**
  5454. * Stores a right-handed perspective projection into a given matrix
  5455. * @param fov defines the horizontal field of view
  5456. * @param aspect defines the aspect ratio
  5457. * @param znear defines the near clip plane
  5458. * @param zfar defines the far clip plane
  5459. * @param result defines the target matrix
  5460. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5461. */
  5462. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5463. /**
  5464. * Stores a right-handed perspective projection into a given matrix
  5465. * @param fov defines the horizontal field of view
  5466. * @param aspect defines the aspect ratio
  5467. * @param znear defines the near clip plane
  5468. * @param zfar not used as infinity is used as far clip
  5469. * @param result defines the target matrix
  5470. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5471. */
  5472. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5473. /**
  5474. * Stores a perspective projection for WebVR info a given matrix
  5475. * @param fov defines the field of view
  5476. * @param znear defines the near clip plane
  5477. * @param zfar defines the far clip plane
  5478. * @param result defines the target matrix
  5479. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  5480. */
  5481. static PerspectiveFovWebVRToRef(fov: {
  5482. upDegrees: number;
  5483. downDegrees: number;
  5484. leftDegrees: number;
  5485. rightDegrees: number;
  5486. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  5487. /**
  5488. * Computes a complete transformation matrix
  5489. * @param viewport defines the viewport to use
  5490. * @param world defines the world matrix
  5491. * @param view defines the view matrix
  5492. * @param projection defines the projection matrix
  5493. * @param zmin defines the near clip plane
  5494. * @param zmax defines the far clip plane
  5495. * @returns the transformation matrix
  5496. */
  5497. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  5498. /**
  5499. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  5500. * @param matrix defines the matrix to use
  5501. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  5502. */
  5503. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  5504. /**
  5505. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  5506. * @param matrix defines the matrix to use
  5507. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  5508. */
  5509. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  5510. /**
  5511. * Compute the transpose of a given matrix
  5512. * @param matrix defines the matrix to transpose
  5513. * @returns the new matrix
  5514. */
  5515. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  5516. /**
  5517. * Compute the transpose of a matrix and store it in a target matrix
  5518. * @param matrix defines the matrix to transpose
  5519. * @param result defines the target matrix
  5520. */
  5521. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  5522. /**
  5523. * Computes a reflection matrix from a plane
  5524. * @param plane defines the reflection plane
  5525. * @returns a new matrix
  5526. */
  5527. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  5528. /**
  5529. * Computes a reflection matrix from a plane
  5530. * @param plane defines the reflection plane
  5531. * @param result defines the target matrix
  5532. */
  5533. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  5534. /**
  5535. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  5536. * @param xaxis defines the value of the 1st axis
  5537. * @param yaxis defines the value of the 2nd axis
  5538. * @param zaxis defines the value of the 3rd axis
  5539. * @param result defines the target matrix
  5540. */
  5541. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  5542. /**
  5543. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  5544. * @param quat defines the quaternion to use
  5545. * @param result defines the target matrix
  5546. */
  5547. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  5548. }
  5549. /**
  5550. * @hidden
  5551. */
  5552. export class TmpVectors {
  5553. static Vector2: Vector2[];
  5554. static Vector3: Vector3[];
  5555. static Vector4: Vector4[];
  5556. static Quaternion: Quaternion[];
  5557. static Matrix: Matrix[];
  5558. }
  5559. }
  5560. declare module BABYLON {
  5561. /**
  5562. * Defines potential orientation for back face culling
  5563. */
  5564. export enum Orientation {
  5565. /**
  5566. * Clockwise
  5567. */
  5568. CW = 0,
  5569. /** Counter clockwise */
  5570. CCW = 1
  5571. }
  5572. /** Class used to represent a Bezier curve */
  5573. export class BezierCurve {
  5574. /**
  5575. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5576. * @param t defines the time
  5577. * @param x1 defines the left coordinate on X axis
  5578. * @param y1 defines the left coordinate on Y axis
  5579. * @param x2 defines the right coordinate on X axis
  5580. * @param y2 defines the right coordinate on Y axis
  5581. * @returns the interpolated value
  5582. */
  5583. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5584. }
  5585. /**
  5586. * Defines angle representation
  5587. */
  5588. export class Angle {
  5589. private _radians;
  5590. /**
  5591. * Creates an Angle object of "radians" radians (float).
  5592. * @param radians the angle in radians
  5593. */
  5594. constructor(radians: number);
  5595. /**
  5596. * Get value in degrees
  5597. * @returns the Angle value in degrees (float)
  5598. */
  5599. degrees(): number;
  5600. /**
  5601. * Get value in radians
  5602. * @returns the Angle value in radians (float)
  5603. */
  5604. radians(): number;
  5605. /**
  5606. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  5607. * @param a defines first point as the origin
  5608. * @param b defines point
  5609. * @returns a new Angle
  5610. */
  5611. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5612. /**
  5613. * Gets a new Angle object from the given float in radians
  5614. * @param radians defines the angle value in radians
  5615. * @returns a new Angle
  5616. */
  5617. static FromRadians(radians: number): Angle;
  5618. /**
  5619. * Gets a new Angle object from the given float in degrees
  5620. * @param degrees defines the angle value in degrees
  5621. * @returns a new Angle
  5622. */
  5623. static FromDegrees(degrees: number): Angle;
  5624. }
  5625. /**
  5626. * This represents an arc in a 2d space.
  5627. */
  5628. export class Arc2 {
  5629. /** Defines the start point of the arc */
  5630. startPoint: Vector2;
  5631. /** Defines the mid point of the arc */
  5632. midPoint: Vector2;
  5633. /** Defines the end point of the arc */
  5634. endPoint: Vector2;
  5635. /**
  5636. * Defines the center point of the arc.
  5637. */
  5638. centerPoint: Vector2;
  5639. /**
  5640. * Defines the radius of the arc.
  5641. */
  5642. radius: number;
  5643. /**
  5644. * Defines the angle of the arc (from mid point to end point).
  5645. */
  5646. angle: Angle;
  5647. /**
  5648. * Defines the start angle of the arc (from start point to middle point).
  5649. */
  5650. startAngle: Angle;
  5651. /**
  5652. * Defines the orientation of the arc (clock wise/counter clock wise).
  5653. */
  5654. orientation: Orientation;
  5655. /**
  5656. * Creates an Arc object from the three given points : start, middle and end.
  5657. * @param startPoint Defines the start point of the arc
  5658. * @param midPoint Defines the midlle point of the arc
  5659. * @param endPoint Defines the end point of the arc
  5660. */
  5661. constructor(
  5662. /** Defines the start point of the arc */
  5663. startPoint: Vector2,
  5664. /** Defines the mid point of the arc */
  5665. midPoint: Vector2,
  5666. /** Defines the end point of the arc */
  5667. endPoint: Vector2);
  5668. }
  5669. /**
  5670. * Represents a 2D path made up of multiple 2D points
  5671. */
  5672. export class Path2 {
  5673. private _points;
  5674. private _length;
  5675. /**
  5676. * If the path start and end point are the same
  5677. */
  5678. closed: boolean;
  5679. /**
  5680. * Creates a Path2 object from the starting 2D coordinates x and y.
  5681. * @param x the starting points x value
  5682. * @param y the starting points y value
  5683. */
  5684. constructor(x: number, y: number);
  5685. /**
  5686. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5687. * @param x the added points x value
  5688. * @param y the added points y value
  5689. * @returns the updated Path2.
  5690. */
  5691. addLineTo(x: number, y: number): Path2;
  5692. /**
  5693. * 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.
  5694. * @param midX middle point x value
  5695. * @param midY middle point y value
  5696. * @param endX end point x value
  5697. * @param endY end point y value
  5698. * @param numberOfSegments (default: 36)
  5699. * @returns the updated Path2.
  5700. */
  5701. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5702. /**
  5703. * Closes the Path2.
  5704. * @returns the Path2.
  5705. */
  5706. close(): Path2;
  5707. /**
  5708. * Gets the sum of the distance between each sequential point in the path
  5709. * @returns the Path2 total length (float).
  5710. */
  5711. length(): number;
  5712. /**
  5713. * Gets the points which construct the path
  5714. * @returns the Path2 internal array of points.
  5715. */
  5716. getPoints(): Vector2[];
  5717. /**
  5718. * Retreives the point at the distance aways from the starting point
  5719. * @param normalizedLengthPosition the length along the path to retreive the point from
  5720. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5721. */
  5722. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5723. /**
  5724. * Creates a new path starting from an x and y position
  5725. * @param x starting x value
  5726. * @param y starting y value
  5727. * @returns a new Path2 starting at the coordinates (x, y).
  5728. */
  5729. static StartingAt(x: number, y: number): Path2;
  5730. }
  5731. /**
  5732. * Represents a 3D path made up of multiple 3D points
  5733. */
  5734. export class Path3D {
  5735. /**
  5736. * an array of Vector3, the curve axis of the Path3D
  5737. */
  5738. path: Vector3[];
  5739. private _curve;
  5740. private _distances;
  5741. private _tangents;
  5742. private _normals;
  5743. private _binormals;
  5744. private _raw;
  5745. private _alignTangentsWithPath;
  5746. private readonly _pointAtData;
  5747. /**
  5748. * new Path3D(path, normal, raw)
  5749. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5750. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5751. * @param path an array of Vector3, the curve axis of the Path3D
  5752. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5753. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5754. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5755. */
  5756. constructor(
  5757. /**
  5758. * an array of Vector3, the curve axis of the Path3D
  5759. */
  5760. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5761. /**
  5762. * Returns the Path3D array of successive Vector3 designing its curve.
  5763. * @returns the Path3D array of successive Vector3 designing its curve.
  5764. */
  5765. getCurve(): Vector3[];
  5766. /**
  5767. * Returns the Path3D array of successive Vector3 designing its curve.
  5768. * @returns the Path3D array of successive Vector3 designing its curve.
  5769. */
  5770. getPoints(): Vector3[];
  5771. /**
  5772. * @returns the computed length (float) of the path.
  5773. */
  5774. length(): number;
  5775. /**
  5776. * Returns an array populated with tangent vectors on each Path3D curve point.
  5777. * @returns an array populated with tangent vectors on each Path3D curve point.
  5778. */
  5779. getTangents(): Vector3[];
  5780. /**
  5781. * Returns an array populated with normal vectors on each Path3D curve point.
  5782. * @returns an array populated with normal vectors on each Path3D curve point.
  5783. */
  5784. getNormals(): Vector3[];
  5785. /**
  5786. * Returns an array populated with binormal vectors on each Path3D curve point.
  5787. * @returns an array populated with binormal vectors on each Path3D curve point.
  5788. */
  5789. getBinormals(): Vector3[];
  5790. /**
  5791. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5792. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5793. */
  5794. getDistances(): number[];
  5795. /**
  5796. * Returns an interpolated point along this path
  5797. * @param position the position of the point along this path, from 0.0 to 1.0
  5798. * @returns a new Vector3 as the point
  5799. */
  5800. getPointAt(position: number): Vector3;
  5801. /**
  5802. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5803. * @param position the position of the point along this path, from 0.0 to 1.0
  5804. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5805. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5806. */
  5807. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5808. /**
  5809. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5810. * @param position the position of the point along this path, from 0.0 to 1.0
  5811. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5812. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5813. */
  5814. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5815. /**
  5816. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5817. * @param position the position of the point along this path, from 0.0 to 1.0
  5818. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5819. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5820. */
  5821. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5822. /**
  5823. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5824. * @param position the position of the point along this path, from 0.0 to 1.0
  5825. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5826. */
  5827. getDistanceAt(position: number): number;
  5828. /**
  5829. * Returns the array index of the previous point of an interpolated point along this path
  5830. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5831. * @returns the array index
  5832. */
  5833. getPreviousPointIndexAt(position: number): number;
  5834. /**
  5835. * 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)
  5836. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5837. * @returns the sub position
  5838. */
  5839. getSubPositionAt(position: number): number;
  5840. /**
  5841. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5842. * @param target the vector of which to get the closest position to
  5843. * @returns the position of the closest virtual point on this path to the target vector
  5844. */
  5845. getClosestPositionTo(target: Vector3): number;
  5846. /**
  5847. * Returns a sub path (slice) of this path
  5848. * @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
  5849. * @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
  5850. * @returns a sub path (slice) of this path
  5851. */
  5852. slice(start?: number, end?: number): Path3D;
  5853. /**
  5854. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5855. * @param path path which all values are copied into the curves points
  5856. * @param firstNormal which should be projected onto the curve
  5857. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5858. * @returns the same object updated.
  5859. */
  5860. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5861. private _compute;
  5862. private _getFirstNonNullVector;
  5863. private _getLastNonNullVector;
  5864. private _normalVector;
  5865. /**
  5866. * Updates the point at data for an interpolated point along this curve
  5867. * @param position the position of the point along this curve, from 0.0 to 1.0
  5868. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5869. * @returns the (updated) point at data
  5870. */
  5871. private _updatePointAtData;
  5872. /**
  5873. * Updates the point at data from the specified parameters
  5874. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5875. * @param point the interpolated point
  5876. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5877. */
  5878. private _setPointAtData;
  5879. /**
  5880. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5881. */
  5882. private _updateInterpolationMatrix;
  5883. }
  5884. /**
  5885. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5886. * A Curve3 is designed from a series of successive Vector3.
  5887. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5888. */
  5889. export class Curve3 {
  5890. private _points;
  5891. private _length;
  5892. /**
  5893. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5894. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5895. * @param v1 (Vector3) the control point
  5896. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5897. * @param nbPoints (integer) the wanted number of points in the curve
  5898. * @returns the created Curve3
  5899. */
  5900. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5901. /**
  5902. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5903. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5904. * @param v1 (Vector3) the first control point
  5905. * @param v2 (Vector3) the second control point
  5906. * @param v3 (Vector3) the end point of the Cubic Bezier
  5907. * @param nbPoints (integer) the wanted number of points in the curve
  5908. * @returns the created Curve3
  5909. */
  5910. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5911. /**
  5912. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5913. * @param p1 (Vector3) the origin point of the Hermite Spline
  5914. * @param t1 (Vector3) the tangent vector at the origin point
  5915. * @param p2 (Vector3) the end point of the Hermite Spline
  5916. * @param t2 (Vector3) the tangent vector at the end point
  5917. * @param nbPoints (integer) the wanted number of points in the curve
  5918. * @returns the created Curve3
  5919. */
  5920. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5921. /**
  5922. * Returns a Curve3 object along a CatmullRom Spline curve :
  5923. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5924. * @param nbPoints (integer) the wanted number of points between each curve control points
  5925. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5926. * @returns the created Curve3
  5927. */
  5928. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5929. /**
  5930. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5931. * A Curve3 is designed from a series of successive Vector3.
  5932. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5933. * @param points points which make up the curve
  5934. */
  5935. constructor(points: Vector3[]);
  5936. /**
  5937. * @returns the Curve3 stored array of successive Vector3
  5938. */
  5939. getPoints(): Vector3[];
  5940. /**
  5941. * @returns the computed length (float) of the curve.
  5942. */
  5943. length(): number;
  5944. /**
  5945. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5946. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5947. * curveA and curveB keep unchanged.
  5948. * @param curve the curve to continue from this curve
  5949. * @returns the newly constructed curve
  5950. */
  5951. continue(curve: DeepImmutable<Curve3>): Curve3;
  5952. private _computeLength;
  5953. }
  5954. }
  5955. declare module BABYLON {
  5956. /**
  5957. * This represents the main contract an easing function should follow.
  5958. * Easing functions are used throughout the animation system.
  5959. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5960. */
  5961. export interface IEasingFunction {
  5962. /**
  5963. * Given an input gradient between 0 and 1, this returns the corresponding value
  5964. * of the easing function.
  5965. * The link below provides some of the most common examples of easing functions.
  5966. * @see https://easings.net/
  5967. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5968. * @returns the corresponding value on the curve defined by the easing function
  5969. */
  5970. ease(gradient: number): number;
  5971. }
  5972. /**
  5973. * Base class used for every default easing function.
  5974. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5975. */
  5976. export class EasingFunction implements IEasingFunction {
  5977. /**
  5978. * Interpolation follows the mathematical formula associated with the easing function.
  5979. */
  5980. static readonly EASINGMODE_EASEIN: number;
  5981. /**
  5982. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5983. */
  5984. static readonly EASINGMODE_EASEOUT: number;
  5985. /**
  5986. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5987. */
  5988. static readonly EASINGMODE_EASEINOUT: number;
  5989. private _easingMode;
  5990. /**
  5991. * Sets the easing mode of the current function.
  5992. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5993. */
  5994. setEasingMode(easingMode: number): void;
  5995. /**
  5996. * Gets the current easing mode.
  5997. * @returns the easing mode
  5998. */
  5999. getEasingMode(): number;
  6000. /**
  6001. * @hidden
  6002. */
  6003. easeInCore(gradient: number): number;
  6004. /**
  6005. * Given an input gradient between 0 and 1, this returns the corresponding value
  6006. * of the easing function.
  6007. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6008. * @returns the corresponding value on the curve defined by the easing function
  6009. */
  6010. ease(gradient: number): number;
  6011. }
  6012. /**
  6013. * Easing function with a circle shape (see link below).
  6014. * @see https://easings.net/#easeInCirc
  6015. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6016. */
  6017. export class CircleEase extends EasingFunction implements IEasingFunction {
  6018. /** @hidden */
  6019. easeInCore(gradient: number): number;
  6020. }
  6021. /**
  6022. * Easing function with a ease back shape (see link below).
  6023. * @see https://easings.net/#easeInBack
  6024. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6025. */
  6026. export class BackEase extends EasingFunction implements IEasingFunction {
  6027. /** Defines the amplitude of the function */
  6028. amplitude: number;
  6029. /**
  6030. * Instantiates a back ease easing
  6031. * @see https://easings.net/#easeInBack
  6032. * @param amplitude Defines the amplitude of the function
  6033. */
  6034. constructor(
  6035. /** Defines the amplitude of the function */
  6036. amplitude?: number);
  6037. /** @hidden */
  6038. easeInCore(gradient: number): number;
  6039. }
  6040. /**
  6041. * Easing function with a bouncing shape (see link below).
  6042. * @see https://easings.net/#easeInBounce
  6043. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6044. */
  6045. export class BounceEase extends EasingFunction implements IEasingFunction {
  6046. /** Defines the number of bounces */
  6047. bounces: number;
  6048. /** Defines the amplitude of the bounce */
  6049. bounciness: number;
  6050. /**
  6051. * Instantiates a bounce easing
  6052. * @see https://easings.net/#easeInBounce
  6053. * @param bounces Defines the number of bounces
  6054. * @param bounciness Defines the amplitude of the bounce
  6055. */
  6056. constructor(
  6057. /** Defines the number of bounces */
  6058. bounces?: number,
  6059. /** Defines the amplitude of the bounce */
  6060. bounciness?: number);
  6061. /** @hidden */
  6062. easeInCore(gradient: number): number;
  6063. }
  6064. /**
  6065. * Easing function with a power of 3 shape (see link below).
  6066. * @see https://easings.net/#easeInCubic
  6067. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6068. */
  6069. export class CubicEase extends EasingFunction implements IEasingFunction {
  6070. /** @hidden */
  6071. easeInCore(gradient: number): number;
  6072. }
  6073. /**
  6074. * Easing function with an elastic shape (see link below).
  6075. * @see https://easings.net/#easeInElastic
  6076. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6077. */
  6078. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6079. /** Defines the number of oscillations*/
  6080. oscillations: number;
  6081. /** Defines the amplitude of the oscillations*/
  6082. springiness: number;
  6083. /**
  6084. * Instantiates an elastic easing function
  6085. * @see https://easings.net/#easeInElastic
  6086. * @param oscillations Defines the number of oscillations
  6087. * @param springiness Defines the amplitude of the oscillations
  6088. */
  6089. constructor(
  6090. /** Defines the number of oscillations*/
  6091. oscillations?: number,
  6092. /** Defines the amplitude of the oscillations*/
  6093. springiness?: number);
  6094. /** @hidden */
  6095. easeInCore(gradient: number): number;
  6096. }
  6097. /**
  6098. * Easing function with an exponential shape (see link below).
  6099. * @see https://easings.net/#easeInExpo
  6100. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6101. */
  6102. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6103. /** Defines the exponent of the function */
  6104. exponent: number;
  6105. /**
  6106. * Instantiates an exponential easing function
  6107. * @see https://easings.net/#easeInExpo
  6108. * @param exponent Defines the exponent of the function
  6109. */
  6110. constructor(
  6111. /** Defines the exponent of the function */
  6112. exponent?: number);
  6113. /** @hidden */
  6114. easeInCore(gradient: number): number;
  6115. }
  6116. /**
  6117. * Easing function with a power shape (see link below).
  6118. * @see https://easings.net/#easeInQuad
  6119. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6120. */
  6121. export class PowerEase extends EasingFunction implements IEasingFunction {
  6122. /** Defines the power of the function */
  6123. power: number;
  6124. /**
  6125. * Instantiates an power base easing function
  6126. * @see https://easings.net/#easeInQuad
  6127. * @param power Defines the power of the function
  6128. */
  6129. constructor(
  6130. /** Defines the power of the function */
  6131. power?: number);
  6132. /** @hidden */
  6133. easeInCore(gradient: number): number;
  6134. }
  6135. /**
  6136. * Easing function with a power of 2 shape (see link below).
  6137. * @see https://easings.net/#easeInQuad
  6138. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6139. */
  6140. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6141. /** @hidden */
  6142. easeInCore(gradient: number): number;
  6143. }
  6144. /**
  6145. * Easing function with a power of 4 shape (see link below).
  6146. * @see https://easings.net/#easeInQuart
  6147. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6148. */
  6149. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6150. /** @hidden */
  6151. easeInCore(gradient: number): number;
  6152. }
  6153. /**
  6154. * Easing function with a power of 5 shape (see link below).
  6155. * @see https://easings.net/#easeInQuint
  6156. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6157. */
  6158. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6159. /** @hidden */
  6160. easeInCore(gradient: number): number;
  6161. }
  6162. /**
  6163. * Easing function with a sin shape (see link below).
  6164. * @see https://easings.net/#easeInSine
  6165. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6166. */
  6167. export class SineEase extends EasingFunction implements IEasingFunction {
  6168. /** @hidden */
  6169. easeInCore(gradient: number): number;
  6170. }
  6171. /**
  6172. * Easing function with a bezier shape (see link below).
  6173. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6174. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6175. */
  6176. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6177. /** Defines the x component of the start tangent in the bezier curve */
  6178. x1: number;
  6179. /** Defines the y component of the start tangent in the bezier curve */
  6180. y1: number;
  6181. /** Defines the x component of the end tangent in the bezier curve */
  6182. x2: number;
  6183. /** Defines the y component of the end tangent in the bezier curve */
  6184. y2: number;
  6185. /**
  6186. * Instantiates a bezier function
  6187. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6188. * @param x1 Defines the x component of the start tangent in the bezier curve
  6189. * @param y1 Defines the y component of the start tangent in the bezier curve
  6190. * @param x2 Defines the x component of the end tangent in the bezier curve
  6191. * @param y2 Defines the y component of the end tangent in the bezier curve
  6192. */
  6193. constructor(
  6194. /** Defines the x component of the start tangent in the bezier curve */
  6195. x1?: number,
  6196. /** Defines the y component of the start tangent in the bezier curve */
  6197. y1?: number,
  6198. /** Defines the x component of the end tangent in the bezier curve */
  6199. x2?: number,
  6200. /** Defines the y component of the end tangent in the bezier curve */
  6201. y2?: number);
  6202. /** @hidden */
  6203. easeInCore(gradient: number): number;
  6204. }
  6205. }
  6206. declare module BABYLON {
  6207. /**
  6208. * Class used to hold a RGB color
  6209. */
  6210. export class Color3 {
  6211. /**
  6212. * Defines the red component (between 0 and 1, default is 0)
  6213. */
  6214. r: number;
  6215. /**
  6216. * Defines the green component (between 0 and 1, default is 0)
  6217. */
  6218. g: number;
  6219. /**
  6220. * Defines the blue component (between 0 and 1, default is 0)
  6221. */
  6222. b: number;
  6223. /**
  6224. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  6225. * @param r defines the red component (between 0 and 1, default is 0)
  6226. * @param g defines the green component (between 0 and 1, default is 0)
  6227. * @param b defines the blue component (between 0 and 1, default is 0)
  6228. */
  6229. constructor(
  6230. /**
  6231. * Defines the red component (between 0 and 1, default is 0)
  6232. */
  6233. r?: number,
  6234. /**
  6235. * Defines the green component (between 0 and 1, default is 0)
  6236. */
  6237. g?: number,
  6238. /**
  6239. * Defines the blue component (between 0 and 1, default is 0)
  6240. */
  6241. b?: number);
  6242. /**
  6243. * Creates a string with the Color3 current values
  6244. * @returns the string representation of the Color3 object
  6245. */
  6246. toString(): string;
  6247. /**
  6248. * Returns the string "Color3"
  6249. * @returns "Color3"
  6250. */
  6251. getClassName(): string;
  6252. /**
  6253. * Compute the Color3 hash code
  6254. * @returns an unique number that can be used to hash Color3 objects
  6255. */
  6256. getHashCode(): number;
  6257. /**
  6258. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  6259. * @param array defines the array where to store the r,g,b components
  6260. * @param index defines an optional index in the target array to define where to start storing values
  6261. * @returns the current Color3 object
  6262. */
  6263. toArray(array: FloatArray, index?: number): Color3;
  6264. /**
  6265. * Update the current color with values stored in an array from the starting index of the given array
  6266. * @param array defines the source array
  6267. * @param offset defines an offset in the source array
  6268. * @returns the current Color3 object
  6269. */
  6270. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  6271. /**
  6272. * Returns a new Color4 object from the current Color3 and the given alpha
  6273. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  6274. * @returns a new Color4 object
  6275. */
  6276. toColor4(alpha?: number): Color4;
  6277. /**
  6278. * Returns a new array populated with 3 numeric elements : red, green and blue values
  6279. * @returns the new array
  6280. */
  6281. asArray(): number[];
  6282. /**
  6283. * Returns the luminance value
  6284. * @returns a float value
  6285. */
  6286. toLuminance(): number;
  6287. /**
  6288. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  6289. * @param otherColor defines the second operand
  6290. * @returns the new Color3 object
  6291. */
  6292. multiply(otherColor: DeepImmutable<Color3>): Color3;
  6293. /**
  6294. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  6295. * @param otherColor defines the second operand
  6296. * @param result defines the Color3 object where to store the result
  6297. * @returns the current Color3
  6298. */
  6299. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6300. /**
  6301. * Determines equality between Color3 objects
  6302. * @param otherColor defines the second operand
  6303. * @returns true if the rgb values are equal to the given ones
  6304. */
  6305. equals(otherColor: DeepImmutable<Color3>): boolean;
  6306. /**
  6307. * Determines equality between the current Color3 object and a set of r,b,g values
  6308. * @param r defines the red component to check
  6309. * @param g defines the green component to check
  6310. * @param b defines the blue component to check
  6311. * @returns true if the rgb values are equal to the given ones
  6312. */
  6313. equalsFloats(r: number, g: number, b: number): boolean;
  6314. /**
  6315. * Multiplies in place each rgb value by scale
  6316. * @param scale defines the scaling factor
  6317. * @returns the updated Color3
  6318. */
  6319. scale(scale: number): Color3;
  6320. /**
  6321. * Multiplies the rgb values by scale and stores the result into "result"
  6322. * @param scale defines the scaling factor
  6323. * @param result defines the Color3 object where to store the result
  6324. * @returns the unmodified current Color3
  6325. */
  6326. scaleToRef(scale: number, result: Color3): Color3;
  6327. /**
  6328. * Scale the current Color3 values by a factor and add the result to a given Color3
  6329. * @param scale defines the scale factor
  6330. * @param result defines color to store the result into
  6331. * @returns the unmodified current Color3
  6332. */
  6333. scaleAndAddToRef(scale: number, result: Color3): Color3;
  6334. /**
  6335. * Clamps the rgb values by the min and max values and stores the result into "result"
  6336. * @param min defines minimum clamping value (default is 0)
  6337. * @param max defines maximum clamping value (default is 1)
  6338. * @param result defines color to store the result into
  6339. * @returns the original Color3
  6340. */
  6341. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  6342. /**
  6343. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  6344. * @param otherColor defines the second operand
  6345. * @returns the new Color3
  6346. */
  6347. add(otherColor: DeepImmutable<Color3>): Color3;
  6348. /**
  6349. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  6350. * @param otherColor defines the second operand
  6351. * @param result defines Color3 object to store the result into
  6352. * @returns the unmodified current Color3
  6353. */
  6354. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6355. /**
  6356. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  6357. * @param otherColor defines the second operand
  6358. * @returns the new Color3
  6359. */
  6360. subtract(otherColor: DeepImmutable<Color3>): Color3;
  6361. /**
  6362. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  6363. * @param otherColor defines the second operand
  6364. * @param result defines Color3 object to store the result into
  6365. * @returns the unmodified current Color3
  6366. */
  6367. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6368. /**
  6369. * Copy the current object
  6370. * @returns a new Color3 copied the current one
  6371. */
  6372. clone(): Color3;
  6373. /**
  6374. * Copies the rgb values from the source in the current Color3
  6375. * @param source defines the source Color3 object
  6376. * @returns the updated Color3 object
  6377. */
  6378. copyFrom(source: DeepImmutable<Color3>): Color3;
  6379. /**
  6380. * Updates the Color3 rgb values from the given floats
  6381. * @param r defines the red component to read from
  6382. * @param g defines the green component to read from
  6383. * @param b defines the blue component to read from
  6384. * @returns the current Color3 object
  6385. */
  6386. copyFromFloats(r: number, g: number, b: number): Color3;
  6387. /**
  6388. * Updates the Color3 rgb values from the given floats
  6389. * @param r defines the red component to read from
  6390. * @param g defines the green component to read from
  6391. * @param b defines the blue component to read from
  6392. * @returns the current Color3 object
  6393. */
  6394. set(r: number, g: number, b: number): Color3;
  6395. /**
  6396. * Compute the Color3 hexadecimal code as a string
  6397. * @returns a string containing the hexadecimal representation of the Color3 object
  6398. */
  6399. toHexString(): string;
  6400. /**
  6401. * Computes a new Color3 converted from the current one to linear space
  6402. * @returns a new Color3 object
  6403. */
  6404. toLinearSpace(): Color3;
  6405. /**
  6406. * Converts current color in rgb space to HSV values
  6407. * @returns a new color3 representing the HSV values
  6408. */
  6409. toHSV(): Color3;
  6410. /**
  6411. * Converts current color in rgb space to HSV values
  6412. * @param result defines the Color3 where to store the HSV values
  6413. */
  6414. toHSVToRef(result: Color3): void;
  6415. /**
  6416. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  6417. * @param convertedColor defines the Color3 object where to store the linear space version
  6418. * @returns the unmodified Color3
  6419. */
  6420. toLinearSpaceToRef(convertedColor: Color3): Color3;
  6421. /**
  6422. * Computes a new Color3 converted from the current one to gamma space
  6423. * @returns a new Color3 object
  6424. */
  6425. toGammaSpace(): Color3;
  6426. /**
  6427. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  6428. * @param convertedColor defines the Color3 object where to store the gamma space version
  6429. * @returns the unmodified Color3
  6430. */
  6431. toGammaSpaceToRef(convertedColor: Color3): Color3;
  6432. private static _BlackReadOnly;
  6433. /**
  6434. * Convert Hue, saturation and value to a Color3 (RGB)
  6435. * @param hue defines the hue
  6436. * @param saturation defines the saturation
  6437. * @param value defines the value
  6438. * @param result defines the Color3 where to store the RGB values
  6439. */
  6440. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  6441. /**
  6442. * Creates a new Color3 from the string containing valid hexadecimal values
  6443. * @param hex defines a string containing valid hexadecimal values
  6444. * @returns a new Color3 object
  6445. */
  6446. static FromHexString(hex: string): Color3;
  6447. /**
  6448. * Creates a new Color3 from the starting index of the given array
  6449. * @param array defines the source array
  6450. * @param offset defines an offset in the source array
  6451. * @returns a new Color3 object
  6452. */
  6453. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  6454. /**
  6455. * Creates a new Color3 from the starting index element of the given array
  6456. * @param array defines the source array to read from
  6457. * @param offset defines the offset in the source array
  6458. * @param result defines the target Color3 object
  6459. */
  6460. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  6461. /**
  6462. * Creates a new Color3 from integer values (< 256)
  6463. * @param r defines the red component to read from (value between 0 and 255)
  6464. * @param g defines the green component to read from (value between 0 and 255)
  6465. * @param b defines the blue component to read from (value between 0 and 255)
  6466. * @returns a new Color3 object
  6467. */
  6468. static FromInts(r: number, g: number, b: number): Color3;
  6469. /**
  6470. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  6471. * @param start defines the start Color3 value
  6472. * @param end defines the end Color3 value
  6473. * @param amount defines the gradient value between start and end
  6474. * @returns a new Color3 object
  6475. */
  6476. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  6477. /**
  6478. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  6479. * @param left defines the start value
  6480. * @param right defines the end value
  6481. * @param amount defines the gradient factor
  6482. * @param result defines the Color3 object where to store the result
  6483. */
  6484. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  6485. /**
  6486. * Returns a Color3 value containing a red color
  6487. * @returns a new Color3 object
  6488. */
  6489. static Red(): Color3;
  6490. /**
  6491. * Returns a Color3 value containing a green color
  6492. * @returns a new Color3 object
  6493. */
  6494. static Green(): Color3;
  6495. /**
  6496. * Returns a Color3 value containing a blue color
  6497. * @returns a new Color3 object
  6498. */
  6499. static Blue(): Color3;
  6500. /**
  6501. * Returns a Color3 value containing a black color
  6502. * @returns a new Color3 object
  6503. */
  6504. static Black(): Color3;
  6505. /**
  6506. * Gets a Color3 value containing a black color that must not be updated
  6507. */
  6508. static get BlackReadOnly(): DeepImmutable<Color3>;
  6509. /**
  6510. * Returns a Color3 value containing a white color
  6511. * @returns a new Color3 object
  6512. */
  6513. static White(): Color3;
  6514. /**
  6515. * Returns a Color3 value containing a purple color
  6516. * @returns a new Color3 object
  6517. */
  6518. static Purple(): Color3;
  6519. /**
  6520. * Returns a Color3 value containing a magenta color
  6521. * @returns a new Color3 object
  6522. */
  6523. static Magenta(): Color3;
  6524. /**
  6525. * Returns a Color3 value containing a yellow color
  6526. * @returns a new Color3 object
  6527. */
  6528. static Yellow(): Color3;
  6529. /**
  6530. * Returns a Color3 value containing a gray color
  6531. * @returns a new Color3 object
  6532. */
  6533. static Gray(): Color3;
  6534. /**
  6535. * Returns a Color3 value containing a teal color
  6536. * @returns a new Color3 object
  6537. */
  6538. static Teal(): Color3;
  6539. /**
  6540. * Returns a Color3 value containing a random color
  6541. * @returns a new Color3 object
  6542. */
  6543. static Random(): Color3;
  6544. }
  6545. /**
  6546. * Class used to hold a RBGA color
  6547. */
  6548. export class Color4 {
  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. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  6567. * @param r defines the red component (between 0 and 1, default is 0)
  6568. * @param g defines the green component (between 0 and 1, default is 0)
  6569. * @param b defines the blue component (between 0 and 1, default is 0)
  6570. * @param a defines the alpha component (between 0 and 1, default is 1)
  6571. */
  6572. constructor(
  6573. /**
  6574. * Defines the red component (between 0 and 1, default is 0)
  6575. */
  6576. r?: number,
  6577. /**
  6578. * Defines the green component (between 0 and 1, default is 0)
  6579. */
  6580. g?: number,
  6581. /**
  6582. * Defines the blue component (between 0 and 1, default is 0)
  6583. */
  6584. b?: number,
  6585. /**
  6586. * Defines the alpha component (between 0 and 1, default is 1)
  6587. */
  6588. a?: number);
  6589. /**
  6590. * Adds in place the given Color4 values to the current Color4 object
  6591. * @param right defines the second operand
  6592. * @returns the current updated Color4 object
  6593. */
  6594. addInPlace(right: DeepImmutable<Color4>): Color4;
  6595. /**
  6596. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  6597. * @returns the new array
  6598. */
  6599. asArray(): number[];
  6600. /**
  6601. * Stores from the starting index in the given array the Color4 successive values
  6602. * @param array defines the array where to store the r,g,b components
  6603. * @param index defines an optional index in the target array to define where to start storing values
  6604. * @returns the current Color4 object
  6605. */
  6606. toArray(array: number[], index?: number): Color4;
  6607. /**
  6608. * Update the current color with values stored in an array from the starting index of the given array
  6609. * @param array defines the source array
  6610. * @param offset defines an offset in the source array
  6611. * @returns the current Color4 object
  6612. */
  6613. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6614. /**
  6615. * Determines equality between Color4 objects
  6616. * @param otherColor defines the second operand
  6617. * @returns true if the rgba values are equal to the given ones
  6618. */
  6619. equals(otherColor: DeepImmutable<Color4>): boolean;
  6620. /**
  6621. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  6622. * @param right defines the second operand
  6623. * @returns a new Color4 object
  6624. */
  6625. add(right: DeepImmutable<Color4>): Color4;
  6626. /**
  6627. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  6628. * @param right defines the second operand
  6629. * @returns a new Color4 object
  6630. */
  6631. subtract(right: DeepImmutable<Color4>): Color4;
  6632. /**
  6633. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  6634. * @param right defines the second operand
  6635. * @param result defines the Color4 object where to store the result
  6636. * @returns the current Color4 object
  6637. */
  6638. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  6639. /**
  6640. * Creates a new Color4 with the current Color4 values multiplied by scale
  6641. * @param scale defines the scaling factor to apply
  6642. * @returns a new Color4 object
  6643. */
  6644. scale(scale: number): Color4;
  6645. /**
  6646. * Multiplies the current Color4 values by scale and stores the result in "result"
  6647. * @param scale defines the scaling factor to apply
  6648. * @param result defines the Color4 object where to store the result
  6649. * @returns the current unmodified Color4
  6650. */
  6651. scaleToRef(scale: number, result: Color4): Color4;
  6652. /**
  6653. * Scale the current Color4 values by a factor and add the result to a given Color4
  6654. * @param scale defines the scale factor
  6655. * @param result defines the Color4 object where to store the result
  6656. * @returns the unmodified current Color4
  6657. */
  6658. scaleAndAddToRef(scale: number, result: Color4): Color4;
  6659. /**
  6660. * Clamps the rgb values by the min and max values and stores the result into "result"
  6661. * @param min defines minimum clamping value (default is 0)
  6662. * @param max defines maximum clamping value (default is 1)
  6663. * @param result defines color to store the result into.
  6664. * @returns the cuurent Color4
  6665. */
  6666. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  6667. /**
  6668. * Multipy an Color4 value by another and return a new Color4 object
  6669. * @param color defines the Color4 value to multiply by
  6670. * @returns a new Color4 object
  6671. */
  6672. multiply(color: Color4): Color4;
  6673. /**
  6674. * Multipy a Color4 value by another and push the result in a reference value
  6675. * @param color defines the Color4 value to multiply by
  6676. * @param result defines the Color4 to fill the result in
  6677. * @returns the result Color4
  6678. */
  6679. multiplyToRef(color: Color4, result: Color4): Color4;
  6680. /**
  6681. * Creates a string with the Color4 current values
  6682. * @returns the string representation of the Color4 object
  6683. */
  6684. toString(): string;
  6685. /**
  6686. * Returns the string "Color4"
  6687. * @returns "Color4"
  6688. */
  6689. getClassName(): string;
  6690. /**
  6691. * Compute the Color4 hash code
  6692. * @returns an unique number that can be used to hash Color4 objects
  6693. */
  6694. getHashCode(): number;
  6695. /**
  6696. * Creates a new Color4 copied from the current one
  6697. * @returns a new Color4 object
  6698. */
  6699. clone(): Color4;
  6700. /**
  6701. * Copies the given Color4 values into the current one
  6702. * @param source defines the source Color4 object
  6703. * @returns the current updated Color4 object
  6704. */
  6705. copyFrom(source: Color4): Color4;
  6706. /**
  6707. * Copies the given float values into the current one
  6708. * @param r defines the red component to read from
  6709. * @param g defines the green component to read from
  6710. * @param b defines the blue component to read from
  6711. * @param a defines the alpha component to read from
  6712. * @returns the current updated Color4 object
  6713. */
  6714. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  6715. /**
  6716. * Copies the given float values into the current one
  6717. * @param r defines the red component to read from
  6718. * @param g defines the green component to read from
  6719. * @param b defines the blue component to read from
  6720. * @param a defines the alpha component to read from
  6721. * @returns the current updated Color4 object
  6722. */
  6723. set(r: number, g: number, b: number, a: number): Color4;
  6724. /**
  6725. * Compute the Color4 hexadecimal code as a string
  6726. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  6727. * @returns a string containing the hexadecimal representation of the Color4 object
  6728. */
  6729. toHexString(returnAsColor3?: boolean): string;
  6730. /**
  6731. * Computes a new Color4 converted from the current one to linear space
  6732. * @returns a new Color4 object
  6733. */
  6734. toLinearSpace(): Color4;
  6735. /**
  6736. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6737. * @param convertedColor defines the Color4 object where to store the linear space version
  6738. * @returns the unmodified Color4
  6739. */
  6740. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6741. /**
  6742. * Computes a new Color4 converted from the current one to gamma space
  6743. * @returns a new Color4 object
  6744. */
  6745. toGammaSpace(): Color4;
  6746. /**
  6747. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6748. * @param convertedColor defines the Color4 object where to store the gamma space version
  6749. * @returns the unmodified Color4
  6750. */
  6751. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6752. /**
  6753. * Creates a new Color4 from the string containing valid hexadecimal values
  6754. * @param hex defines a string containing valid hexadecimal values
  6755. * @returns a new Color4 object
  6756. */
  6757. static FromHexString(hex: string): Color4;
  6758. /**
  6759. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6760. * @param left defines the start value
  6761. * @param right defines the end value
  6762. * @param amount defines the gradient factor
  6763. * @returns a new Color4 object
  6764. */
  6765. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6766. /**
  6767. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6768. * @param left defines the start value
  6769. * @param right defines the end value
  6770. * @param amount defines the gradient factor
  6771. * @param result defines the Color4 object where to store data
  6772. */
  6773. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6774. /**
  6775. * Creates a new Color4 from a Color3 and an alpha value
  6776. * @param color3 defines the source Color3 to read from
  6777. * @param alpha defines the alpha component (1.0 by default)
  6778. * @returns a new Color4 object
  6779. */
  6780. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6781. /**
  6782. * Creates a new Color4 from the starting index element of the given array
  6783. * @param array defines the source array to read from
  6784. * @param offset defines the offset in the source array
  6785. * @returns a new Color4 object
  6786. */
  6787. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6788. /**
  6789. * Creates a new Color4 from the starting index element of the given array
  6790. * @param array defines the source array to read from
  6791. * @param offset defines the offset in the source array
  6792. * @param result defines the target Color4 object
  6793. */
  6794. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6795. /**
  6796. * Creates a new Color3 from integer values (< 256)
  6797. * @param r defines the red component to read from (value between 0 and 255)
  6798. * @param g defines the green component to read from (value between 0 and 255)
  6799. * @param b defines the blue component to read from (value between 0 and 255)
  6800. * @param a defines the alpha component to read from (value between 0 and 255)
  6801. * @returns a new Color3 object
  6802. */
  6803. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6804. /**
  6805. * Check the content of a given array and convert it to an array containing RGBA data
  6806. * If the original array was already containing count * 4 values then it is returned directly
  6807. * @param colors defines the array to check
  6808. * @param count defines the number of RGBA data to expect
  6809. * @returns an array containing count * 4 values (RGBA)
  6810. */
  6811. static CheckColors4(colors: number[], count: number): number[];
  6812. }
  6813. /**
  6814. * @hidden
  6815. */
  6816. export class TmpColors {
  6817. static Color3: Color3[];
  6818. static Color4: Color4[];
  6819. }
  6820. }
  6821. declare module BABYLON {
  6822. /**
  6823. * Defines an interface which represents an animation key frame
  6824. */
  6825. export interface IAnimationKey {
  6826. /**
  6827. * Frame of the key frame
  6828. */
  6829. frame: number;
  6830. /**
  6831. * Value at the specifies key frame
  6832. */
  6833. value: any;
  6834. /**
  6835. * The input tangent for the cubic hermite spline
  6836. */
  6837. inTangent?: any;
  6838. /**
  6839. * The output tangent for the cubic hermite spline
  6840. */
  6841. outTangent?: any;
  6842. /**
  6843. * The animation interpolation type
  6844. */
  6845. interpolation?: AnimationKeyInterpolation;
  6846. }
  6847. /**
  6848. * Enum for the animation key frame interpolation type
  6849. */
  6850. export enum AnimationKeyInterpolation {
  6851. /**
  6852. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6853. */
  6854. STEP = 1
  6855. }
  6856. }
  6857. declare module BABYLON {
  6858. /**
  6859. * Represents the range of an animation
  6860. */
  6861. export class AnimationRange {
  6862. /**The name of the animation range**/
  6863. name: string;
  6864. /**The starting frame of the animation */
  6865. from: number;
  6866. /**The ending frame of the animation*/
  6867. to: number;
  6868. /**
  6869. * Initializes the range of an animation
  6870. * @param name The name of the animation range
  6871. * @param from The starting frame of the animation
  6872. * @param to The ending frame of the animation
  6873. */
  6874. constructor(
  6875. /**The name of the animation range**/
  6876. name: string,
  6877. /**The starting frame of the animation */
  6878. from: number,
  6879. /**The ending frame of the animation*/
  6880. to: number);
  6881. /**
  6882. * Makes a copy of the animation range
  6883. * @returns A copy of the animation range
  6884. */
  6885. clone(): AnimationRange;
  6886. }
  6887. }
  6888. declare module BABYLON {
  6889. /**
  6890. * Composed of a frame, and an action function
  6891. */
  6892. export class AnimationEvent {
  6893. /** The frame for which the event is triggered **/
  6894. frame: number;
  6895. /** The event to perform when triggered **/
  6896. action: (currentFrame: number) => void;
  6897. /** Specifies if the event should be triggered only once**/
  6898. onlyOnce?: boolean | undefined;
  6899. /**
  6900. * Specifies if the animation event is done
  6901. */
  6902. isDone: boolean;
  6903. /**
  6904. * Initializes the animation event
  6905. * @param frame The frame for which the event is triggered
  6906. * @param action The event to perform when triggered
  6907. * @param onlyOnce Specifies if the event should be triggered only once
  6908. */
  6909. constructor(
  6910. /** The frame for which the event is triggered **/
  6911. frame: number,
  6912. /** The event to perform when triggered **/
  6913. action: (currentFrame: number) => void,
  6914. /** Specifies if the event should be triggered only once**/
  6915. onlyOnce?: boolean | undefined);
  6916. /** @hidden */
  6917. _clone(): AnimationEvent;
  6918. }
  6919. }
  6920. declare module BABYLON {
  6921. /**
  6922. * Interface used to define a behavior
  6923. */
  6924. export interface Behavior<T> {
  6925. /** gets or sets behavior's name */
  6926. name: string;
  6927. /**
  6928. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6929. */
  6930. init(): void;
  6931. /**
  6932. * Called when the behavior is attached to a target
  6933. * @param target defines the target where the behavior is attached to
  6934. */
  6935. attach(target: T): void;
  6936. /**
  6937. * Called when the behavior is detached from its target
  6938. */
  6939. detach(): void;
  6940. }
  6941. /**
  6942. * Interface implemented by classes supporting behaviors
  6943. */
  6944. export interface IBehaviorAware<T> {
  6945. /**
  6946. * Attach a behavior
  6947. * @param behavior defines the behavior to attach
  6948. * @returns the current host
  6949. */
  6950. addBehavior(behavior: Behavior<T>): T;
  6951. /**
  6952. * Remove a behavior from the current object
  6953. * @param behavior defines the behavior to detach
  6954. * @returns the current host
  6955. */
  6956. removeBehavior(behavior: Behavior<T>): T;
  6957. /**
  6958. * Gets a behavior using its name to search
  6959. * @param name defines the name to search
  6960. * @returns the behavior or null if not found
  6961. */
  6962. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6963. }
  6964. }
  6965. declare module BABYLON {
  6966. /**
  6967. * Class used to provide helpers for slicing
  6968. */
  6969. export class SliceTools {
  6970. /**
  6971. * Provides a slice function that will work even on IE
  6972. * @param data defines the array to slice
  6973. * @param start defines the start of the data (optional)
  6974. * @param end defines the end of the data (optional)
  6975. * @returns the new sliced array
  6976. */
  6977. static Slice<T>(data: T, start?: number, end?: number): T;
  6978. /**
  6979. * Provides a slice function that will work even on IE
  6980. * The difference between this and Slice is that this will force-convert to array
  6981. * @param data defines the array to slice
  6982. * @param start defines the start of the data (optional)
  6983. * @param end defines the end of the data (optional)
  6984. * @returns the new sliced array
  6985. */
  6986. static SliceToArray<T, P>(data: T, start?: number, end?: number): Array<P>;
  6987. }
  6988. }
  6989. declare module BABYLON {
  6990. /**
  6991. * Class used to store data that will be store in GPU memory
  6992. */
  6993. export class Buffer {
  6994. private _engine;
  6995. private _buffer;
  6996. /** @hidden */
  6997. _data: Nullable<DataArray>;
  6998. private _updatable;
  6999. private _instanced;
  7000. private _divisor;
  7001. private _isAlreadyOwned;
  7002. /**
  7003. * Gets the byte stride.
  7004. */
  7005. readonly byteStride: number;
  7006. /**
  7007. * Constructor
  7008. * @param engine the engine
  7009. * @param data the data to use for this buffer
  7010. * @param updatable whether the data is updatable
  7011. * @param stride the stride (optional)
  7012. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  7013. * @param instanced whether the buffer is instanced (optional)
  7014. * @param useBytes set to true if the stride in in bytes (optional)
  7015. * @param divisor sets an optional divisor for instances (1 by default)
  7016. */
  7017. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  7018. /**
  7019. * Create a new VertexBuffer based on the current buffer
  7020. * @param kind defines the vertex buffer kind (position, normal, etc.)
  7021. * @param offset defines offset in the buffer (0 by default)
  7022. * @param size defines the size in floats of attributes (position is 3 for instance)
  7023. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  7024. * @param instanced defines if the vertex buffer contains indexed data
  7025. * @param useBytes defines if the offset and stride are in bytes *
  7026. * @param divisor sets an optional divisor for instances (1 by default)
  7027. * @returns the new vertex buffer
  7028. */
  7029. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  7030. /**
  7031. * Gets a boolean indicating if the Buffer is updatable?
  7032. * @returns true if the buffer is updatable
  7033. */
  7034. isUpdatable(): boolean;
  7035. /**
  7036. * Gets current buffer's data
  7037. * @returns a DataArray or null
  7038. */
  7039. getData(): Nullable<DataArray>;
  7040. /**
  7041. * Gets underlying native buffer
  7042. * @returns underlying native buffer
  7043. */
  7044. getBuffer(): Nullable<DataBuffer>;
  7045. /**
  7046. * Gets the stride in float32 units (i.e. byte stride / 4).
  7047. * May not be an integer if the byte stride is not divisible by 4.
  7048. * @returns the stride in float32 units
  7049. * @deprecated Please use byteStride instead.
  7050. */
  7051. getStrideSize(): number;
  7052. /**
  7053. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  7054. * @param data defines the data to store
  7055. */
  7056. create(data?: Nullable<DataArray>): void;
  7057. /** @hidden */
  7058. _rebuild(): void;
  7059. /**
  7060. * Update current buffer data
  7061. * @param data defines the data to store
  7062. */
  7063. update(data: DataArray): void;
  7064. /**
  7065. * Updates the data directly.
  7066. * @param data the new data
  7067. * @param offset the new offset
  7068. * @param vertexCount the vertex count (optional)
  7069. * @param useBytes set to true if the offset is in bytes
  7070. */
  7071. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  7072. /** @hidden */
  7073. _increaseReferences(): void;
  7074. /**
  7075. * Release all resources
  7076. */
  7077. dispose(): void;
  7078. }
  7079. /**
  7080. * Specialized buffer used to store vertex data
  7081. */
  7082. export class VertexBuffer {
  7083. private static _Counter;
  7084. /** @hidden */
  7085. _buffer: Buffer;
  7086. private _kind;
  7087. private _size;
  7088. private _ownsBuffer;
  7089. private _instanced;
  7090. private _instanceDivisor;
  7091. /**
  7092. * The byte type.
  7093. */
  7094. static readonly BYTE: number;
  7095. /**
  7096. * The unsigned byte type.
  7097. */
  7098. static readonly UNSIGNED_BYTE: number;
  7099. /**
  7100. * The short type.
  7101. */
  7102. static readonly SHORT: number;
  7103. /**
  7104. * The unsigned short type.
  7105. */
  7106. static readonly UNSIGNED_SHORT: number;
  7107. /**
  7108. * The integer type.
  7109. */
  7110. static readonly INT: number;
  7111. /**
  7112. * The unsigned integer type.
  7113. */
  7114. static readonly UNSIGNED_INT: number;
  7115. /**
  7116. * The float type.
  7117. */
  7118. static readonly FLOAT: number;
  7119. /**
  7120. * Gets or sets the instance divisor when in instanced mode
  7121. */
  7122. get instanceDivisor(): number;
  7123. set instanceDivisor(value: number);
  7124. /**
  7125. * Gets the byte stride.
  7126. */
  7127. readonly byteStride: number;
  7128. /**
  7129. * Gets the byte offset.
  7130. */
  7131. readonly byteOffset: number;
  7132. /**
  7133. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  7134. */
  7135. readonly normalized: boolean;
  7136. /**
  7137. * Gets the data type of each component in the array.
  7138. */
  7139. readonly type: number;
  7140. /**
  7141. * Gets the unique id of this vertex buffer
  7142. */
  7143. readonly uniqueId: number;
  7144. /**
  7145. * Gets a hash code representing the format (type, normalized, size, instanced, stride) of this buffer
  7146. * All buffers with the same format will have the same hash code
  7147. */
  7148. readonly hashCode: number;
  7149. /**
  7150. * Constructor
  7151. * @param engine the engine
  7152. * @param data the data to use for this vertex buffer
  7153. * @param kind the vertex buffer kind
  7154. * @param updatable whether the data is updatable
  7155. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  7156. * @param stride the stride (optional)
  7157. * @param instanced whether the buffer is instanced (optional)
  7158. * @param offset the offset of the data (optional)
  7159. * @param size the number of components (optional)
  7160. * @param type the type of the component (optional)
  7161. * @param normalized whether the data contains normalized data (optional)
  7162. * @param useBytes set to true if stride and offset are in bytes (optional)
  7163. * @param divisor defines the instance divisor to use (1 by default)
  7164. * @param takeBufferOwnership defines if the buffer should be released when the vertex buffer is disposed
  7165. */
  7166. 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);
  7167. private _computeHashCode;
  7168. /** @hidden */
  7169. _rebuild(): void;
  7170. /**
  7171. * Returns the kind of the VertexBuffer (string)
  7172. * @returns a string
  7173. */
  7174. getKind(): string;
  7175. /**
  7176. * Gets a boolean indicating if the VertexBuffer is updatable?
  7177. * @returns true if the buffer is updatable
  7178. */
  7179. isUpdatable(): boolean;
  7180. /**
  7181. * Gets current buffer's data
  7182. * @returns a DataArray or null
  7183. */
  7184. getData(): Nullable<DataArray>;
  7185. /**
  7186. * Gets current buffer's data as a float array. Float data is constructed if the vertex buffer data cannot be returned directly.
  7187. * @param totalVertices number of vertices in the buffer to take into account
  7188. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  7189. * @returns a float array containing vertex data
  7190. */
  7191. getFloatData(totalVertices: number, forceCopy?: boolean): Nullable<FloatArray>;
  7192. /**
  7193. * Gets underlying native buffer
  7194. * @returns underlying native buffer
  7195. */
  7196. getBuffer(): Nullable<DataBuffer>;
  7197. /**
  7198. * Gets the stride in float32 units (i.e. byte stride / 4).
  7199. * May not be an integer if the byte stride is not divisible by 4.
  7200. * @returns the stride in float32 units
  7201. * @deprecated Please use byteStride instead.
  7202. */
  7203. getStrideSize(): number;
  7204. /**
  7205. * Returns the offset as a multiple of the type byte length.
  7206. * @returns the offset in bytes
  7207. * @deprecated Please use byteOffset instead.
  7208. */
  7209. getOffset(): number;
  7210. /**
  7211. * Returns the number of components per vertex attribute (integer)
  7212. * @returns the size in float
  7213. */
  7214. getSize(): number;
  7215. /**
  7216. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  7217. * @returns true if this buffer is instanced
  7218. */
  7219. getIsInstanced(): boolean;
  7220. /**
  7221. * Returns the instancing divisor, zero for non-instanced (integer).
  7222. * @returns a number
  7223. */
  7224. getInstanceDivisor(): number;
  7225. /**
  7226. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  7227. * @param data defines the data to store
  7228. */
  7229. create(data?: DataArray): void;
  7230. /**
  7231. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  7232. * This function will create a new buffer if the current one is not updatable
  7233. * @param data defines the data to store
  7234. */
  7235. update(data: DataArray): void;
  7236. /**
  7237. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  7238. * Returns the directly updated WebGLBuffer.
  7239. * @param data the new data
  7240. * @param offset the new offset
  7241. * @param useBytes set to true if the offset is in bytes
  7242. */
  7243. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  7244. /**
  7245. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  7246. */
  7247. dispose(): void;
  7248. /**
  7249. * Enumerates each value of this vertex buffer as numbers.
  7250. * @param count the number of values to enumerate
  7251. * @param callback the callback function called for each value
  7252. */
  7253. forEach(count: number, callback: (value: number, index: number) => void): void;
  7254. /**
  7255. * Positions
  7256. */
  7257. static readonly PositionKind: string;
  7258. /**
  7259. * Normals
  7260. */
  7261. static readonly NormalKind: string;
  7262. /**
  7263. * Tangents
  7264. */
  7265. static readonly TangentKind: string;
  7266. /**
  7267. * Texture coordinates
  7268. */
  7269. static readonly UVKind: string;
  7270. /**
  7271. * Texture coordinates 2
  7272. */
  7273. static readonly UV2Kind: string;
  7274. /**
  7275. * Texture coordinates 3
  7276. */
  7277. static readonly UV3Kind: string;
  7278. /**
  7279. * Texture coordinates 4
  7280. */
  7281. static readonly UV4Kind: string;
  7282. /**
  7283. * Texture coordinates 5
  7284. */
  7285. static readonly UV5Kind: string;
  7286. /**
  7287. * Texture coordinates 6
  7288. */
  7289. static readonly UV6Kind: string;
  7290. /**
  7291. * Colors
  7292. */
  7293. static readonly ColorKind: string;
  7294. /**
  7295. * Matrix indices (for bones)
  7296. */
  7297. static readonly MatricesIndicesKind: string;
  7298. /**
  7299. * Matrix weights (for bones)
  7300. */
  7301. static readonly MatricesWeightsKind: string;
  7302. /**
  7303. * Additional matrix indices (for bones)
  7304. */
  7305. static readonly MatricesIndicesExtraKind: string;
  7306. /**
  7307. * Additional matrix weights (for bones)
  7308. */
  7309. static readonly MatricesWeightsExtraKind: string;
  7310. /**
  7311. * Deduces the stride given a kind.
  7312. * @param kind The kind string to deduce
  7313. * @returns The deduced stride
  7314. */
  7315. static DeduceStride(kind: string): number;
  7316. /**
  7317. * Gets the byte length of the given type.
  7318. * @param type the type
  7319. * @returns the number of bytes
  7320. */
  7321. static GetTypeByteLength(type: number): number;
  7322. /**
  7323. * Enumerates each value of the given parameters as numbers.
  7324. * @param data the data to enumerate
  7325. * @param byteOffset the byte offset of the data
  7326. * @param byteStride the byte stride of the data
  7327. * @param componentCount the number of components per element
  7328. * @param componentType the type of the component
  7329. * @param count the number of values to enumerate
  7330. * @param normalized whether the data is normalized
  7331. * @param callback the callback function called for each value
  7332. */
  7333. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  7334. private static _GetFloatValue;
  7335. }
  7336. }
  7337. declare module BABYLON {
  7338. /**
  7339. * @hidden
  7340. */
  7341. export class IntersectionInfo {
  7342. bu: Nullable<number>;
  7343. bv: Nullable<number>;
  7344. distance: number;
  7345. faceId: number;
  7346. subMeshId: number;
  7347. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  7348. }
  7349. }
  7350. declare module BABYLON {
  7351. /**
  7352. * Class used to store bounding sphere information
  7353. */
  7354. export class BoundingSphere {
  7355. /**
  7356. * Gets the center of the bounding sphere in local space
  7357. */
  7358. readonly center: Vector3;
  7359. /**
  7360. * Radius of the bounding sphere in local space
  7361. */
  7362. radius: number;
  7363. /**
  7364. * Gets the center of the bounding sphere in world space
  7365. */
  7366. readonly centerWorld: Vector3;
  7367. /**
  7368. * Radius of the bounding sphere in world space
  7369. */
  7370. radiusWorld: number;
  7371. /**
  7372. * Gets the minimum vector in local space
  7373. */
  7374. readonly minimum: Vector3;
  7375. /**
  7376. * Gets the maximum vector in local space
  7377. */
  7378. readonly maximum: Vector3;
  7379. private _worldMatrix;
  7380. private static readonly TmpVector3;
  7381. /**
  7382. * Creates a new bounding sphere
  7383. * @param min defines the minimum vector (in local space)
  7384. * @param max defines the maximum vector (in local space)
  7385. * @param worldMatrix defines the new world matrix
  7386. */
  7387. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7388. /**
  7389. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7390. * @param min defines the new minimum vector (in local space)
  7391. * @param max defines the new maximum vector (in local space)
  7392. * @param worldMatrix defines the new world matrix
  7393. */
  7394. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7395. /**
  7396. * Scale the current bounding sphere by applying a scale factor
  7397. * @param factor defines the scale factor to apply
  7398. * @returns the current bounding box
  7399. */
  7400. scale(factor: number): BoundingSphere;
  7401. /**
  7402. * Gets the world matrix of the bounding box
  7403. * @returns a matrix
  7404. */
  7405. getWorldMatrix(): DeepImmutable<Matrix>;
  7406. /** @hidden */
  7407. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7408. /**
  7409. * Tests if the bounding sphere is intersecting the frustum planes
  7410. * @param frustumPlanes defines the frustum planes to test
  7411. * @returns true if there is an intersection
  7412. */
  7413. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7414. /**
  7415. * Tests if the bounding sphere center is in between the frustum planes.
  7416. * Used for optimistic fast inclusion.
  7417. * @param frustumPlanes defines the frustum planes to test
  7418. * @returns true if the sphere center is in between the frustum planes
  7419. */
  7420. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7421. /**
  7422. * Tests if a point is inside the bounding sphere
  7423. * @param point defines the point to test
  7424. * @returns true if the point is inside the bounding sphere
  7425. */
  7426. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7427. /**
  7428. * Checks if two sphere intersect
  7429. * @param sphere0 sphere 0
  7430. * @param sphere1 sphere 1
  7431. * @returns true if the spheres intersect
  7432. */
  7433. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7434. }
  7435. }
  7436. declare module BABYLON {
  7437. /**
  7438. * Class used to store bounding box information
  7439. */
  7440. export class BoundingBox implements ICullable {
  7441. /**
  7442. * Gets the 8 vectors representing the bounding box in local space
  7443. */
  7444. readonly vectors: Vector3[];
  7445. /**
  7446. * Gets the center of the bounding box in local space
  7447. */
  7448. readonly center: Vector3;
  7449. /**
  7450. * Gets the center of the bounding box in world space
  7451. */
  7452. readonly centerWorld: Vector3;
  7453. /**
  7454. * Gets the extend size in local space
  7455. */
  7456. readonly extendSize: Vector3;
  7457. /**
  7458. * Gets the extend size in world space
  7459. */
  7460. readonly extendSizeWorld: Vector3;
  7461. /**
  7462. * Gets the OBB (object bounding box) directions
  7463. */
  7464. readonly directions: Vector3[];
  7465. /**
  7466. * Gets the 8 vectors representing the bounding box in world space
  7467. */
  7468. readonly vectorsWorld: Vector3[];
  7469. /**
  7470. * Gets the minimum vector in world space
  7471. */
  7472. readonly minimumWorld: Vector3;
  7473. /**
  7474. * Gets the maximum vector in world space
  7475. */
  7476. readonly maximumWorld: Vector3;
  7477. /**
  7478. * Gets the minimum vector in local space
  7479. */
  7480. readonly minimum: Vector3;
  7481. /**
  7482. * Gets the maximum vector in local space
  7483. */
  7484. readonly maximum: Vector3;
  7485. private _worldMatrix;
  7486. private static readonly TmpVector3;
  7487. /**
  7488. * @hidden
  7489. */
  7490. _tag: number;
  7491. /**
  7492. * Creates a new bounding box
  7493. * @param min defines the minimum vector (in local space)
  7494. * @param max defines the maximum vector (in local space)
  7495. * @param worldMatrix defines the new world matrix
  7496. */
  7497. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7498. /**
  7499. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7500. * @param min defines the new minimum vector (in local space)
  7501. * @param max defines the new maximum vector (in local space)
  7502. * @param worldMatrix defines the new world matrix
  7503. */
  7504. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7505. /**
  7506. * Scale the current bounding box by applying a scale factor
  7507. * @param factor defines the scale factor to apply
  7508. * @returns the current bounding box
  7509. */
  7510. scale(factor: number): BoundingBox;
  7511. /**
  7512. * Gets the world matrix of the bounding box
  7513. * @returns a matrix
  7514. */
  7515. getWorldMatrix(): DeepImmutable<Matrix>;
  7516. /** @hidden */
  7517. _update(world: DeepImmutable<Matrix>): void;
  7518. /**
  7519. * Tests if the bounding box is intersecting the frustum planes
  7520. * @param frustumPlanes defines the frustum planes to test
  7521. * @returns true if there is an intersection
  7522. */
  7523. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7524. /**
  7525. * Tests if the bounding box is entirely inside the frustum planes
  7526. * @param frustumPlanes defines the frustum planes to test
  7527. * @returns true if there is an inclusion
  7528. */
  7529. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7530. /**
  7531. * Tests if a point is inside the bounding box
  7532. * @param point defines the point to test
  7533. * @returns true if the point is inside the bounding box
  7534. */
  7535. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7536. /**
  7537. * Tests if the bounding box intersects with a bounding sphere
  7538. * @param sphere defines the sphere to test
  7539. * @returns true if there is an intersection
  7540. */
  7541. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7542. /**
  7543. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7544. * @param min defines the min vector to use
  7545. * @param max defines the max vector to use
  7546. * @returns true if there is an intersection
  7547. */
  7548. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7549. /**
  7550. * Tests if two bounding boxes are intersections
  7551. * @param box0 defines the first box to test
  7552. * @param box1 defines the second box to test
  7553. * @returns true if there is an intersection
  7554. */
  7555. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7556. /**
  7557. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7558. * @param minPoint defines the minimum vector of the bounding box
  7559. * @param maxPoint defines the maximum vector of the bounding box
  7560. * @param sphereCenter defines the sphere center
  7561. * @param sphereRadius defines the sphere radius
  7562. * @returns true if there is an intersection
  7563. */
  7564. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7565. /**
  7566. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7567. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7568. * @param frustumPlanes defines the frustum planes to test
  7569. * @return true if there is an inclusion
  7570. */
  7571. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7572. /**
  7573. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7574. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7575. * @param frustumPlanes defines the frustum planes to test
  7576. * @return true if there is an intersection
  7577. */
  7578. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7579. }
  7580. }
  7581. declare module BABYLON {
  7582. /** @hidden */
  7583. export class Collider {
  7584. /** Define if a collision was found */
  7585. collisionFound: boolean;
  7586. /**
  7587. * Define last intersection point in local space
  7588. */
  7589. intersectionPoint: Vector3;
  7590. /**
  7591. * Define last collided mesh
  7592. */
  7593. collidedMesh: Nullable<AbstractMesh>;
  7594. private _collisionPoint;
  7595. private _planeIntersectionPoint;
  7596. private _tempVector;
  7597. private _tempVector2;
  7598. private _tempVector3;
  7599. private _tempVector4;
  7600. private _edge;
  7601. private _baseToVertex;
  7602. private _destinationPoint;
  7603. private _slidePlaneNormal;
  7604. private _displacementVector;
  7605. /** @hidden */
  7606. _radius: Vector3;
  7607. /** @hidden */
  7608. _retry: number;
  7609. private _velocity;
  7610. private _basePoint;
  7611. private _epsilon;
  7612. /** @hidden */
  7613. _velocityWorldLength: number;
  7614. /** @hidden */
  7615. _basePointWorld: Vector3;
  7616. private _velocityWorld;
  7617. private _normalizedVelocity;
  7618. /** @hidden */
  7619. _initialVelocity: Vector3;
  7620. /** @hidden */
  7621. _initialPosition: Vector3;
  7622. private _nearestDistance;
  7623. private _collisionMask;
  7624. get collisionMask(): number;
  7625. set collisionMask(mask: number);
  7626. /**
  7627. * Gets the plane normal used to compute the sliding response (in local space)
  7628. */
  7629. get slidePlaneNormal(): Vector3;
  7630. /** @hidden */
  7631. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7632. /** @hidden */
  7633. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7634. /** @hidden */
  7635. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7636. /** @hidden */
  7637. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7638. /** @hidden */
  7639. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7640. /** @hidden */
  7641. _getResponse(pos: Vector3, vel: Vector3): void;
  7642. }
  7643. }
  7644. declare module BABYLON {
  7645. /**
  7646. * Interface for cullable objects
  7647. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7648. */
  7649. export interface ICullable {
  7650. /**
  7651. * Checks if the object or part of the object is in the frustum
  7652. * @param frustumPlanes Camera near/planes
  7653. * @returns true if the object is in frustum otherwise false
  7654. */
  7655. isInFrustum(frustumPlanes: Plane[]): boolean;
  7656. /**
  7657. * Checks if a cullable object (mesh...) is in the camera frustum
  7658. * Unlike isInFrustum this checks the full bounding box
  7659. * @param frustumPlanes Camera near/planes
  7660. * @returns true if the object is in frustum otherwise false
  7661. */
  7662. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7663. }
  7664. /**
  7665. * Info for a bounding data of a mesh
  7666. */
  7667. export class BoundingInfo implements ICullable {
  7668. /**
  7669. * Bounding box for the mesh
  7670. */
  7671. readonly boundingBox: BoundingBox;
  7672. /**
  7673. * Bounding sphere for the mesh
  7674. */
  7675. readonly boundingSphere: BoundingSphere;
  7676. private _isLocked;
  7677. private static readonly TmpVector3;
  7678. /**
  7679. * Constructs bounding info
  7680. * @param minimum min vector of the bounding box/sphere
  7681. * @param maximum max vector of the bounding box/sphere
  7682. * @param worldMatrix defines the new world matrix
  7683. */
  7684. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7685. /**
  7686. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7687. * @param min defines the new minimum vector (in local space)
  7688. * @param max defines the new maximum vector (in local space)
  7689. * @param worldMatrix defines the new world matrix
  7690. */
  7691. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7692. /**
  7693. * min vector of the bounding box/sphere
  7694. */
  7695. get minimum(): Vector3;
  7696. /**
  7697. * max vector of the bounding box/sphere
  7698. */
  7699. get maximum(): Vector3;
  7700. /**
  7701. * If the info is locked and won't be updated to avoid perf overhead
  7702. */
  7703. get isLocked(): boolean;
  7704. set isLocked(value: boolean);
  7705. /**
  7706. * Updates the bounding sphere and box
  7707. * @param world world matrix to be used to update
  7708. */
  7709. update(world: DeepImmutable<Matrix>): void;
  7710. /**
  7711. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7712. * @param center New center of the bounding info
  7713. * @param extend New extend of the bounding info
  7714. * @returns the current bounding info
  7715. */
  7716. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7717. /**
  7718. * Grows the bounding info to include the given point.
  7719. * @param point The point that will be included in the current bounding info
  7720. * @returns the current bounding info
  7721. */
  7722. encapsulate(point: Vector3): BoundingInfo;
  7723. /**
  7724. * Grows the bounding info to encapsulate the given bounding info.
  7725. * @param toEncapsulate The bounding info that will be encapsulated in the current bounding info
  7726. * @returns the current bounding info
  7727. */
  7728. encapsulateBoundingInfo(toEncapsulate: BoundingInfo): BoundingInfo;
  7729. /**
  7730. * Scale the current bounding info by applying a scale factor
  7731. * @param factor defines the scale factor to apply
  7732. * @returns the current bounding info
  7733. */
  7734. scale(factor: number): BoundingInfo;
  7735. /**
  7736. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7737. * @param frustumPlanes defines the frustum to test
  7738. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7739. * @returns true if the bounding info is in the frustum planes
  7740. */
  7741. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7742. /**
  7743. * Gets the world distance between the min and max points of the bounding box
  7744. */
  7745. get diagonalLength(): number;
  7746. /**
  7747. * Checks if a cullable object (mesh...) is in the camera frustum
  7748. * Unlike isInFrustum this checks the full bounding box
  7749. * @param frustumPlanes Camera near/planes
  7750. * @returns true if the object is in frustum otherwise false
  7751. */
  7752. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7753. /** @hidden */
  7754. _checkCollision(collider: Collider): boolean;
  7755. /**
  7756. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7757. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7758. * @param point the point to check intersection with
  7759. * @returns if the point intersects
  7760. */
  7761. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7762. /**
  7763. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7764. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7765. * @param boundingInfo the bounding info to check intersection with
  7766. * @param precise if the intersection should be done using OBB
  7767. * @returns if the bounding info intersects
  7768. */
  7769. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7770. }
  7771. }
  7772. declare module BABYLON {
  7773. /**
  7774. * Extracts minimum and maximum values from a list of indexed positions
  7775. * @param positions defines the positions to use
  7776. * @param indices defines the indices to the positions
  7777. * @param indexStart defines the start index
  7778. * @param indexCount defines the end index
  7779. * @param bias defines bias value to add to the result
  7780. * @return minimum and maximum values
  7781. */
  7782. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7783. minimum: Vector3;
  7784. maximum: Vector3;
  7785. };
  7786. /**
  7787. * Extracts minimum and maximum values from a list of positions
  7788. * @param positions defines the positions to use
  7789. * @param start defines the start index in the positions array
  7790. * @param count defines the number of positions to handle
  7791. * @param bias defines bias value to add to the result
  7792. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7793. * @return minimum and maximum values
  7794. */
  7795. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7796. minimum: Vector3;
  7797. maximum: Vector3;
  7798. };
  7799. }
  7800. declare module BABYLON {
  7801. /**
  7802. * Class used to manipulate GUIDs
  7803. */
  7804. export class GUID {
  7805. /**
  7806. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  7807. * Be aware Math.random() could cause collisions, but:
  7808. * "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"
  7809. * @returns a pseudo random id
  7810. */
  7811. static RandomId(): string;
  7812. }
  7813. }
  7814. declare module BABYLON {
  7815. /**
  7816. * Base class of all the textures in babylon.
  7817. * It groups all the common properties the materials, post process, lights... might need
  7818. * in order to make a correct use of the texture.
  7819. */
  7820. export class BaseTexture extends ThinTexture implements IAnimatable {
  7821. /**
  7822. * Default anisotropic filtering level for the application.
  7823. * It is set to 4 as a good tradeoff between perf and quality.
  7824. */
  7825. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  7826. /**
  7827. * Gets or sets the unique id of the texture
  7828. */
  7829. uniqueId: number;
  7830. /**
  7831. * Define the name of the texture.
  7832. */
  7833. name: string;
  7834. /**
  7835. * Gets or sets an object used to store user defined information.
  7836. */
  7837. metadata: any;
  7838. /**
  7839. * For internal use only. Please do not use.
  7840. */
  7841. reservedDataStore: any;
  7842. private _hasAlpha;
  7843. /**
  7844. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  7845. */
  7846. set hasAlpha(value: boolean);
  7847. get hasAlpha(): boolean;
  7848. /**
  7849. * Defines if the alpha value should be determined via the rgb values.
  7850. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  7851. */
  7852. getAlphaFromRGB: boolean;
  7853. /**
  7854. * Intensity or strength of the texture.
  7855. * It is commonly used by materials to fine tune the intensity of the texture
  7856. */
  7857. level: number;
  7858. /**
  7859. * Define the UV channel to use starting from 0 and defaulting to 0.
  7860. * This is part of the texture as textures usually maps to one uv set.
  7861. */
  7862. coordinatesIndex: number;
  7863. protected _coordinatesMode: number;
  7864. /**
  7865. * How a texture is mapped.
  7866. *
  7867. * | Value | Type | Description |
  7868. * | ----- | ----------------------------------- | ----------- |
  7869. * | 0 | EXPLICIT_MODE | |
  7870. * | 1 | SPHERICAL_MODE | |
  7871. * | 2 | PLANAR_MODE | |
  7872. * | 3 | CUBIC_MODE | |
  7873. * | 4 | PROJECTION_MODE | |
  7874. * | 5 | SKYBOX_MODE | |
  7875. * | 6 | INVCUBIC_MODE | |
  7876. * | 7 | EQUIRECTANGULAR_MODE | |
  7877. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  7878. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  7879. */
  7880. set coordinatesMode(value: number);
  7881. get coordinatesMode(): number;
  7882. /**
  7883. * | Value | Type | Description |
  7884. * | ----- | ------------------ | ----------- |
  7885. * | 0 | CLAMP_ADDRESSMODE | |
  7886. * | 1 | WRAP_ADDRESSMODE | |
  7887. * | 2 | MIRROR_ADDRESSMODE | |
  7888. */
  7889. get wrapU(): number;
  7890. set wrapU(value: number);
  7891. /**
  7892. * | Value | Type | Description |
  7893. * | ----- | ------------------ | ----------- |
  7894. * | 0 | CLAMP_ADDRESSMODE | |
  7895. * | 1 | WRAP_ADDRESSMODE | |
  7896. * | 2 | MIRROR_ADDRESSMODE | |
  7897. */
  7898. get wrapV(): number;
  7899. set wrapV(value: number);
  7900. /**
  7901. * | Value | Type | Description |
  7902. * | ----- | ------------------ | ----------- |
  7903. * | 0 | CLAMP_ADDRESSMODE | |
  7904. * | 1 | WRAP_ADDRESSMODE | |
  7905. * | 2 | MIRROR_ADDRESSMODE | |
  7906. */
  7907. wrapR: number;
  7908. /**
  7909. * With compliant hardware and browser (supporting anisotropic filtering)
  7910. * this defines the level of anisotropic filtering in the texture.
  7911. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  7912. */
  7913. anisotropicFilteringLevel: number;
  7914. private _isCube;
  7915. /**
  7916. * Define if the texture is a cube texture or if false a 2d texture.
  7917. */
  7918. get isCube(): boolean;
  7919. set isCube(value: boolean);
  7920. /**
  7921. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  7922. */
  7923. get is3D(): boolean;
  7924. set is3D(value: boolean);
  7925. /**
  7926. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  7927. */
  7928. get is2DArray(): boolean;
  7929. set is2DArray(value: boolean);
  7930. private _gammaSpace;
  7931. /**
  7932. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  7933. * HDR texture are usually stored in linear space.
  7934. * This only impacts the PBR and Background materials
  7935. */
  7936. get gammaSpace(): boolean;
  7937. set gammaSpace(gamma: boolean);
  7938. /**
  7939. * Gets or sets whether or not the texture contains RGBD data.
  7940. */
  7941. get isRGBD(): boolean;
  7942. set isRGBD(value: boolean);
  7943. /**
  7944. * Is Z inverted in the texture (useful in a cube texture).
  7945. */
  7946. invertZ: boolean;
  7947. /**
  7948. * Are mip maps generated for this texture or not.
  7949. */
  7950. get noMipmap(): boolean;
  7951. /**
  7952. * @hidden
  7953. */
  7954. lodLevelInAlpha: boolean;
  7955. /**
  7956. * With prefiltered texture, defined the offset used during the prefiltering steps.
  7957. */
  7958. get lodGenerationOffset(): number;
  7959. set lodGenerationOffset(value: number);
  7960. /**
  7961. * With prefiltered texture, defined the scale used during the prefiltering steps.
  7962. */
  7963. get lodGenerationScale(): number;
  7964. set lodGenerationScale(value: number);
  7965. /**
  7966. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  7967. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  7968. * average roughness values.
  7969. */
  7970. get linearSpecularLOD(): boolean;
  7971. set linearSpecularLOD(value: boolean);
  7972. /**
  7973. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  7974. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  7975. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  7976. */
  7977. get irradianceTexture(): Nullable<BaseTexture>;
  7978. set irradianceTexture(value: Nullable<BaseTexture>);
  7979. /**
  7980. * Define if the texture is a render target.
  7981. */
  7982. isRenderTarget: boolean;
  7983. /**
  7984. * Define the unique id of the texture in the scene.
  7985. */
  7986. get uid(): string;
  7987. /** @hidden */
  7988. _prefiltered: boolean;
  7989. /**
  7990. * Return a string representation of the texture.
  7991. * @returns the texture as a string
  7992. */
  7993. toString(): string;
  7994. /**
  7995. * Get the class name of the texture.
  7996. * @returns "BaseTexture"
  7997. */
  7998. getClassName(): string;
  7999. /**
  8000. * Define the list of animation attached to the texture.
  8001. */
  8002. animations: Animation[];
  8003. /**
  8004. * An event triggered when the texture is disposed.
  8005. */
  8006. onDisposeObservable: Observable<BaseTexture>;
  8007. private _onDisposeObserver;
  8008. /**
  8009. * Callback triggered when the texture has been disposed.
  8010. * Kept for back compatibility, you can use the onDisposeObservable instead.
  8011. */
  8012. set onDispose(callback: () => void);
  8013. protected _scene: Nullable<Scene>;
  8014. /** @hidden */
  8015. _texture: Nullable<InternalTexture>;
  8016. private _uid;
  8017. /**
  8018. * Define if the texture is preventing a material to render or not.
  8019. * If not and the texture is not ready, the engine will use a default black texture instead.
  8020. */
  8021. get isBlocking(): boolean;
  8022. /**
  8023. * Instantiates a new BaseTexture.
  8024. * Base class of all the textures in babylon.
  8025. * It groups all the common properties the materials, post process, lights... might need
  8026. * in order to make a correct use of the texture.
  8027. * @param sceneOrEngine Define the scene or engine the texture belongs to
  8028. */
  8029. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  8030. /**
  8031. * Get the scene the texture belongs to.
  8032. * @returns the scene or null if undefined
  8033. */
  8034. getScene(): Nullable<Scene>;
  8035. /** @hidden */
  8036. protected _getEngine(): Nullable<ThinEngine>;
  8037. /**
  8038. * Checks if the texture has the same transform matrix than another texture
  8039. * @param texture texture to check against
  8040. * @returns true if the transforms are the same, else false
  8041. */
  8042. checkTransformsAreIdentical(texture: Nullable<BaseTexture>): boolean;
  8043. /**
  8044. * Get the texture transform matrix used to offset tile the texture for instance.
  8045. * @returns the transformation matrix
  8046. */
  8047. getTextureMatrix(): Matrix;
  8048. /**
  8049. * Get the texture reflection matrix used to rotate/transform the reflection.
  8050. * @returns the reflection matrix
  8051. */
  8052. getReflectionTextureMatrix(): Matrix;
  8053. /**
  8054. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  8055. * @returns true if ready or not blocking
  8056. */
  8057. isReadyOrNotBlocking(): boolean;
  8058. /**
  8059. * Scales the texture if is `canRescale()`
  8060. * @param ratio the resize factor we want to use to rescale
  8061. */
  8062. scale(ratio: number): void;
  8063. /**
  8064. * Get if the texture can rescale.
  8065. */
  8066. get canRescale(): boolean;
  8067. /** @hidden */
  8068. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  8069. /** @hidden */
  8070. _rebuild(): void;
  8071. /**
  8072. * Clones the texture.
  8073. * @returns the cloned texture
  8074. */
  8075. clone(): Nullable<BaseTexture>;
  8076. /**
  8077. * Get the texture underlying type (INT, FLOAT...)
  8078. */
  8079. get textureType(): number;
  8080. /**
  8081. * Get the texture underlying format (RGB, RGBA...)
  8082. */
  8083. get textureFormat(): number;
  8084. /**
  8085. * Indicates that textures need to be re-calculated for all materials
  8086. */
  8087. protected _markAllSubMeshesAsTexturesDirty(): void;
  8088. /**
  8089. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  8090. * This will returns an RGBA array buffer containing either in values (0-255) or
  8091. * float values (0-1) depending of the underlying buffer type.
  8092. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  8093. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  8094. * @param buffer defines a user defined buffer to fill with data (can be null)
  8095. * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels
  8096. * @returns The Array buffer promise containing the pixels data.
  8097. */
  8098. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Nullable<Promise<ArrayBufferView>>;
  8099. /** @hidden */
  8100. _readPixelsSync(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Nullable<ArrayBufferView>;
  8101. /** @hidden */
  8102. get _lodTextureHigh(): Nullable<BaseTexture>;
  8103. /** @hidden */
  8104. get _lodTextureMid(): Nullable<BaseTexture>;
  8105. /** @hidden */
  8106. get _lodTextureLow(): Nullable<BaseTexture>;
  8107. /**
  8108. * Dispose the texture and release its associated resources.
  8109. */
  8110. dispose(): void;
  8111. /**
  8112. * Serialize the texture into a JSON representation that can be parsed later on.
  8113. * @returns the JSON representation of the texture
  8114. */
  8115. serialize(): any;
  8116. /**
  8117. * Helper function to be called back once a list of texture contains only ready textures.
  8118. * @param textures Define the list of textures to wait for
  8119. * @param callback Define the callback triggered once the entire list will be ready
  8120. */
  8121. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  8122. private static _isScene;
  8123. }
  8124. }
  8125. declare module BABYLON {
  8126. /** @hidden */
  8127. export class WebGLDataBuffer extends DataBuffer {
  8128. private _buffer;
  8129. constructor(resource: WebGLBuffer);
  8130. get underlyingResource(): any;
  8131. }
  8132. }
  8133. declare module BABYLON {
  8134. /** @hidden */
  8135. export class WebGLPipelineContext implements IPipelineContext {
  8136. private _valueCache;
  8137. private _uniforms;
  8138. engine: ThinEngine;
  8139. program: Nullable<WebGLProgram>;
  8140. context?: WebGLRenderingContext;
  8141. vertexShader?: WebGLShader;
  8142. fragmentShader?: WebGLShader;
  8143. isParallelCompiled: boolean;
  8144. onCompiled?: () => void;
  8145. transformFeedback?: WebGLTransformFeedback | null;
  8146. vertexCompilationError: Nullable<string>;
  8147. fragmentCompilationError: Nullable<string>;
  8148. programLinkError: Nullable<string>;
  8149. programValidationError: Nullable<string>;
  8150. get isAsync(): boolean;
  8151. get isReady(): boolean;
  8152. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  8153. _fillEffectInformation(effect: Effect, uniformBuffersNames: {
  8154. [key: string]: number;
  8155. }, uniformsNames: string[], uniforms: {
  8156. [key: string]: Nullable<WebGLUniformLocation>;
  8157. }, samplerList: string[], samplers: {
  8158. [key: string]: number;
  8159. }, attributesNames: string[], attributes: number[]): void;
  8160. /**
  8161. * Release all associated resources.
  8162. **/
  8163. dispose(): void;
  8164. /** @hidden */
  8165. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  8166. /** @hidden */
  8167. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  8168. /** @hidden */
  8169. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  8170. /** @hidden */
  8171. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  8172. /**
  8173. * Sets an integer value on a uniform variable.
  8174. * @param uniformName Name of the variable.
  8175. * @param value Value to be set.
  8176. */
  8177. setInt(uniformName: string, value: number): void;
  8178. /**
  8179. * Sets a int2 on a uniform variable.
  8180. * @param uniformName Name of the variable.
  8181. * @param x First int in int2.
  8182. * @param y Second int in int2.
  8183. */
  8184. setInt2(uniformName: string, x: number, y: number): void;
  8185. /**
  8186. * Sets a int3 on a uniform variable.
  8187. * @param uniformName Name of the variable.
  8188. * @param x First int in int3.
  8189. * @param y Second int in int3.
  8190. * @param y Third int in int3.
  8191. */
  8192. setInt3(uniformName: string, x: number, y: number, z: number): void;
  8193. /**
  8194. * Sets a int4 on a uniform variable.
  8195. * @param uniformName Name of the variable.
  8196. * @param x First int in int4.
  8197. * @param y Second int in int4.
  8198. * @param y Third int in int4.
  8199. * @param w Fourth int in int4.
  8200. */
  8201. setInt4(uniformName: string, x: number, y: number, z: number, w: number): void;
  8202. /**
  8203. * Sets an int array on a uniform variable.
  8204. * @param uniformName Name of the variable.
  8205. * @param array array to be set.
  8206. */
  8207. setIntArray(uniformName: string, array: Int32Array): void;
  8208. /**
  8209. * 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)
  8210. * @param uniformName Name of the variable.
  8211. * @param array array to be set.
  8212. */
  8213. setIntArray2(uniformName: string, array: Int32Array): void;
  8214. /**
  8215. * 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)
  8216. * @param uniformName Name of the variable.
  8217. * @param array array to be set.
  8218. */
  8219. setIntArray3(uniformName: string, array: Int32Array): void;
  8220. /**
  8221. * 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)
  8222. * @param uniformName Name of the variable.
  8223. * @param array array to be set.
  8224. */
  8225. setIntArray4(uniformName: string, array: Int32Array): void;
  8226. /**
  8227. * Sets an array on a uniform variable.
  8228. * @param uniformName Name of the variable.
  8229. * @param array array to be set.
  8230. */
  8231. setArray(uniformName: string, array: number[]): void;
  8232. /**
  8233. * 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)
  8234. * @param uniformName Name of the variable.
  8235. * @param array array to be set.
  8236. */
  8237. setArray2(uniformName: string, array: number[]): void;
  8238. /**
  8239. * 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)
  8240. * @param uniformName Name of the variable.
  8241. * @param array array to be set.
  8242. * @returns this effect.
  8243. */
  8244. setArray3(uniformName: string, array: number[]): void;
  8245. /**
  8246. * 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)
  8247. * @param uniformName Name of the variable.
  8248. * @param array array to be set.
  8249. */
  8250. setArray4(uniformName: string, array: number[]): void;
  8251. /**
  8252. * Sets matrices on a uniform variable.
  8253. * @param uniformName Name of the variable.
  8254. * @param matrices matrices to be set.
  8255. */
  8256. setMatrices(uniformName: string, matrices: Float32Array): void;
  8257. /**
  8258. * Sets matrix on a uniform variable.
  8259. * @param uniformName Name of the variable.
  8260. * @param matrix matrix to be set.
  8261. */
  8262. setMatrix(uniformName: string, matrix: IMatrixLike): void;
  8263. /**
  8264. * 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)
  8265. * @param uniformName Name of the variable.
  8266. * @param matrix matrix to be set.
  8267. */
  8268. setMatrix3x3(uniformName: string, matrix: Float32Array): void;
  8269. /**
  8270. * Sets a 2x2 matrix on a uniform variable. (Specified as [1,2,3,4] will result in [1,2][3,4] matrix)
  8271. * @param uniformName Name of the variable.
  8272. * @param matrix matrix to be set.
  8273. */
  8274. setMatrix2x2(uniformName: string, matrix: Float32Array): void;
  8275. /**
  8276. * Sets a float on a uniform variable.
  8277. * @param uniformName Name of the variable.
  8278. * @param value value to be set.
  8279. * @returns this effect.
  8280. */
  8281. setFloat(uniformName: string, value: number): void;
  8282. /**
  8283. * Sets a Vector2 on a uniform variable.
  8284. * @param uniformName Name of the variable.
  8285. * @param vector2 vector2 to be set.
  8286. */
  8287. setVector2(uniformName: string, vector2: IVector2Like): void;
  8288. /**
  8289. * Sets a float2 on a uniform variable.
  8290. * @param uniformName Name of the variable.
  8291. * @param x First float in float2.
  8292. * @param y Second float in float2.
  8293. */
  8294. setFloat2(uniformName: string, x: number, y: number): void;
  8295. /**
  8296. * Sets a Vector3 on a uniform variable.
  8297. * @param uniformName Name of the variable.
  8298. * @param vector3 Value to be set.
  8299. */
  8300. setVector3(uniformName: string, vector3: IVector3Like): void;
  8301. /**
  8302. * Sets a float3 on a uniform variable.
  8303. * @param uniformName Name of the variable.
  8304. * @param x First float in float3.
  8305. * @param y Second float in float3.
  8306. * @param z Third float in float3.
  8307. */
  8308. setFloat3(uniformName: string, x: number, y: number, z: number): void;
  8309. /**
  8310. * Sets a Vector4 on a uniform variable.
  8311. * @param uniformName Name of the variable.
  8312. * @param vector4 Value to be set.
  8313. */
  8314. setVector4(uniformName: string, vector4: IVector4Like): void;
  8315. /**
  8316. * Sets a float4 on a uniform variable.
  8317. * @param uniformName Name of the variable.
  8318. * @param x First float in float4.
  8319. * @param y Second float in float4.
  8320. * @param z Third float in float4.
  8321. * @param w Fourth float in float4.
  8322. * @returns this effect.
  8323. */
  8324. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): void;
  8325. /**
  8326. * Sets a Color3 on a uniform variable.
  8327. * @param uniformName Name of the variable.
  8328. * @param color3 Value to be set.
  8329. */
  8330. setColor3(uniformName: string, color3: IColor3Like): void;
  8331. /**
  8332. * Sets a Color4 on a uniform variable.
  8333. * @param uniformName Name of the variable.
  8334. * @param color3 Value to be set.
  8335. * @param alpha Alpha value to be set.
  8336. */
  8337. setColor4(uniformName: string, color3: IColor3Like, alpha: number): void;
  8338. /**
  8339. * Sets a Color4 on a uniform variable
  8340. * @param uniformName defines the name of the variable
  8341. * @param color4 defines the value to be set
  8342. */
  8343. setDirectColor4(uniformName: string, color4: IColor4Like): void;
  8344. _getVertexShaderCode(): string | null;
  8345. _getFragmentShaderCode(): string | null;
  8346. }
  8347. }
  8348. declare module BABYLON {
  8349. interface ThinEngine {
  8350. /**
  8351. * Create an uniform buffer
  8352. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8353. * @param elements defines the content of the uniform buffer
  8354. * @returns the webGL uniform buffer
  8355. */
  8356. createUniformBuffer(elements: FloatArray): DataBuffer;
  8357. /**
  8358. * Create a dynamic uniform buffer
  8359. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8360. * @param elements defines the content of the uniform buffer
  8361. * @returns the webGL uniform buffer
  8362. */
  8363. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  8364. /**
  8365. * Update an existing uniform buffer
  8366. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8367. * @param uniformBuffer defines the target uniform buffer
  8368. * @param elements defines the content to update
  8369. * @param offset defines the offset in the uniform buffer where update should start
  8370. * @param count defines the size of the data to update
  8371. */
  8372. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  8373. /**
  8374. * Bind an uniform buffer to the current webGL context
  8375. * @param buffer defines the buffer to bind
  8376. */
  8377. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  8378. /**
  8379. * Bind a buffer to the current webGL context at a given location
  8380. * @param buffer defines the buffer to bind
  8381. * @param location defines the index where to bind the buffer
  8382. * @param name Name of the uniform variable to bind
  8383. */
  8384. bindUniformBufferBase(buffer: DataBuffer, location: number, name: string): void;
  8385. /**
  8386. * Bind a specific block at a given index in a specific shader program
  8387. * @param pipelineContext defines the pipeline context to use
  8388. * @param blockName defines the block name
  8389. * @param index defines the index where to bind the block
  8390. */
  8391. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  8392. }
  8393. }
  8394. declare module BABYLON {
  8395. /**
  8396. * Uniform buffer objects.
  8397. *
  8398. * Handles blocks of uniform on the GPU.
  8399. *
  8400. * If WebGL 2 is not available, this class falls back on traditional setUniformXXX calls.
  8401. *
  8402. * For more information, please refer to :
  8403. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  8404. */
  8405. export class UniformBuffer {
  8406. /** @hidden */
  8407. static _updatedUbosInFrame: {
  8408. [name: string]: number;
  8409. };
  8410. private _engine;
  8411. private _buffer;
  8412. private _buffers;
  8413. private _bufferIndex;
  8414. private _createBufferOnWrite;
  8415. private _data;
  8416. private _bufferData;
  8417. private _dynamic?;
  8418. private _uniformLocations;
  8419. private _uniformSizes;
  8420. private _uniformArraySizes;
  8421. private _uniformLocationPointer;
  8422. private _needSync;
  8423. private _noUBO;
  8424. private _currentEffect;
  8425. private _currentEffectName;
  8426. private _name;
  8427. private _currentFrameId;
  8428. /** @hidden */
  8429. _alreadyBound: boolean;
  8430. private static _MAX_UNIFORM_SIZE;
  8431. private static _tempBuffer;
  8432. private static _tempBufferInt32View;
  8433. /**
  8434. * Lambda to Update a 3x3 Matrix 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. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  8439. /**
  8440. * Lambda to Update a 2x2 Matrix 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. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  8445. /**
  8446. * Lambda to Update a single float 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. updateFloat: (name: string, x: number) => void;
  8451. /**
  8452. * Lambda to Update a vec2 of float 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. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  8457. /**
  8458. * Lambda to Update a vec3 of float 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. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  8463. /**
  8464. * Lambda to Update a vec4 of float 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. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  8469. /**
  8470. * Lambda to Update an array of float 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. updateFloatArray: (name: string, array: Float32Array) => void;
  8475. /**
  8476. * Lambda to Update an array of number 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. updateArray: (name: string, array: number[]) => void;
  8481. /**
  8482. * Lambda to Update an array of number 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. updateIntArray: (name: string, array: Int32Array) => void;
  8487. /**
  8488. * Lambda to Update a 4x4 Matrix 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. updateMatrix: (name: string, mat: IMatrixLike) => void;
  8493. /**
  8494. * Lambda to Update an array of 4x4 Matrix in 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. updateMatrices: (name: string, mat: Float32Array) => void;
  8499. /**
  8500. * Lambda to Update vec3 of float from a Vector 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. updateVector3: (name: string, vector: Vector3) => void;
  8505. /**
  8506. * Lambda to Update vec4 of float from a Vector 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. updateVector4: (name: string, vector: Vector4) => void;
  8511. /**
  8512. * Lambda to Update vec3 of float from a Color 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. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  8517. /**
  8518. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  8519. * This is dynamic to allow compat with webgl 1 and 2.
  8520. * You will need to pass the name of the uniform as well as the value.
  8521. */
  8522. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  8523. /**
  8524. * Lambda to Update a int a uniform buffer.
  8525. * This is dynamic to allow compat with webgl 1 and 2.
  8526. * You will need to pass the name of the uniform as well as the value.
  8527. */
  8528. updateInt: (name: string, x: number, suffix?: string) => void;
  8529. /**
  8530. * Lambda to Update a vec2 of int in a uniform buffer.
  8531. * This is dynamic to allow compat with webgl 1 and 2.
  8532. * You will need to pass the name of the uniform as well as the value.
  8533. */
  8534. updateInt2: (name: string, x: number, y: number, suffix?: string) => void;
  8535. /**
  8536. * Lambda to Update a vec3 of int in a uniform buffer.
  8537. * This is dynamic to allow compat with webgl 1 and 2.
  8538. * You will need to pass the name of the uniform as well as the value.
  8539. */
  8540. updateInt3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  8541. /**
  8542. * Lambda to Update a vec4 of int in a uniform buffer.
  8543. * This is dynamic to allow compat with webgl 1 and 2.
  8544. * You will need to pass the name of the uniform as well as the value.
  8545. */
  8546. updateInt4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  8547. /**
  8548. * Instantiates a new Uniform buffer objects.
  8549. *
  8550. * Handles blocks of uniform on the GPU.
  8551. *
  8552. * If WebGL 2 is not available, this class falls back on traditional setUniformXXX calls.
  8553. *
  8554. * For more information, please refer to :
  8555. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  8556. * @param engine Define the engine the buffer is associated with
  8557. * @param data Define the data contained in the buffer
  8558. * @param dynamic Define if the buffer is updatable
  8559. * @param name to assign to the buffer (debugging purpose)
  8560. */
  8561. constructor(engine: Engine, data?: number[], dynamic?: boolean, name?: string);
  8562. /**
  8563. * Indicates if the buffer is using the WebGL2 UBO implementation,
  8564. * or just falling back on setUniformXXX calls.
  8565. */
  8566. get useUbo(): boolean;
  8567. /**
  8568. * Indicates if the WebGL underlying uniform buffer is in sync
  8569. * with the javascript cache data.
  8570. */
  8571. get isSync(): boolean;
  8572. /**
  8573. * Indicates if the WebGL underlying uniform buffer is dynamic.
  8574. * Also, a dynamic UniformBuffer will disable cache verification and always
  8575. * update the underlying WebGL uniform buffer to the GPU.
  8576. * @returns if Dynamic, otherwise false
  8577. */
  8578. isDynamic(): boolean;
  8579. /**
  8580. * The data cache on JS side.
  8581. * @returns the underlying data as a float array
  8582. */
  8583. getData(): Float32Array;
  8584. /**
  8585. * The underlying WebGL Uniform buffer.
  8586. * @returns the webgl buffer
  8587. */
  8588. getBuffer(): Nullable<DataBuffer>;
  8589. /**
  8590. * std140 layout specifies how to align data within an UBO structure.
  8591. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  8592. * for specs.
  8593. */
  8594. private _fillAlignment;
  8595. /**
  8596. * Adds an uniform in the buffer.
  8597. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  8598. * for the layout to be correct !
  8599. * @param name Name of the uniform, as used in the uniform block in the shader.
  8600. * @param size Data size, or data directly.
  8601. * @param arraySize The number of elements in the array, 0 if not an array.
  8602. */
  8603. addUniform(name: string, size: number | number[], arraySize?: number): void;
  8604. /**
  8605. * Adds a Matrix 4x4 to the uniform buffer.
  8606. * @param name Name of the uniform, as used in the uniform block in the shader.
  8607. * @param mat A 4x4 matrix.
  8608. */
  8609. addMatrix(name: string, mat: Matrix): void;
  8610. /**
  8611. * Adds a vec2 to the uniform buffer.
  8612. * @param name Name of the uniform, as used in the uniform block in the shader.
  8613. * @param x Define the x component value of the vec2
  8614. * @param y Define the y component value of the vec2
  8615. */
  8616. addFloat2(name: string, x: number, y: number): void;
  8617. /**
  8618. * Adds a vec3 to the uniform buffer.
  8619. * @param name Name of the uniform, as used in the uniform block in the shader.
  8620. * @param x Define the x component value of the vec3
  8621. * @param y Define the y component value of the vec3
  8622. * @param z Define the z component value of the vec3
  8623. */
  8624. addFloat3(name: string, x: number, y: number, z: number): void;
  8625. /**
  8626. * Adds a vec3 to the uniform buffer.
  8627. * @param name Name of the uniform, as used in the uniform block in the shader.
  8628. * @param color Define the vec3 from a Color
  8629. */
  8630. addColor3(name: string, color: Color3): void;
  8631. /**
  8632. * Adds a vec4 to the uniform buffer.
  8633. * @param name Name of the uniform, as used in the uniform block in the shader.
  8634. * @param color Define the rgb components from a Color
  8635. * @param alpha Define the a component of the vec4
  8636. */
  8637. addColor4(name: string, color: Color3, alpha: number): void;
  8638. /**
  8639. * Adds a vec3 to the uniform buffer.
  8640. * @param name Name of the uniform, as used in the uniform block in the shader.
  8641. * @param vector Define the vec3 components from a Vector
  8642. */
  8643. addVector3(name: string, vector: Vector3): void;
  8644. /**
  8645. * Adds a Matrix 3x3 to the uniform buffer.
  8646. * @param name Name of the uniform, as used in the uniform block in the shader.
  8647. */
  8648. addMatrix3x3(name: string): void;
  8649. /**
  8650. * Adds a Matrix 2x2 to the uniform buffer.
  8651. * @param name Name of the uniform, as used in the uniform block in the shader.
  8652. */
  8653. addMatrix2x2(name: string): void;
  8654. /**
  8655. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  8656. */
  8657. create(): void;
  8658. /** @hidden */
  8659. _rebuild(): void;
  8660. /** @hidden */
  8661. get _numBuffers(): number;
  8662. /** @hidden */
  8663. get _indexBuffer(): number;
  8664. /** Gets the name of this buffer */
  8665. get name(): string;
  8666. /**
  8667. * Updates the WebGL Uniform Buffer on the GPU.
  8668. * If the `dynamic` flag is set to true, no cache comparison is done.
  8669. * Otherwise, the buffer will be updated only if the cache differs.
  8670. */
  8671. update(): void;
  8672. private _createNewBuffer;
  8673. private _checkNewFrame;
  8674. /**
  8675. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  8676. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  8677. * @param data Define the flattened data
  8678. * @param size Define the size of the data.
  8679. */
  8680. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  8681. /**
  8682. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  8683. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  8684. * @param data Define the flattened data
  8685. * @param size Define the size of the data.
  8686. */
  8687. updateUniformArray(uniformName: string, data: FloatArray, size: number): void;
  8688. private _valueCache;
  8689. private _cacheMatrix;
  8690. private _updateMatrix3x3ForUniform;
  8691. private _updateMatrix3x3ForEffect;
  8692. private _updateMatrix2x2ForEffect;
  8693. private _updateMatrix2x2ForUniform;
  8694. private _updateFloatForEffect;
  8695. private _updateFloatForUniform;
  8696. private _updateFloat2ForEffect;
  8697. private _updateFloat2ForUniform;
  8698. private _updateFloat3ForEffect;
  8699. private _updateFloat3ForUniform;
  8700. private _updateFloat4ForEffect;
  8701. private _updateFloat4ForUniform;
  8702. private _updateFloatArrayForEffect;
  8703. private _updateFloatArrayForUniform;
  8704. private _updateArrayForEffect;
  8705. private _updateArrayForUniform;
  8706. private _updateIntArrayForEffect;
  8707. private _updateIntArrayForUniform;
  8708. private _updateMatrixForEffect;
  8709. private _updateMatrixForUniform;
  8710. private _updateMatricesForEffect;
  8711. private _updateMatricesForUniform;
  8712. private _updateVector3ForEffect;
  8713. private _updateVector3ForUniform;
  8714. private _updateVector4ForEffect;
  8715. private _updateVector4ForUniform;
  8716. private _updateColor3ForEffect;
  8717. private _updateColor3ForUniform;
  8718. private _updateColor4ForEffect;
  8719. private _updateColor4ForUniform;
  8720. private _updateIntForEffect;
  8721. private _updateIntForUniform;
  8722. private _updateInt2ForEffect;
  8723. private _updateInt2ForUniform;
  8724. private _updateInt3ForEffect;
  8725. private _updateInt3ForUniform;
  8726. private _updateInt4ForEffect;
  8727. private _updateInt4ForUniform;
  8728. /**
  8729. * Sets a sampler uniform on the effect.
  8730. * @param name Define the name of the sampler.
  8731. * @param texture Define the texture to set in the sampler
  8732. */
  8733. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  8734. /**
  8735. * Directly updates the value of the uniform in the cache AND on the GPU.
  8736. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  8737. * @param data Define the flattened data
  8738. */
  8739. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  8740. /**
  8741. * Binds this uniform buffer to an effect.
  8742. * @param effect Define the effect to bind the buffer to
  8743. * @param name Name of the uniform block in the shader.
  8744. */
  8745. bindToEffect(effect: Effect, name: string): void;
  8746. /**
  8747. * Disposes the uniform buffer.
  8748. */
  8749. dispose(): void;
  8750. }
  8751. }
  8752. declare module BABYLON {
  8753. /**
  8754. * Manages the defines for the Material
  8755. */
  8756. export class MaterialDefines {
  8757. /** @hidden */
  8758. protected _keys: string[];
  8759. private _isDirty;
  8760. /** @hidden */
  8761. _renderId: number;
  8762. /** @hidden */
  8763. _areLightsDirty: boolean;
  8764. /** @hidden */
  8765. _areLightsDisposed: boolean;
  8766. /** @hidden */
  8767. _areAttributesDirty: boolean;
  8768. /** @hidden */
  8769. _areTexturesDirty: boolean;
  8770. /** @hidden */
  8771. _areFresnelDirty: boolean;
  8772. /** @hidden */
  8773. _areMiscDirty: boolean;
  8774. /** @hidden */
  8775. _arePrePassDirty: boolean;
  8776. /** @hidden */
  8777. _areImageProcessingDirty: boolean;
  8778. /** @hidden */
  8779. _normals: boolean;
  8780. /** @hidden */
  8781. _uvs: boolean;
  8782. /** @hidden */
  8783. _needNormals: boolean;
  8784. /** @hidden */
  8785. _needUVs: boolean;
  8786. [id: string]: any;
  8787. /**
  8788. * Specifies if the material needs to be re-calculated
  8789. */
  8790. get isDirty(): boolean;
  8791. /**
  8792. * Marks the material to indicate that it has been re-calculated
  8793. */
  8794. markAsProcessed(): void;
  8795. /**
  8796. * Marks the material to indicate that it needs to be re-calculated
  8797. */
  8798. markAsUnprocessed(): void;
  8799. /**
  8800. * Marks the material to indicate all of its defines need to be re-calculated
  8801. */
  8802. markAllAsDirty(): void;
  8803. /**
  8804. * Marks the material to indicate that image processing needs to be re-calculated
  8805. */
  8806. markAsImageProcessingDirty(): void;
  8807. /**
  8808. * Marks the material to indicate the lights need to be re-calculated
  8809. * @param disposed Defines whether the light is dirty due to dispose or not
  8810. */
  8811. markAsLightDirty(disposed?: boolean): void;
  8812. /**
  8813. * Marks the attribute state as changed
  8814. */
  8815. markAsAttributesDirty(): void;
  8816. /**
  8817. * Marks the texture state as changed
  8818. */
  8819. markAsTexturesDirty(): void;
  8820. /**
  8821. * Marks the fresnel state as changed
  8822. */
  8823. markAsFresnelDirty(): void;
  8824. /**
  8825. * Marks the misc state as changed
  8826. */
  8827. markAsMiscDirty(): void;
  8828. /**
  8829. * Marks the prepass state as changed
  8830. */
  8831. markAsPrePassDirty(): void;
  8832. /**
  8833. * Rebuilds the material defines
  8834. */
  8835. rebuild(): void;
  8836. /**
  8837. * Specifies if two material defines are equal
  8838. * @param other - A material define instance to compare to
  8839. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8840. */
  8841. isEqual(other: MaterialDefines): boolean;
  8842. /**
  8843. * Clones this instance's defines to another instance
  8844. * @param other - material defines to clone values to
  8845. */
  8846. cloneTo(other: MaterialDefines): void;
  8847. /**
  8848. * Resets the material define values
  8849. */
  8850. reset(): void;
  8851. /**
  8852. * Converts the material define values to a string
  8853. * @returns - String of material define information
  8854. */
  8855. toString(): string;
  8856. }
  8857. }
  8858. declare module BABYLON {
  8859. /**
  8860. * Enum that determines the text-wrapping mode to use.
  8861. */
  8862. export enum InspectableType {
  8863. /**
  8864. * Checkbox for booleans
  8865. */
  8866. Checkbox = 0,
  8867. /**
  8868. * Sliders for numbers
  8869. */
  8870. Slider = 1,
  8871. /**
  8872. * Vector3
  8873. */
  8874. Vector3 = 2,
  8875. /**
  8876. * Quaternions
  8877. */
  8878. Quaternion = 3,
  8879. /**
  8880. * Color3
  8881. */
  8882. Color3 = 4,
  8883. /**
  8884. * String
  8885. */
  8886. String = 5
  8887. }
  8888. /**
  8889. * Interface used to define custom inspectable properties.
  8890. * This interface is used by the inspector to display custom property grids
  8891. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8892. */
  8893. export interface IInspectable {
  8894. /**
  8895. * Gets the label to display
  8896. */
  8897. label: string;
  8898. /**
  8899. * Gets the name of the property to edit
  8900. */
  8901. propertyName: string;
  8902. /**
  8903. * Gets the type of the editor to use
  8904. */
  8905. type: InspectableType;
  8906. /**
  8907. * Gets the minimum value of the property when using in "slider" mode
  8908. */
  8909. min?: number;
  8910. /**
  8911. * Gets the maximum value of the property when using in "slider" mode
  8912. */
  8913. max?: number;
  8914. /**
  8915. * Gets the setp to use when using in "slider" mode
  8916. */
  8917. step?: number;
  8918. }
  8919. }
  8920. declare module BABYLON {
  8921. /**
  8922. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  8923. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  8924. * 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.
  8925. */
  8926. export abstract class Light extends Node {
  8927. /**
  8928. * Falloff Default: light is falling off following the material specification:
  8929. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  8930. */
  8931. static readonly FALLOFF_DEFAULT: number;
  8932. /**
  8933. * Falloff Physical: light is falling off following the inverse squared distance law.
  8934. */
  8935. static readonly FALLOFF_PHYSICAL: number;
  8936. /**
  8937. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  8938. * to enhance interoperability with other engines.
  8939. */
  8940. static readonly FALLOFF_GLTF: number;
  8941. /**
  8942. * Falloff Standard: light is falling off like in the standard material
  8943. * to enhance interoperability with other materials.
  8944. */
  8945. static readonly FALLOFF_STANDARD: number;
  8946. /**
  8947. * If every light affecting the material is in this lightmapMode,
  8948. * material.lightmapTexture adds or multiplies
  8949. * (depends on material.useLightmapAsShadowmap)
  8950. * after every other light calculations.
  8951. */
  8952. static readonly LIGHTMAP_DEFAULT: number;
  8953. /**
  8954. * material.lightmapTexture as only diffuse lighting from this light
  8955. * adds only specular lighting from this light
  8956. * adds dynamic shadows
  8957. */
  8958. static readonly LIGHTMAP_SPECULAR: number;
  8959. /**
  8960. * material.lightmapTexture as only lighting
  8961. * no light calculation from this light
  8962. * only adds dynamic shadows from this light
  8963. */
  8964. static readonly LIGHTMAP_SHADOWSONLY: number;
  8965. /**
  8966. * Each light type uses the default quantity according to its type:
  8967. * point/spot lights use luminous intensity
  8968. * directional lights use illuminance
  8969. */
  8970. static readonly INTENSITYMODE_AUTOMATIC: number;
  8971. /**
  8972. * lumen (lm)
  8973. */
  8974. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  8975. /**
  8976. * candela (lm/sr)
  8977. */
  8978. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  8979. /**
  8980. * lux (lm/m^2)
  8981. */
  8982. static readonly INTENSITYMODE_ILLUMINANCE: number;
  8983. /**
  8984. * nit (cd/m^2)
  8985. */
  8986. static readonly INTENSITYMODE_LUMINANCE: number;
  8987. /**
  8988. * Light type const id of the point light.
  8989. */
  8990. static readonly LIGHTTYPEID_POINTLIGHT: number;
  8991. /**
  8992. * Light type const id of the directional light.
  8993. */
  8994. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  8995. /**
  8996. * Light type const id of the spot light.
  8997. */
  8998. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  8999. /**
  9000. * Light type const id of the hemispheric light.
  9001. */
  9002. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9003. /**
  9004. * Diffuse gives the basic color to an object.
  9005. */
  9006. diffuse: Color3;
  9007. /**
  9008. * Specular produces a highlight color on an object.
  9009. * Note: This is note affecting PBR materials.
  9010. */
  9011. specular: Color3;
  9012. /**
  9013. * Defines the falloff type for this light. This lets overriding how punctual light are
  9014. * falling off base on range or angle.
  9015. * This can be set to any values in Light.FALLOFF_x.
  9016. *
  9017. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9018. * other types of materials.
  9019. */
  9020. falloffType: number;
  9021. /**
  9022. * Strength of the light.
  9023. * Note: By default it is define in the framework own unit.
  9024. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9025. */
  9026. intensity: number;
  9027. private _range;
  9028. protected _inverseSquaredRange: number;
  9029. /**
  9030. * Defines how far from the source the light is impacting in scene units.
  9031. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9032. */
  9033. get range(): number;
  9034. /**
  9035. * Defines how far from the source the light is impacting in scene units.
  9036. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9037. */
  9038. set range(value: number);
  9039. /**
  9040. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9041. * of light.
  9042. */
  9043. private _photometricScale;
  9044. private _intensityMode;
  9045. /**
  9046. * Gets the photometric scale used to interpret the intensity.
  9047. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9048. */
  9049. get intensityMode(): number;
  9050. /**
  9051. * Sets the photometric scale used to interpret the intensity.
  9052. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9053. */
  9054. set intensityMode(value: number);
  9055. private _radius;
  9056. /**
  9057. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9058. */
  9059. get radius(): number;
  9060. /**
  9061. * sets the light radius used by PBR Materials to simulate soft area lights.
  9062. */
  9063. set radius(value: number);
  9064. private _renderPriority;
  9065. /**
  9066. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9067. * exceeding the number allowed of the materials.
  9068. */
  9069. renderPriority: number;
  9070. private _shadowEnabled;
  9071. /**
  9072. * Gets whether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9073. * the current shadow generator.
  9074. */
  9075. get shadowEnabled(): boolean;
  9076. /**
  9077. * Sets whether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9078. * the current shadow generator.
  9079. */
  9080. set shadowEnabled(value: boolean);
  9081. private _includedOnlyMeshes;
  9082. /**
  9083. * Gets the only meshes impacted by this light.
  9084. */
  9085. get includedOnlyMeshes(): AbstractMesh[];
  9086. /**
  9087. * Sets the only meshes impacted by this light.
  9088. */
  9089. set includedOnlyMeshes(value: AbstractMesh[]);
  9090. private _excludedMeshes;
  9091. /**
  9092. * Gets the meshes not impacted by this light.
  9093. */
  9094. get excludedMeshes(): AbstractMesh[];
  9095. /**
  9096. * Sets the meshes not impacted by this light.
  9097. */
  9098. set excludedMeshes(value: AbstractMesh[]);
  9099. private _excludeWithLayerMask;
  9100. /**
  9101. * Gets the layer id use to find what meshes are not impacted by the light.
  9102. * Inactive if 0
  9103. */
  9104. get excludeWithLayerMask(): number;
  9105. /**
  9106. * Sets the layer id use to find what meshes are not impacted by the light.
  9107. * Inactive if 0
  9108. */
  9109. set excludeWithLayerMask(value: number);
  9110. private _includeOnlyWithLayerMask;
  9111. /**
  9112. * Gets the layer id use to find what meshes are impacted by the light.
  9113. * Inactive if 0
  9114. */
  9115. get includeOnlyWithLayerMask(): number;
  9116. /**
  9117. * Sets the layer id use to find what meshes are impacted by the light.
  9118. * Inactive if 0
  9119. */
  9120. set includeOnlyWithLayerMask(value: number);
  9121. private _lightmapMode;
  9122. /**
  9123. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9124. */
  9125. get lightmapMode(): number;
  9126. /**
  9127. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9128. */
  9129. set lightmapMode(value: number);
  9130. /**
  9131. * Shadow generator associated to the light.
  9132. * @hidden Internal use only.
  9133. */
  9134. _shadowGenerator: Nullable<IShadowGenerator>;
  9135. /**
  9136. * @hidden Internal use only.
  9137. */
  9138. _excludedMeshesIds: string[];
  9139. /**
  9140. * @hidden Internal use only.
  9141. */
  9142. _includedOnlyMeshesIds: string[];
  9143. /**
  9144. * The current light uniform buffer.
  9145. * @hidden Internal use only.
  9146. */
  9147. _uniformBuffer: UniformBuffer;
  9148. /** @hidden */
  9149. _renderId: number;
  9150. /**
  9151. * Creates a Light object in the scene.
  9152. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9153. * @param name The friendly name of the light
  9154. * @param scene The scene the light belongs too
  9155. */
  9156. constructor(name: string, scene: Scene);
  9157. protected abstract _buildUniformLayout(): void;
  9158. /**
  9159. * Sets the passed Effect "effect" with the Light information.
  9160. * @param effect The effect to update
  9161. * @param lightIndex The index of the light in the effect to update
  9162. * @returns The light
  9163. */
  9164. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  9165. /**
  9166. * Sets the passed Effect "effect" with the Light textures.
  9167. * @param effect The effect to update
  9168. * @param lightIndex The index of the light in the effect to update
  9169. * @returns The light
  9170. */
  9171. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  9172. /**
  9173. * Binds the lights information from the scene to the effect for the given mesh.
  9174. * @param lightIndex Light index
  9175. * @param scene The scene where the light belongs to
  9176. * @param effect The effect we are binding the data to
  9177. * @param useSpecular Defines if specular is supported
  9178. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9179. */
  9180. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9181. /**
  9182. * Sets the passed Effect "effect" with the Light information.
  9183. * @param effect The effect to update
  9184. * @param lightDataUniformName The uniform used to store light data (position or direction)
  9185. * @returns The light
  9186. */
  9187. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  9188. /**
  9189. * Returns the string "Light".
  9190. * @returns the class name
  9191. */
  9192. getClassName(): string;
  9193. /** @hidden */
  9194. readonly _isLight: boolean;
  9195. /**
  9196. * Converts the light information to a readable string for debug purpose.
  9197. * @param fullDetails Supports for multiple levels of logging within scene loading
  9198. * @returns the human readable light info
  9199. */
  9200. toString(fullDetails?: boolean): string;
  9201. /** @hidden */
  9202. protected _syncParentEnabledState(): void;
  9203. /**
  9204. * Set the enabled state of this node.
  9205. * @param value - the new enabled state
  9206. */
  9207. setEnabled(value: boolean): void;
  9208. /**
  9209. * Returns the Light associated shadow generator if any.
  9210. * @return the associated shadow generator.
  9211. */
  9212. getShadowGenerator(): Nullable<IShadowGenerator>;
  9213. /**
  9214. * Returns a Vector3, the absolute light position in the World.
  9215. * @returns the world space position of the light
  9216. */
  9217. getAbsolutePosition(): Vector3;
  9218. /**
  9219. * Specifies if the light will affect the passed mesh.
  9220. * @param mesh The mesh to test against the light
  9221. * @return true the mesh is affected otherwise, false.
  9222. */
  9223. canAffectMesh(mesh: AbstractMesh): boolean;
  9224. /**
  9225. * Sort function to order lights for rendering.
  9226. * @param a First Light object to compare to second.
  9227. * @param b Second Light object to compare first.
  9228. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  9229. */
  9230. static CompareLightsPriority(a: Light, b: Light): number;
  9231. /**
  9232. * Releases resources associated with this node.
  9233. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  9234. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  9235. */
  9236. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  9237. /**
  9238. * Returns the light type ID (integer).
  9239. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  9240. */
  9241. getTypeID(): number;
  9242. /**
  9243. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  9244. * @returns the scaled intensity in intensity mode unit
  9245. */
  9246. getScaledIntensity(): number;
  9247. /**
  9248. * Returns a new Light object, named "name", from the current one.
  9249. * @param name The name of the cloned light
  9250. * @param newParent The parent of this light, if it has one
  9251. * @returns the new created light
  9252. */
  9253. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  9254. /**
  9255. * Serializes the current light into a Serialization object.
  9256. * @returns the serialized object.
  9257. */
  9258. serialize(): any;
  9259. /**
  9260. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  9261. * This new light is named "name" and added to the passed scene.
  9262. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  9263. * @param name The friendly name of the light
  9264. * @param scene The scene the new light will belong to
  9265. * @returns the constructor function
  9266. */
  9267. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  9268. /**
  9269. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  9270. * @param parsedLight The JSON representation of the light
  9271. * @param scene The scene to create the parsed light in
  9272. * @returns the created light after parsing
  9273. */
  9274. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  9275. private _hookArrayForExcluded;
  9276. private _hookArrayForIncludedOnly;
  9277. private _resyncMeshes;
  9278. /**
  9279. * Forces the meshes to update their light related information in their rendering used effects
  9280. * @hidden Internal Use Only
  9281. */
  9282. _markMeshesAsLightDirty(): void;
  9283. /**
  9284. * Recomputes the cached photometric scale if needed.
  9285. */
  9286. private _computePhotometricScale;
  9287. /**
  9288. * Returns the Photometric Scale according to the light type and intensity mode.
  9289. */
  9290. private _getPhotometricScale;
  9291. /**
  9292. * Reorder the light in the scene according to their defined priority.
  9293. * @hidden Internal Use Only
  9294. */
  9295. _reorderLightsInScene(): void;
  9296. /**
  9297. * Prepares the list of defines specific to the light type.
  9298. * @param defines the list of defines
  9299. * @param lightIndex defines the index of the light for the effect
  9300. */
  9301. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  9302. }
  9303. }
  9304. declare module BABYLON {
  9305. /** Defines supported spaces */
  9306. export enum Space {
  9307. /** Local (object) space */
  9308. LOCAL = 0,
  9309. /** World space */
  9310. WORLD = 1,
  9311. /** Bone space */
  9312. BONE = 2
  9313. }
  9314. /** Defines the 3 main axes */
  9315. export class Axis {
  9316. /** X axis */
  9317. static X: Vector3;
  9318. /** Y axis */
  9319. static Y: Vector3;
  9320. /** Z axis */
  9321. static Z: Vector3;
  9322. }
  9323. /**
  9324. * Defines cartesian components.
  9325. */
  9326. export enum Coordinate {
  9327. /** X axis */
  9328. X = 0,
  9329. /** Y axis */
  9330. Y = 1,
  9331. /** Z axis */
  9332. Z = 2
  9333. }
  9334. }
  9335. declare module BABYLON {
  9336. /**
  9337. * Interface describing all the common properties and methods a shadow light needs to implement.
  9338. * This helps both the shadow generator and materials to generate the corresponding shadow maps
  9339. * as well as binding the different shadow properties to the effects.
  9340. */
  9341. export interface IShadowLight extends Light {
  9342. /**
  9343. * The light id in the scene (used in scene.findLightById for instance)
  9344. */
  9345. id: string;
  9346. /**
  9347. * The position the shadow will be casted from.
  9348. */
  9349. position: Vector3;
  9350. /**
  9351. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9352. */
  9353. direction: Vector3;
  9354. /**
  9355. * The transformed position. Position of the light in world space taking parenting in account.
  9356. */
  9357. transformedPosition: Vector3;
  9358. /**
  9359. * The transformed direction. Direction of the light in world space taking parenting in account.
  9360. */
  9361. transformedDirection: Vector3;
  9362. /**
  9363. * The friendly name of the light in the scene.
  9364. */
  9365. name: string;
  9366. /**
  9367. * Defines the shadow projection clipping minimum z value.
  9368. */
  9369. shadowMinZ: number;
  9370. /**
  9371. * Defines the shadow projection clipping maximum z value.
  9372. */
  9373. shadowMaxZ: number;
  9374. /**
  9375. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9376. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9377. */
  9378. computeTransformedInformation(): boolean;
  9379. /**
  9380. * Gets the scene the light belongs to.
  9381. * @returns The scene
  9382. */
  9383. getScene(): Scene;
  9384. /**
  9385. * Callback defining a custom Projection Matrix Builder.
  9386. * This can be used to override the default projection matrix computation.
  9387. */
  9388. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9389. /**
  9390. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9391. * @param matrix The matrix to updated with the projection information
  9392. * @param viewMatrix The transform matrix of the light
  9393. * @param renderList The list of mesh to render in the map
  9394. * @returns The current light
  9395. */
  9396. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9397. /**
  9398. * Gets the current depth scale used in ESM.
  9399. * @returns The scale
  9400. */
  9401. getDepthScale(): number;
  9402. /**
  9403. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9404. * @returns true if a cube texture needs to be use
  9405. */
  9406. needCube(): boolean;
  9407. /**
  9408. * Detects if the projection matrix requires to be recomputed this frame.
  9409. * @returns true if it requires to be recomputed otherwise, false.
  9410. */
  9411. needProjectionMatrixCompute(): boolean;
  9412. /**
  9413. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9414. */
  9415. forceProjectionMatrixCompute(): void;
  9416. /**
  9417. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9418. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9419. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9420. */
  9421. getShadowDirection(faceIndex?: number): Vector3;
  9422. /**
  9423. * Gets the minZ used for shadow according to both the scene and the light.
  9424. * @param activeCamera The camera we are returning the min for
  9425. * @returns the depth min z
  9426. */
  9427. getDepthMinZ(activeCamera: Camera): number;
  9428. /**
  9429. * Gets the maxZ used for shadow according to both the scene and the light.
  9430. * @param activeCamera The camera we are returning the max for
  9431. * @returns the depth max z
  9432. */
  9433. getDepthMaxZ(activeCamera: Camera): number;
  9434. }
  9435. /**
  9436. * Base implementation IShadowLight
  9437. * It groups all the common behaviour in order to reduce duplication and better follow the DRY pattern.
  9438. */
  9439. export abstract class ShadowLight extends Light implements IShadowLight {
  9440. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9441. protected _position: Vector3;
  9442. protected _setPosition(value: Vector3): void;
  9443. /**
  9444. * Sets the position the shadow will be casted from. Also use as the light position for both
  9445. * point and spot lights.
  9446. */
  9447. get position(): Vector3;
  9448. /**
  9449. * Sets the position the shadow will be casted from. Also use as the light position for both
  9450. * point and spot lights.
  9451. */
  9452. set position(value: Vector3);
  9453. protected _direction: Vector3;
  9454. protected _setDirection(value: Vector3): void;
  9455. /**
  9456. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9457. * Also use as the light direction on spot and directional lights.
  9458. */
  9459. get direction(): Vector3;
  9460. /**
  9461. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9462. * Also use as the light direction on spot and directional lights.
  9463. */
  9464. set direction(value: Vector3);
  9465. protected _shadowMinZ: number;
  9466. /**
  9467. * Gets the shadow projection clipping minimum z value.
  9468. */
  9469. get shadowMinZ(): number;
  9470. /**
  9471. * Sets the shadow projection clipping minimum z value.
  9472. */
  9473. set shadowMinZ(value: number);
  9474. protected _shadowMaxZ: number;
  9475. /**
  9476. * Sets the shadow projection clipping maximum z value.
  9477. */
  9478. get shadowMaxZ(): number;
  9479. /**
  9480. * Gets the shadow projection clipping maximum z value.
  9481. */
  9482. set shadowMaxZ(value: number);
  9483. /**
  9484. * Callback defining a custom Projection Matrix Builder.
  9485. * This can be used to override the default projection matrix computation.
  9486. */
  9487. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9488. /**
  9489. * The transformed position. Position of the light in world space taking parenting in account.
  9490. */
  9491. transformedPosition: Vector3;
  9492. /**
  9493. * The transformed direction. Direction of the light in world space taking parenting in account.
  9494. */
  9495. transformedDirection: Vector3;
  9496. private _needProjectionMatrixCompute;
  9497. /**
  9498. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9499. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9500. */
  9501. computeTransformedInformation(): boolean;
  9502. /**
  9503. * Return the depth scale used for the shadow map.
  9504. * @returns the depth scale.
  9505. */
  9506. getDepthScale(): number;
  9507. /**
  9508. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9509. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9510. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9511. */
  9512. getShadowDirection(faceIndex?: number): Vector3;
  9513. /**
  9514. * Returns the ShadowLight absolute position in the World.
  9515. * @returns the position vector in world space
  9516. */
  9517. getAbsolutePosition(): Vector3;
  9518. /**
  9519. * Sets the ShadowLight direction toward the passed target.
  9520. * @param target The point to target in local space
  9521. * @returns the updated ShadowLight direction
  9522. */
  9523. setDirectionToTarget(target: Vector3): Vector3;
  9524. /**
  9525. * Returns the light rotation in euler definition.
  9526. * @returns the x y z rotation in local space.
  9527. */
  9528. getRotation(): Vector3;
  9529. /**
  9530. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9531. * @returns true if a cube texture needs to be use
  9532. */
  9533. needCube(): boolean;
  9534. /**
  9535. * Detects if the projection matrix requires to be recomputed this frame.
  9536. * @returns true if it requires to be recomputed otherwise, false.
  9537. */
  9538. needProjectionMatrixCompute(): boolean;
  9539. /**
  9540. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9541. */
  9542. forceProjectionMatrixCompute(): void;
  9543. /** @hidden */
  9544. _initCache(): void;
  9545. /** @hidden */
  9546. _isSynchronized(): boolean;
  9547. /**
  9548. * Computes the world matrix of the node
  9549. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9550. * @returns the world matrix
  9551. */
  9552. computeWorldMatrix(force?: boolean): Matrix;
  9553. /**
  9554. * Gets the minZ used for shadow according to both the scene and the light.
  9555. * @param activeCamera The camera we are returning the min for
  9556. * @returns the depth min z
  9557. */
  9558. getDepthMinZ(activeCamera: Camera): number;
  9559. /**
  9560. * Gets the maxZ used for shadow according to both the scene and the light.
  9561. * @param activeCamera The camera we are returning the max for
  9562. * @returns the depth max z
  9563. */
  9564. getDepthMaxZ(activeCamera: Camera): number;
  9565. /**
  9566. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9567. * @param matrix The matrix to updated with the projection information
  9568. * @param viewMatrix The transform matrix of the light
  9569. * @param renderList The list of mesh to render in the map
  9570. * @returns The current light
  9571. */
  9572. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9573. }
  9574. }
  9575. declare module BABYLON {
  9576. /**
  9577. * Configuration needed for prepass-capable materials
  9578. */
  9579. export class PrePassConfiguration {
  9580. /**
  9581. * Previous world matrices of meshes carrying this material
  9582. * Used for computing velocity
  9583. */
  9584. previousWorldMatrices: {
  9585. [index: number]: Matrix;
  9586. };
  9587. /**
  9588. * Previous view project matrix
  9589. * Used for computing velocity
  9590. */
  9591. previousViewProjection: Matrix;
  9592. /**
  9593. * Previous bones of meshes carrying this material
  9594. * Used for computing velocity
  9595. */
  9596. previousBones: {
  9597. [index: number]: Float32Array;
  9598. };
  9599. /**
  9600. * Add the required uniforms to the current list.
  9601. * @param uniforms defines the current uniform list.
  9602. */
  9603. static AddUniforms(uniforms: string[]): void;
  9604. /**
  9605. * Add the required samplers to the current list.
  9606. * @param samplers defines the current sampler list.
  9607. */
  9608. static AddSamplers(samplers: string[]): void;
  9609. /**
  9610. * Binds the material data.
  9611. * @param effect defines the effect to update
  9612. * @param scene defines the scene the material belongs to.
  9613. * @param mesh The mesh
  9614. * @param world World matrix of this mesh
  9615. * @param isFrozen Is the material frozen
  9616. */
  9617. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  9618. }
  9619. }
  9620. declare module BABYLON {
  9621. /**
  9622. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  9623. * This is the base of the follow, arc rotate cameras and Free camera
  9624. * @see https://doc.babylonjs.com/features/cameras
  9625. */
  9626. export class TargetCamera extends Camera {
  9627. private static _RigCamTransformMatrix;
  9628. private static _TargetTransformMatrix;
  9629. private static _TargetFocalPoint;
  9630. private _tmpUpVector;
  9631. private _tmpTargetVector;
  9632. /**
  9633. * Define the current direction the camera is moving to
  9634. */
  9635. cameraDirection: Vector3;
  9636. /**
  9637. * Define the current rotation the camera is rotating to
  9638. */
  9639. cameraRotation: Vector2;
  9640. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  9641. ignoreParentScaling: boolean;
  9642. /**
  9643. * When set, the up vector of the camera will be updated by the rotation of the camera
  9644. */
  9645. updateUpVectorFromRotation: boolean;
  9646. private _tmpQuaternion;
  9647. /**
  9648. * Define the current rotation of the camera
  9649. */
  9650. rotation: Vector3;
  9651. /**
  9652. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  9653. */
  9654. rotationQuaternion: Quaternion;
  9655. /**
  9656. * Define the current speed of the camera
  9657. */
  9658. speed: number;
  9659. /**
  9660. * Add constraint to the camera to prevent it to move freely in all directions and
  9661. * around all axis.
  9662. */
  9663. noRotationConstraint: boolean;
  9664. /**
  9665. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  9666. * panning
  9667. */
  9668. invertRotation: boolean;
  9669. /**
  9670. * Speed multiplier for inverse camera panning
  9671. */
  9672. inverseRotationSpeed: number;
  9673. /**
  9674. * Define the current target of the camera as an object or a position.
  9675. */
  9676. lockedTarget: any;
  9677. /** @hidden */
  9678. _currentTarget: Vector3;
  9679. /** @hidden */
  9680. _initialFocalDistance: number;
  9681. /** @hidden */
  9682. _viewMatrix: Matrix;
  9683. /** @hidden */
  9684. _camMatrix: Matrix;
  9685. /** @hidden */
  9686. _cameraTransformMatrix: Matrix;
  9687. /** @hidden */
  9688. _cameraRotationMatrix: Matrix;
  9689. /** @hidden */
  9690. _referencePoint: Vector3;
  9691. /** @hidden */
  9692. _transformedReferencePoint: Vector3;
  9693. /** @hidden */
  9694. _reset: () => void;
  9695. private _defaultUp;
  9696. /**
  9697. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  9698. * This is the base of the follow, arc rotate cameras and Free camera
  9699. * @see https://doc.babylonjs.com/features/cameras
  9700. * @param name Defines the name of the camera in the scene
  9701. * @param position Defines the start position of the camera in the scene
  9702. * @param scene Defines the scene the camera belongs to
  9703. * @param setActiveOnSceneIfNoneActive Defines whether the camera should be marked as active if not other active cameras have been defined
  9704. */
  9705. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  9706. /**
  9707. * Gets the position in front of the camera at a given distance.
  9708. * @param distance The distance from the camera we want the position to be
  9709. * @returns the position
  9710. */
  9711. getFrontPosition(distance: number): Vector3;
  9712. /** @hidden */
  9713. _getLockedTargetPosition(): Nullable<Vector3>;
  9714. private _storedPosition;
  9715. private _storedRotation;
  9716. private _storedRotationQuaternion;
  9717. /**
  9718. * Store current camera state of the camera (fov, position, rotation, etc..)
  9719. * @returns the camera
  9720. */
  9721. storeState(): Camera;
  9722. /**
  9723. * Restored camera state. You must call storeState() first
  9724. * @returns whether it was successful or not
  9725. * @hidden
  9726. */
  9727. _restoreStateValues(): boolean;
  9728. /** @hidden */
  9729. _initCache(): void;
  9730. /** @hidden */
  9731. _updateCache(ignoreParentClass?: boolean): void;
  9732. /** @hidden */
  9733. _isSynchronizedViewMatrix(): boolean;
  9734. /** @hidden */
  9735. _computeLocalCameraSpeed(): number;
  9736. /**
  9737. * Defines the target the camera should look at.
  9738. * @param target Defines the new target as a Vector or a mesh
  9739. */
  9740. setTarget(target: Vector3): void;
  9741. /**
  9742. * Defines the target point of the camera.
  9743. * The camera looks towards it form the radius distance.
  9744. */
  9745. get target(): Vector3;
  9746. set target(value: Vector3);
  9747. /**
  9748. * Return the current target position of the camera. This value is expressed in local space.
  9749. * @returns the target position
  9750. */
  9751. getTarget(): Vector3;
  9752. /** @hidden */
  9753. _decideIfNeedsToMove(): boolean;
  9754. /** @hidden */
  9755. _updatePosition(): void;
  9756. /** @hidden */
  9757. _checkInputs(): void;
  9758. protected _updateCameraRotationMatrix(): void;
  9759. /**
  9760. * 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)
  9761. * @returns the current camera
  9762. */
  9763. private _rotateUpVectorWithCameraRotationMatrix;
  9764. private _cachedRotationZ;
  9765. private _cachedQuaternionRotationZ;
  9766. /** @hidden */
  9767. _getViewMatrix(): Matrix;
  9768. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  9769. /**
  9770. * @hidden
  9771. */
  9772. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  9773. /**
  9774. * @hidden
  9775. */
  9776. _updateRigCameras(): void;
  9777. private _getRigCamPositionAndTarget;
  9778. /**
  9779. * Gets the current object class name.
  9780. * @return the class name
  9781. */
  9782. getClassName(): string;
  9783. }
  9784. }
  9785. declare module BABYLON {
  9786. /**
  9787. * @ignore
  9788. * This is a list of all the different input types that are available in the application.
  9789. * Fo instance: ArcRotateCameraGamepadInput...
  9790. */
  9791. export var CameraInputTypes: {};
  9792. /**
  9793. * This is the contract to implement in order to create a new input class.
  9794. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  9795. */
  9796. export interface ICameraInput<TCamera extends Camera> {
  9797. /**
  9798. * Defines the camera the input is attached to.
  9799. */
  9800. camera: Nullable<TCamera>;
  9801. /**
  9802. * Gets the class name of the current input.
  9803. * @returns the class name
  9804. */
  9805. getClassName(): string;
  9806. /**
  9807. * Get the friendly name associated with the input class.
  9808. * @returns the input friendly name
  9809. */
  9810. getSimpleName(): string;
  9811. /**
  9812. * Attach the input controls to a specific dom element to get the input from.
  9813. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9814. */
  9815. attachControl(noPreventDefault?: boolean): void;
  9816. /**
  9817. * Detach the current controls from the specified dom element.
  9818. */
  9819. detachControl(): void;
  9820. /**
  9821. * Update the current camera state depending on the inputs that have been used this frame.
  9822. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9823. */
  9824. checkInputs?: () => void;
  9825. }
  9826. /**
  9827. * Represents a map of input types to input instance or input index to input instance.
  9828. */
  9829. export interface CameraInputsMap<TCamera extends Camera> {
  9830. /**
  9831. * Accessor to the input by input type.
  9832. */
  9833. [name: string]: ICameraInput<TCamera>;
  9834. /**
  9835. * Accessor to the input by input index.
  9836. */
  9837. [idx: number]: ICameraInput<TCamera>;
  9838. }
  9839. /**
  9840. * This represents the input manager used within a camera.
  9841. * It helps dealing with all the different kind of input attached to a camera.
  9842. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9843. */
  9844. export class CameraInputsManager<TCamera extends Camera> {
  9845. /**
  9846. * Defines the list of inputs attached to the camera.
  9847. */
  9848. attached: CameraInputsMap<TCamera>;
  9849. /**
  9850. * Defines the dom element the camera is collecting inputs from.
  9851. * This is null if the controls have not been attached.
  9852. */
  9853. attachedToElement: boolean;
  9854. /**
  9855. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9856. */
  9857. noPreventDefault: boolean;
  9858. /**
  9859. * Defined the camera the input manager belongs to.
  9860. */
  9861. camera: TCamera;
  9862. /**
  9863. * Update the current camera state depending on the inputs that have been used this frame.
  9864. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9865. */
  9866. checkInputs: () => void;
  9867. /**
  9868. * Instantiate a new Camera Input Manager.
  9869. * @param camera Defines the camera the input manager belongs to
  9870. */
  9871. constructor(camera: TCamera);
  9872. /**
  9873. * Add an input method to a camera
  9874. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9875. * @param input camera input method
  9876. */
  9877. add(input: ICameraInput<TCamera>): void;
  9878. /**
  9879. * Remove a specific input method from a camera
  9880. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  9881. * @param inputToRemove camera input method
  9882. */
  9883. remove(inputToRemove: ICameraInput<TCamera>): void;
  9884. /**
  9885. * Remove a specific input type from a camera
  9886. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  9887. * @param inputType the type of the input to remove
  9888. */
  9889. removeByType(inputType: string): void;
  9890. private _addCheckInputs;
  9891. /**
  9892. * Attach the input controls to the currently attached dom element to listen the events from.
  9893. * @param input Defines the input to attach
  9894. */
  9895. attachInput(input: ICameraInput<TCamera>): void;
  9896. /**
  9897. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  9898. * @param element Defines the dom element to collect the events from
  9899. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9900. */
  9901. attachElement(noPreventDefault?: boolean): void;
  9902. /**
  9903. * Detach the current manager inputs controls from a specific dom element.
  9904. * @param element Defines the dom element to collect the events from
  9905. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  9906. */
  9907. detachElement(disconnect?: boolean): void;
  9908. /**
  9909. * Rebuild the dynamic inputCheck function from the current list of
  9910. * defined inputs in the manager.
  9911. */
  9912. rebuildInputCheck(): void;
  9913. /**
  9914. * Remove all attached input methods from a camera
  9915. */
  9916. clear(): void;
  9917. /**
  9918. * Serialize the current input manager attached to a camera.
  9919. * This ensures than once parsed,
  9920. * the input associated to the camera will be identical to the current ones
  9921. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  9922. */
  9923. serialize(serializedCamera: any): void;
  9924. /**
  9925. * Parses an input manager serialized JSON to restore the previous list of inputs
  9926. * and states associated to a camera.
  9927. * @param parsedCamera Defines the JSON to parse
  9928. */
  9929. parse(parsedCamera: any): void;
  9930. }
  9931. }
  9932. declare module BABYLON {
  9933. /**
  9934. * Event Types
  9935. */
  9936. export enum DeviceInputEventType {
  9937. /** PointerMove */
  9938. PointerMove = 0,
  9939. /** PointerDown */
  9940. PointerDown = 1,
  9941. /** PointerUp */
  9942. PointerUp = 2
  9943. }
  9944. /**
  9945. * Native friendly interface for Event Object
  9946. */
  9947. export interface IEvent {
  9948. /**
  9949. * Current target for an event
  9950. */
  9951. currentTarget?: any;
  9952. /**
  9953. * Alias for target
  9954. * @deprecated
  9955. */
  9956. srcElement?: any;
  9957. /**
  9958. * Type of event
  9959. */
  9960. type: string;
  9961. /**
  9962. * Reference to object where object was dispatched
  9963. */
  9964. target: any;
  9965. /**
  9966. * Tells user agent what to do when not explicitly handled
  9967. */
  9968. preventDefault: () => void;
  9969. }
  9970. /**
  9971. * Native friendly interface for UIEvent Object
  9972. */
  9973. export interface IUIEvent extends IEvent {
  9974. /**
  9975. * Provides current click count
  9976. */
  9977. detail: number;
  9978. /**
  9979. * Horizontal coordinate of event
  9980. */
  9981. pageX: number;
  9982. /**
  9983. * Vertical coordinate of event
  9984. */
  9985. pageY: number;
  9986. }
  9987. /**
  9988. * Native friendly interface for KeyboardEvent Object
  9989. */
  9990. export interface IKeyboardEvent extends IUIEvent {
  9991. /**
  9992. * Status of Alt key being pressed
  9993. */
  9994. altKey: boolean;
  9995. /**
  9996. * Unicode value of character pressed
  9997. * @deprecated
  9998. */
  9999. charCode?: number;
  10000. /**
  10001. * Code for key based on layout
  10002. */
  10003. code: string;
  10004. /**
  10005. * Status of Ctrl key being pressed
  10006. */
  10007. ctrlKey: boolean;
  10008. /**
  10009. * String representation of key
  10010. */
  10011. key: string;
  10012. /**
  10013. * ASCII value of key
  10014. * @deprecated
  10015. */
  10016. keyCode: number;
  10017. /**
  10018. * Status of Meta key (eg. Windows key) being pressed
  10019. */
  10020. metaKey: boolean;
  10021. /**
  10022. * Status of Shift key being pressed
  10023. */
  10024. shiftKey: boolean;
  10025. }
  10026. /**
  10027. * Native friendly interface for MouseEvent Object
  10028. */
  10029. export interface IMouseEvent extends IUIEvent {
  10030. /**
  10031. * Status of Alt key being pressed
  10032. */
  10033. altKey: boolean;
  10034. /**
  10035. * Value of single mouse button pressed
  10036. */
  10037. button: number;
  10038. /**
  10039. * Value of all mouse buttons pressed
  10040. */
  10041. buttons: number;
  10042. /**
  10043. * Current X coordinate
  10044. */
  10045. clientX: number;
  10046. /**
  10047. * Current Y coordinate
  10048. */
  10049. clientY: number;
  10050. /**
  10051. * Status of Ctrl key being pressed
  10052. */
  10053. ctrlKey: boolean;
  10054. /**
  10055. * Status of Meta key (eg. Windows key) being pressed
  10056. */
  10057. metaKey: boolean;
  10058. /**
  10059. * Delta of movement on X axis
  10060. */
  10061. movementX: number;
  10062. /**
  10063. * Delta of movement on Y axis
  10064. */
  10065. movementY: number;
  10066. /**
  10067. * Delta of movement on X axis
  10068. */
  10069. mozMovementX?: number;
  10070. /**
  10071. * Delta of movement on Y axis
  10072. */
  10073. mozMovementY?: number;
  10074. /**
  10075. * Delta of movement on X axis
  10076. */
  10077. msMovementX?: any;
  10078. /**
  10079. * Delta of movement on Y axis
  10080. */
  10081. msMovementY?: any;
  10082. /**
  10083. * Current coordinate of X within container
  10084. */
  10085. offsetX: number;
  10086. /**
  10087. * Current coordinate of Y within container
  10088. */
  10089. offsetY: number;
  10090. /**
  10091. * Status of Shift key being pressed
  10092. */
  10093. shiftKey: boolean;
  10094. /**
  10095. * Delta of movement on X axis
  10096. */
  10097. webkitMovementX?: any;
  10098. /**
  10099. * Delta of movement on Y axis
  10100. */
  10101. webkitMovementY?: any;
  10102. /**
  10103. * Alias of clientX
  10104. */
  10105. x: number;
  10106. /**
  10107. * Alias of clientY
  10108. */
  10109. y: number;
  10110. }
  10111. /**
  10112. * Native friendly interface for PointerEvent Object
  10113. */
  10114. export interface IPointerEvent extends IMouseEvent {
  10115. /**
  10116. * Pointer Event ID
  10117. */
  10118. pointerId: number;
  10119. /**
  10120. * Type of pointer
  10121. */
  10122. pointerType: string;
  10123. }
  10124. /**
  10125. * Native friendly interface for WheelEvent Object
  10126. */
  10127. export interface IWheelEvent extends IMouseEvent {
  10128. /**
  10129. * Units for delta value
  10130. */
  10131. deltaMode: number;
  10132. /**
  10133. * Horizontal scroll delta
  10134. */
  10135. deltaX: number;
  10136. /**
  10137. * Vertical scroll delta
  10138. */
  10139. deltaY: number;
  10140. /**
  10141. * Z-Axis scroll delta
  10142. */
  10143. deltaZ: number;
  10144. }
  10145. /**
  10146. * Constants used for Events
  10147. */
  10148. export class EventConstants {
  10149. /**
  10150. * Pixel delta for Wheel Events (Default)
  10151. */
  10152. static DOM_DELTA_PIXEL: number;
  10153. /**
  10154. * Line delta for Wheel Events
  10155. */
  10156. static DOM_DELTA_LINE: number;
  10157. /**
  10158. * Page delta for Wheel Events
  10159. */
  10160. static DOM_DELTA_PAGE: number;
  10161. }
  10162. }
  10163. declare module BABYLON {
  10164. /**
  10165. * Gather the list of keyboard event types as constants.
  10166. */
  10167. export class KeyboardEventTypes {
  10168. /**
  10169. * The keydown event is fired when a key becomes active (pressed).
  10170. */
  10171. static readonly KEYDOWN: number;
  10172. /**
  10173. * The keyup event is fired when a key has been released.
  10174. */
  10175. static readonly KEYUP: number;
  10176. }
  10177. /**
  10178. * This class is used to store keyboard related info for the onKeyboardObservable event.
  10179. */
  10180. export class KeyboardInfo {
  10181. /**
  10182. * Defines the type of event (KeyboardEventTypes)
  10183. */
  10184. type: number;
  10185. /**
  10186. * Defines the related dom event
  10187. */
  10188. event: IKeyboardEvent;
  10189. /**
  10190. * Instantiates a new keyboard info.
  10191. * This class is used to store keyboard related info for the onKeyboardObservable event.
  10192. * @param type Defines the type of event (KeyboardEventTypes)
  10193. * @param event Defines the related dom event
  10194. */
  10195. constructor(
  10196. /**
  10197. * Defines the type of event (KeyboardEventTypes)
  10198. */
  10199. type: number,
  10200. /**
  10201. * Defines the related dom event
  10202. */
  10203. event: IKeyboardEvent);
  10204. }
  10205. /**
  10206. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  10207. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  10208. */
  10209. export class KeyboardInfoPre extends KeyboardInfo {
  10210. /**
  10211. * Defines the type of event (KeyboardEventTypes)
  10212. */
  10213. type: number;
  10214. /**
  10215. * Defines the related dom event
  10216. */
  10217. event: IKeyboardEvent;
  10218. /**
  10219. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  10220. */
  10221. skipOnPointerObservable: boolean;
  10222. /**
  10223. * Instantiates a new keyboard pre info.
  10224. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  10225. * @param type Defines the type of event (KeyboardEventTypes)
  10226. * @param event Defines the related dom event
  10227. */
  10228. constructor(
  10229. /**
  10230. * Defines the type of event (KeyboardEventTypes)
  10231. */
  10232. type: number,
  10233. /**
  10234. * Defines the related dom event
  10235. */
  10236. event: IKeyboardEvent);
  10237. }
  10238. }
  10239. declare module BABYLON {
  10240. /**
  10241. * Manage the keyboard inputs to control the movement of a free camera.
  10242. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  10243. */
  10244. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  10245. /**
  10246. * Defines the camera the input is attached to.
  10247. */
  10248. camera: FreeCamera;
  10249. /**
  10250. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  10251. */
  10252. keysUp: number[];
  10253. /**
  10254. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  10255. */
  10256. keysUpward: number[];
  10257. /**
  10258. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  10259. */
  10260. keysDown: number[];
  10261. /**
  10262. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  10263. */
  10264. keysDownward: number[];
  10265. /**
  10266. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  10267. */
  10268. keysLeft: number[];
  10269. /**
  10270. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  10271. */
  10272. keysRight: number[];
  10273. private _keys;
  10274. private _onCanvasBlurObserver;
  10275. private _onKeyboardObserver;
  10276. private _engine;
  10277. private _scene;
  10278. /**
  10279. * Attach the input controls to a specific dom element to get the input from.
  10280. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  10281. */
  10282. attachControl(noPreventDefault?: boolean): void;
  10283. /**
  10284. * Detach the current controls from the specified dom element.
  10285. */
  10286. detachControl(): void;
  10287. /**
  10288. * Update the current camera state depending on the inputs that have been used this frame.
  10289. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  10290. */
  10291. checkInputs(): void;
  10292. /**
  10293. * Gets the class name of the current input.
  10294. * @returns the class name
  10295. */
  10296. getClassName(): string;
  10297. /** @hidden */
  10298. _onLostFocus(): void;
  10299. /**
  10300. * Get the friendly name associated with the input class.
  10301. * @returns the input friendly name
  10302. */
  10303. getSimpleName(): string;
  10304. }
  10305. }
  10306. declare module BABYLON {
  10307. /**
  10308. * Interface used to define Action
  10309. */
  10310. export interface IAction {
  10311. /**
  10312. * Trigger for the action
  10313. */
  10314. trigger: number;
  10315. /** Options of the trigger */
  10316. triggerOptions: any;
  10317. /**
  10318. * Gets the trigger parameters
  10319. * @returns the trigger parameters
  10320. */
  10321. getTriggerParameter(): any;
  10322. /**
  10323. * Internal only - executes current action event
  10324. * @hidden
  10325. */
  10326. _executeCurrent(evt?: ActionEvent): void;
  10327. /**
  10328. * Serialize placeholder for child classes
  10329. * @param parent of child
  10330. * @returns the serialized object
  10331. */
  10332. serialize(parent: any): any;
  10333. /**
  10334. * Internal only
  10335. * @hidden
  10336. */
  10337. _prepare(): void;
  10338. /**
  10339. * Internal only - manager for action
  10340. * @hidden
  10341. */
  10342. _actionManager: Nullable<AbstractActionManager>;
  10343. /**
  10344. * Adds action to chain of actions, may be a DoNothingAction
  10345. * @param action defines the next action to execute
  10346. * @returns The action passed in
  10347. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10348. */
  10349. then(action: IAction): IAction;
  10350. }
  10351. /**
  10352. * The action to be carried out following a trigger
  10353. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10354. */
  10355. export class Action implements IAction {
  10356. /** the trigger, with or without parameters, for the action */
  10357. triggerOptions: any;
  10358. /**
  10359. * Trigger for the action
  10360. */
  10361. trigger: number;
  10362. /**
  10363. * Internal only - manager for action
  10364. * @hidden
  10365. */
  10366. _actionManager: ActionManager;
  10367. private _nextActiveAction;
  10368. private _child;
  10369. private _condition?;
  10370. private _triggerParameter;
  10371. /**
  10372. * An event triggered prior to action being executed.
  10373. */
  10374. onBeforeExecuteObservable: Observable<Action>;
  10375. /**
  10376. * Creates a new Action
  10377. * @param triggerOptions the trigger, with or without parameters, for the action
  10378. * @param condition an optional determinant of action
  10379. */
  10380. constructor(
  10381. /** the trigger, with or without parameters, for the action */
  10382. triggerOptions: any, condition?: Condition);
  10383. /**
  10384. * Internal only
  10385. * @hidden
  10386. */
  10387. _prepare(): void;
  10388. /**
  10389. * Gets the trigger parameter
  10390. * @returns the trigger parameter
  10391. */
  10392. getTriggerParameter(): any;
  10393. /**
  10394. * Sets the trigger parameter
  10395. * @param value defines the new trigger parameter
  10396. */
  10397. setTriggerParameter(value: any): void;
  10398. /**
  10399. * Internal only - executes current action event
  10400. * @hidden
  10401. */
  10402. _executeCurrent(evt?: ActionEvent): void;
  10403. /**
  10404. * Execute placeholder for child classes
  10405. * @param evt optional action event
  10406. */
  10407. execute(evt?: ActionEvent): void;
  10408. /**
  10409. * Skips to next active action
  10410. */
  10411. skipToNextActiveAction(): void;
  10412. /**
  10413. * Adds action to chain of actions, may be a DoNothingAction
  10414. * @param action defines the next action to execute
  10415. * @returns The action passed in
  10416. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10417. */
  10418. then(action: Action): Action;
  10419. /**
  10420. * Internal only
  10421. * @hidden
  10422. */
  10423. _getProperty(propertyPath: string): string;
  10424. /**
  10425. * Internal only
  10426. * @hidden
  10427. */
  10428. _getEffectiveTarget(target: any, propertyPath: string): any;
  10429. /**
  10430. * Serialize placeholder for child classes
  10431. * @param parent of child
  10432. * @returns the serialized object
  10433. */
  10434. serialize(parent: any): any;
  10435. /**
  10436. * Internal only called by serialize
  10437. * @hidden
  10438. */
  10439. protected _serialize(serializedAction: any, parent?: any): any;
  10440. /**
  10441. * Internal only
  10442. * @hidden
  10443. */
  10444. static _SerializeValueAsString: (value: any) => string;
  10445. /**
  10446. * Internal only
  10447. * @hidden
  10448. */
  10449. static _GetTargetProperty: (target: Scene | Node) => {
  10450. name: string;
  10451. targetType: string;
  10452. value: string;
  10453. };
  10454. }
  10455. }
  10456. declare module BABYLON {
  10457. /**
  10458. * A Condition applied to an Action
  10459. */
  10460. export class Condition {
  10461. /**
  10462. * Internal only - manager for action
  10463. * @hidden
  10464. */
  10465. _actionManager: ActionManager;
  10466. /**
  10467. * Internal only
  10468. * @hidden
  10469. */
  10470. _evaluationId: number;
  10471. /**
  10472. * Internal only
  10473. * @hidden
  10474. */
  10475. _currentResult: boolean;
  10476. /**
  10477. * Creates a new Condition
  10478. * @param actionManager the manager of the action the condition is applied to
  10479. */
  10480. constructor(actionManager: ActionManager);
  10481. /**
  10482. * Check if the current condition is valid
  10483. * @returns a boolean
  10484. */
  10485. isValid(): boolean;
  10486. /**
  10487. * Internal only
  10488. * @hidden
  10489. */
  10490. _getProperty(propertyPath: string): string;
  10491. /**
  10492. * Internal only
  10493. * @hidden
  10494. */
  10495. _getEffectiveTarget(target: any, propertyPath: string): any;
  10496. /**
  10497. * Serialize placeholder for child classes
  10498. * @returns the serialized object
  10499. */
  10500. serialize(): any;
  10501. /**
  10502. * Internal only
  10503. * @hidden
  10504. */
  10505. protected _serialize(serializedCondition: any): any;
  10506. }
  10507. /**
  10508. * Defines specific conditional operators as extensions of Condition
  10509. */
  10510. export class ValueCondition extends Condition {
  10511. /** path to specify the property of the target the conditional operator uses */
  10512. propertyPath: string;
  10513. /** the value compared by the conditional operator against the current value of the property */
  10514. value: any;
  10515. /** the conditional operator, default ValueCondition.IsEqual */
  10516. operator: number;
  10517. /**
  10518. * Internal only
  10519. * @hidden
  10520. */
  10521. private static _IsEqual;
  10522. /**
  10523. * Internal only
  10524. * @hidden
  10525. */
  10526. private static _IsDifferent;
  10527. /**
  10528. * Internal only
  10529. * @hidden
  10530. */
  10531. private static _IsGreater;
  10532. /**
  10533. * Internal only
  10534. * @hidden
  10535. */
  10536. private static _IsLesser;
  10537. /**
  10538. * returns the number for IsEqual
  10539. */
  10540. static get IsEqual(): number;
  10541. /**
  10542. * Returns the number for IsDifferent
  10543. */
  10544. static get IsDifferent(): number;
  10545. /**
  10546. * Returns the number for IsGreater
  10547. */
  10548. static get IsGreater(): number;
  10549. /**
  10550. * Returns the number for IsLesser
  10551. */
  10552. static get IsLesser(): number;
  10553. /**
  10554. * Internal only The action manager for the condition
  10555. * @hidden
  10556. */
  10557. _actionManager: ActionManager;
  10558. /**
  10559. * Internal only
  10560. * @hidden
  10561. */
  10562. private _target;
  10563. /**
  10564. * Internal only
  10565. * @hidden
  10566. */
  10567. private _effectiveTarget;
  10568. /**
  10569. * Internal only
  10570. * @hidden
  10571. */
  10572. private _property;
  10573. /**
  10574. * Creates a new ValueCondition
  10575. * @param actionManager manager for the action the condition applies to
  10576. * @param target for the action
  10577. * @param propertyPath path to specify the property of the target the conditional operator uses
  10578. * @param value the value compared by the conditional operator against the current value of the property
  10579. * @param operator the conditional operator, default ValueCondition.IsEqual
  10580. */
  10581. constructor(actionManager: ActionManager, target: any,
  10582. /** path to specify the property of the target the conditional operator uses */
  10583. propertyPath: string,
  10584. /** the value compared by the conditional operator against the current value of the property */
  10585. value: any,
  10586. /** the conditional operator, default ValueCondition.IsEqual */
  10587. operator?: number);
  10588. /**
  10589. * Compares the given value with the property value for the specified conditional operator
  10590. * @returns the result of the comparison
  10591. */
  10592. isValid(): boolean;
  10593. /**
  10594. * Serialize the ValueCondition into a JSON compatible object
  10595. * @returns serialization object
  10596. */
  10597. serialize(): any;
  10598. /**
  10599. * Gets the name of the conditional operator for the ValueCondition
  10600. * @param operator the conditional operator
  10601. * @returns the name
  10602. */
  10603. static GetOperatorName(operator: number): string;
  10604. }
  10605. /**
  10606. * Defines a predicate condition as an extension of Condition
  10607. */
  10608. export class PredicateCondition extends Condition {
  10609. /** defines the predicate function used to validate the condition */
  10610. predicate: () => boolean;
  10611. /**
  10612. * Internal only - manager for action
  10613. * @hidden
  10614. */
  10615. _actionManager: ActionManager;
  10616. /**
  10617. * Creates a new PredicateCondition
  10618. * @param actionManager manager for the action the condition applies to
  10619. * @param predicate defines the predicate function used to validate the condition
  10620. */
  10621. constructor(actionManager: ActionManager,
  10622. /** defines the predicate function used to validate the condition */
  10623. predicate: () => boolean);
  10624. /**
  10625. * @returns the validity of the predicate condition
  10626. */
  10627. isValid(): boolean;
  10628. }
  10629. /**
  10630. * Defines a state condition as an extension of Condition
  10631. */
  10632. export class StateCondition extends Condition {
  10633. /** Value to compare with target state */
  10634. value: string;
  10635. /**
  10636. * Internal only - manager for action
  10637. * @hidden
  10638. */
  10639. _actionManager: ActionManager;
  10640. /**
  10641. * Internal only
  10642. * @hidden
  10643. */
  10644. private _target;
  10645. /**
  10646. * Creates a new StateCondition
  10647. * @param actionManager manager for the action the condition applies to
  10648. * @param target of the condition
  10649. * @param value to compare with target state
  10650. */
  10651. constructor(actionManager: ActionManager, target: any,
  10652. /** Value to compare with target state */
  10653. value: string);
  10654. /**
  10655. * Gets a boolean indicating if the current condition is met
  10656. * @returns the validity of the state
  10657. */
  10658. isValid(): boolean;
  10659. /**
  10660. * Serialize the StateCondition into a JSON compatible object
  10661. * @returns serialization object
  10662. */
  10663. serialize(): any;
  10664. }
  10665. }
  10666. declare module BABYLON {
  10667. /**
  10668. * This defines an action responsible to toggle a boolean once triggered.
  10669. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10670. */
  10671. export class SwitchBooleanAction extends Action {
  10672. /**
  10673. * The path to the boolean property in the target object
  10674. */
  10675. propertyPath: string;
  10676. private _target;
  10677. private _effectiveTarget;
  10678. private _property;
  10679. /**
  10680. * Instantiate the action
  10681. * @param triggerOptions defines the trigger options
  10682. * @param target defines the object containing the boolean
  10683. * @param propertyPath defines the path to the boolean property in the target object
  10684. * @param condition defines the trigger related conditions
  10685. */
  10686. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10687. /** @hidden */
  10688. _prepare(): void;
  10689. /**
  10690. * Execute the action toggle the boolean value.
  10691. */
  10692. execute(): void;
  10693. /**
  10694. * Serializes the actions and its related information.
  10695. * @param parent defines the object to serialize in
  10696. * @returns the serialized object
  10697. */
  10698. serialize(parent: any): any;
  10699. }
  10700. /**
  10701. * This defines an action responsible to set a the state field of the target
  10702. * to a desired value once triggered.
  10703. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10704. */
  10705. export class SetStateAction extends Action {
  10706. /**
  10707. * The value to store in the state field.
  10708. */
  10709. value: string;
  10710. private _target;
  10711. /**
  10712. * Instantiate the action
  10713. * @param triggerOptions defines the trigger options
  10714. * @param target defines the object containing the state property
  10715. * @param value defines the value to store in the state field
  10716. * @param condition defines the trigger related conditions
  10717. */
  10718. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10719. /**
  10720. * Execute the action and store the value on the target state property.
  10721. */
  10722. execute(): void;
  10723. /**
  10724. * Serializes the actions and its related information.
  10725. * @param parent defines the object to serialize in
  10726. * @returns the serialized object
  10727. */
  10728. serialize(parent: any): any;
  10729. }
  10730. /**
  10731. * This defines an action responsible to set a property of the target
  10732. * to a desired value once triggered.
  10733. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10734. */
  10735. export class SetValueAction extends Action {
  10736. /**
  10737. * The path of the property to set in the target.
  10738. */
  10739. propertyPath: string;
  10740. /**
  10741. * The value to set in the property
  10742. */
  10743. value: any;
  10744. private _target;
  10745. private _effectiveTarget;
  10746. private _property;
  10747. /**
  10748. * Instantiate the action
  10749. * @param triggerOptions defines the trigger options
  10750. * @param target defines the object containing the property
  10751. * @param propertyPath defines the path of the property to set in the target
  10752. * @param value defines the value to set in the property
  10753. * @param condition defines the trigger related conditions
  10754. */
  10755. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10756. /** @hidden */
  10757. _prepare(): void;
  10758. /**
  10759. * Execute the action and set the targeted property to the desired value.
  10760. */
  10761. execute(): void;
  10762. /**
  10763. * Serializes the actions and its related information.
  10764. * @param parent defines the object to serialize in
  10765. * @returns the serialized object
  10766. */
  10767. serialize(parent: any): any;
  10768. }
  10769. /**
  10770. * This defines an action responsible to increment the target value
  10771. * to a desired value once triggered.
  10772. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10773. */
  10774. export class IncrementValueAction extends Action {
  10775. /**
  10776. * The path of the property to increment in the target.
  10777. */
  10778. propertyPath: string;
  10779. /**
  10780. * The value we should increment the property by.
  10781. */
  10782. value: any;
  10783. private _target;
  10784. private _effectiveTarget;
  10785. private _property;
  10786. /**
  10787. * Instantiate the action
  10788. * @param triggerOptions defines the trigger options
  10789. * @param target defines the object containing the property
  10790. * @param propertyPath defines the path of the property to increment in the target
  10791. * @param value defines the value value we should increment the property by
  10792. * @param condition defines the trigger related conditions
  10793. */
  10794. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10795. /** @hidden */
  10796. _prepare(): void;
  10797. /**
  10798. * Execute the action and increment the target of the value amount.
  10799. */
  10800. execute(): void;
  10801. /**
  10802. * Serializes the actions and its related information.
  10803. * @param parent defines the object to serialize in
  10804. * @returns the serialized object
  10805. */
  10806. serialize(parent: any): any;
  10807. }
  10808. /**
  10809. * This defines an action responsible to start an animation once triggered.
  10810. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10811. */
  10812. export class PlayAnimationAction extends Action {
  10813. /**
  10814. * Where the animation should start (animation frame)
  10815. */
  10816. from: number;
  10817. /**
  10818. * Where the animation should stop (animation frame)
  10819. */
  10820. to: number;
  10821. /**
  10822. * Define if the animation should loop or stop after the first play.
  10823. */
  10824. loop?: boolean;
  10825. private _target;
  10826. /**
  10827. * Instantiate the action
  10828. * @param triggerOptions defines the trigger options
  10829. * @param target defines the target animation or animation name
  10830. * @param from defines from where the animation should start (animation frame)
  10831. * @param to defines where the animation should stop (animation frame)
  10832. * @param loop defines if the animation should loop or stop after the first play
  10833. * @param condition defines the trigger related conditions
  10834. */
  10835. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10836. /** @hidden */
  10837. _prepare(): void;
  10838. /**
  10839. * Execute the action and play the animation.
  10840. */
  10841. execute(): void;
  10842. /**
  10843. * Serializes the actions and its related information.
  10844. * @param parent defines the object to serialize in
  10845. * @returns the serialized object
  10846. */
  10847. serialize(parent: any): any;
  10848. }
  10849. /**
  10850. * This defines an action responsible to stop an animation once triggered.
  10851. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10852. */
  10853. export class StopAnimationAction extends Action {
  10854. private _target;
  10855. /**
  10856. * Instantiate the action
  10857. * @param triggerOptions defines the trigger options
  10858. * @param target defines the target animation or animation name
  10859. * @param condition defines the trigger related conditions
  10860. */
  10861. constructor(triggerOptions: any, target: any, condition?: Condition);
  10862. /** @hidden */
  10863. _prepare(): void;
  10864. /**
  10865. * Execute the action and stop the animation.
  10866. */
  10867. execute(): void;
  10868. /**
  10869. * Serializes the actions and its related information.
  10870. * @param parent defines the object to serialize in
  10871. * @returns the serialized object
  10872. */
  10873. serialize(parent: any): any;
  10874. }
  10875. /**
  10876. * This defines an action responsible that does nothing once triggered.
  10877. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10878. */
  10879. export class DoNothingAction extends Action {
  10880. /**
  10881. * Instantiate the action
  10882. * @param triggerOptions defines the trigger options
  10883. * @param condition defines the trigger related conditions
  10884. */
  10885. constructor(triggerOptions?: any, condition?: Condition);
  10886. /**
  10887. * Execute the action and do nothing.
  10888. */
  10889. execute(): void;
  10890. /**
  10891. * Serializes the actions and its related information.
  10892. * @param parent defines the object to serialize in
  10893. * @returns the serialized object
  10894. */
  10895. serialize(parent: any): any;
  10896. }
  10897. /**
  10898. * This defines an action responsible to trigger several actions once triggered.
  10899. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10900. */
  10901. export class CombineAction extends Action {
  10902. /**
  10903. * The list of aggregated animations to run.
  10904. */
  10905. children: Action[];
  10906. /**
  10907. * Instantiate the action
  10908. * @param triggerOptions defines the trigger options
  10909. * @param children defines the list of aggregated animations to run
  10910. * @param condition defines the trigger related conditions
  10911. */
  10912. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10913. /** @hidden */
  10914. _prepare(): void;
  10915. /**
  10916. * Execute the action and executes all the aggregated actions.
  10917. */
  10918. execute(evt: ActionEvent): void;
  10919. /**
  10920. * Serializes the actions and its related information.
  10921. * @param parent defines the object to serialize in
  10922. * @returns the serialized object
  10923. */
  10924. serialize(parent: any): any;
  10925. }
  10926. /**
  10927. * This defines an action responsible to run code (external event) once triggered.
  10928. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10929. */
  10930. export class ExecuteCodeAction extends Action {
  10931. /**
  10932. * The callback function to run.
  10933. */
  10934. func: (evt: ActionEvent) => void;
  10935. /**
  10936. * Instantiate the action
  10937. * @param triggerOptions defines the trigger options
  10938. * @param func defines the callback function to run
  10939. * @param condition defines the trigger related conditions
  10940. */
  10941. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10942. /**
  10943. * Execute the action and run the attached code.
  10944. */
  10945. execute(evt: ActionEvent): void;
  10946. }
  10947. /**
  10948. * This defines an action responsible to set the parent property of the target once triggered.
  10949. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10950. */
  10951. export class SetParentAction extends Action {
  10952. private _parent;
  10953. private _target;
  10954. /**
  10955. * Instantiate the action
  10956. * @param triggerOptions defines the trigger options
  10957. * @param target defines the target containing the parent property
  10958. * @param parent defines from where the animation should start (animation frame)
  10959. * @param condition defines the trigger related conditions
  10960. */
  10961. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10962. /** @hidden */
  10963. _prepare(): void;
  10964. /**
  10965. * Execute the action and set the parent property.
  10966. */
  10967. execute(): void;
  10968. /**
  10969. * Serializes the actions and its related information.
  10970. * @param parent defines the object to serialize in
  10971. * @returns the serialized object
  10972. */
  10973. serialize(parent: any): any;
  10974. }
  10975. }
  10976. declare module BABYLON {
  10977. /**
  10978. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10979. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10980. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10981. */
  10982. export class ActionManager extends AbstractActionManager {
  10983. /**
  10984. * Nothing
  10985. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10986. */
  10987. static readonly NothingTrigger: number;
  10988. /**
  10989. * On pick
  10990. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10991. */
  10992. static readonly OnPickTrigger: number;
  10993. /**
  10994. * On left pick
  10995. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10996. */
  10997. static readonly OnLeftPickTrigger: number;
  10998. /**
  10999. * On right pick
  11000. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11001. */
  11002. static readonly OnRightPickTrigger: number;
  11003. /**
  11004. * On center pick
  11005. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11006. */
  11007. static readonly OnCenterPickTrigger: number;
  11008. /**
  11009. * On pick down
  11010. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11011. */
  11012. static readonly OnPickDownTrigger: number;
  11013. /**
  11014. * On double pick
  11015. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11016. */
  11017. static readonly OnDoublePickTrigger: number;
  11018. /**
  11019. * On pick up
  11020. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11021. */
  11022. static readonly OnPickUpTrigger: number;
  11023. /**
  11024. * On pick out.
  11025. * This trigger will only be raised if you also declared a OnPickDown
  11026. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11027. */
  11028. static readonly OnPickOutTrigger: number;
  11029. /**
  11030. * On long press
  11031. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11032. */
  11033. static readonly OnLongPressTrigger: number;
  11034. /**
  11035. * On pointer over
  11036. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11037. */
  11038. static readonly OnPointerOverTrigger: number;
  11039. /**
  11040. * On pointer out
  11041. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11042. */
  11043. static readonly OnPointerOutTrigger: number;
  11044. /**
  11045. * On every frame
  11046. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11047. */
  11048. static readonly OnEveryFrameTrigger: number;
  11049. /**
  11050. * On intersection enter
  11051. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11052. */
  11053. static readonly OnIntersectionEnterTrigger: number;
  11054. /**
  11055. * On intersection exit
  11056. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11057. */
  11058. static readonly OnIntersectionExitTrigger: number;
  11059. /**
  11060. * On key down
  11061. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11062. */
  11063. static readonly OnKeyDownTrigger: number;
  11064. /**
  11065. * On key up
  11066. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11067. */
  11068. static readonly OnKeyUpTrigger: number;
  11069. private _scene;
  11070. /**
  11071. * Creates a new action manager
  11072. * @param scene defines the hosting scene
  11073. */
  11074. constructor(scene: Scene);
  11075. /**
  11076. * Releases all associated resources
  11077. */
  11078. dispose(): void;
  11079. /**
  11080. * Gets hosting scene
  11081. * @returns the hosting scene
  11082. */
  11083. getScene(): Scene;
  11084. /**
  11085. * Does this action manager handles actions of any of the given triggers
  11086. * @param triggers defines the triggers to be tested
  11087. * @return a boolean indicating whether one (or more) of the triggers is handled
  11088. */
  11089. hasSpecificTriggers(triggers: number[]): boolean;
  11090. /**
  11091. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11092. * speed.
  11093. * @param triggerA defines the trigger to be tested
  11094. * @param triggerB defines the trigger to be tested
  11095. * @return a boolean indicating whether one (or more) of the triggers is handled
  11096. */
  11097. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11098. /**
  11099. * Does this action manager handles actions of a given trigger
  11100. * @param trigger defines the trigger to be tested
  11101. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11102. * @return whether the trigger is handled
  11103. */
  11104. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11105. /**
  11106. * Does this action manager has pointer triggers
  11107. */
  11108. get hasPointerTriggers(): boolean;
  11109. /**
  11110. * Does this action manager has pick triggers
  11111. */
  11112. get hasPickTriggers(): boolean;
  11113. /**
  11114. * Registers an action to this action manager
  11115. * @param action defines the action to be registered
  11116. * @return the action amended (prepared) after registration
  11117. */
  11118. registerAction(action: IAction): Nullable<IAction>;
  11119. /**
  11120. * Unregisters an action to this action manager
  11121. * @param action defines the action to be unregistered
  11122. * @return a boolean indicating whether the action has been unregistered
  11123. */
  11124. unregisterAction(action: IAction): Boolean;
  11125. /**
  11126. * Process a specific trigger
  11127. * @param trigger defines the trigger to process
  11128. * @param evt defines the event details to be processed
  11129. */
  11130. processTrigger(trigger: number, evt?: IActionEvent): void;
  11131. /** @hidden */
  11132. _getEffectiveTarget(target: any, propertyPath: string): any;
  11133. /** @hidden */
  11134. _getProperty(propertyPath: string): string;
  11135. /**
  11136. * Serialize this manager to a JSON object
  11137. * @param name defines the property name to store this manager
  11138. * @returns a JSON representation of this manager
  11139. */
  11140. serialize(name: string): any;
  11141. /**
  11142. * Creates a new ActionManager from a JSON data
  11143. * @param parsedActions defines the JSON data to read from
  11144. * @param object defines the hosting mesh
  11145. * @param scene defines the hosting scene
  11146. */
  11147. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11148. /**
  11149. * Get a trigger name by index
  11150. * @param trigger defines the trigger index
  11151. * @returns a trigger name
  11152. */
  11153. static GetTriggerName(trigger: number): string;
  11154. }
  11155. }
  11156. declare module BABYLON {
  11157. /**
  11158. * Class representing a ray with position and direction
  11159. */
  11160. export class Ray {
  11161. /** origin point */
  11162. origin: Vector3;
  11163. /** direction */
  11164. direction: Vector3;
  11165. /** length of the ray */
  11166. length: number;
  11167. private static readonly _TmpVector3;
  11168. private _tmpRay;
  11169. /**
  11170. * Creates a new ray
  11171. * @param origin origin point
  11172. * @param direction direction
  11173. * @param length length of the ray
  11174. */
  11175. constructor(
  11176. /** origin point */
  11177. origin: Vector3,
  11178. /** direction */
  11179. direction: Vector3,
  11180. /** length of the ray */
  11181. length?: number);
  11182. /**
  11183. * Checks if the ray intersects a box
  11184. * This does not account for the ray length by design to improve perfs.
  11185. * @param minimum bound of the box
  11186. * @param maximum bound of the box
  11187. * @param intersectionTreshold extra extend to be added to the box in all direction
  11188. * @returns if the box was hit
  11189. */
  11190. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11191. /**
  11192. * Checks if the ray intersects a box
  11193. * This does not account for the ray lenght by design to improve perfs.
  11194. * @param box the bounding box to check
  11195. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11196. * @returns if the box was hit
  11197. */
  11198. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11199. /**
  11200. * If the ray hits a sphere
  11201. * @param sphere the bounding sphere to check
  11202. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11203. * @returns true if it hits the sphere
  11204. */
  11205. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11206. /**
  11207. * If the ray hits a triange
  11208. * @param vertex0 triangle vertex
  11209. * @param vertex1 triangle vertex
  11210. * @param vertex2 triangle vertex
  11211. * @returns intersection information if hit
  11212. */
  11213. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11214. /**
  11215. * Checks if ray intersects a plane
  11216. * @param plane the plane to check
  11217. * @returns the distance away it was hit
  11218. */
  11219. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11220. /**
  11221. * Calculate the intercept of a ray on a given axis
  11222. * @param axis to check 'x' | 'y' | 'z'
  11223. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11224. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11225. */
  11226. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11227. /**
  11228. * Checks if ray intersects a mesh
  11229. * @param mesh the mesh to check
  11230. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11231. * @returns picking info of the intersection
  11232. */
  11233. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11234. /**
  11235. * Checks if ray intersects a mesh
  11236. * @param meshes the meshes to check
  11237. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11238. * @param results array to store result in
  11239. * @returns Array of picking infos
  11240. */
  11241. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11242. private _comparePickingInfo;
  11243. private static smallnum;
  11244. private static rayl;
  11245. /**
  11246. * Intersection test between the ray and a given segment within a given tolerance (threshold)
  11247. * @param sega the first point of the segment to test the intersection against
  11248. * @param segb the second point of the segment to test the intersection against
  11249. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11250. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11251. */
  11252. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11253. /**
  11254. * Update the ray from viewport position
  11255. * @param x position
  11256. * @param y y position
  11257. * @param viewportWidth viewport width
  11258. * @param viewportHeight viewport height
  11259. * @param world world matrix
  11260. * @param view view matrix
  11261. * @param projection projection matrix
  11262. * @returns this ray updated
  11263. */
  11264. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11265. /**
  11266. * Creates a ray with origin and direction of 0,0,0
  11267. * @returns the new ray
  11268. */
  11269. static Zero(): Ray;
  11270. /**
  11271. * Creates a new ray from screen space and viewport
  11272. * @param x position
  11273. * @param y y position
  11274. * @param viewportWidth viewport width
  11275. * @param viewportHeight viewport height
  11276. * @param world world matrix
  11277. * @param view view matrix
  11278. * @param projection projection matrix
  11279. * @returns new ray
  11280. */
  11281. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11282. /**
  11283. * 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
  11284. * transformed to the given world matrix.
  11285. * @param origin The origin point
  11286. * @param end The end point
  11287. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11288. * @returns the new ray
  11289. */
  11290. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  11291. /**
  11292. * Transforms a ray by a matrix
  11293. * @param ray ray to transform
  11294. * @param matrix matrix to apply
  11295. * @returns the resulting new ray
  11296. */
  11297. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11298. /**
  11299. * Transforms a ray by a matrix
  11300. * @param ray ray to transform
  11301. * @param matrix matrix to apply
  11302. * @param result ray to store result in
  11303. */
  11304. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11305. /**
  11306. * Unproject a ray from screen space to object space
  11307. * @param sourceX defines the screen space x coordinate to use
  11308. * @param sourceY defines the screen space y coordinate to use
  11309. * @param viewportWidth defines the current width of the viewport
  11310. * @param viewportHeight defines the current height of the viewport
  11311. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11312. * @param view defines the view matrix to use
  11313. * @param projection defines the projection matrix to use
  11314. */
  11315. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11316. }
  11317. /**
  11318. * Type used to define predicate used to select faces when a mesh intersection is detected
  11319. */
  11320. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11321. interface Scene {
  11322. /** @hidden */
  11323. _tempPickingRay: Nullable<Ray>;
  11324. /** @hidden */
  11325. _cachedRayForTransform: Ray;
  11326. /** @hidden */
  11327. _pickWithRayInverseMatrix: Matrix;
  11328. /** @hidden */
  11329. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11330. /** @hidden */
  11331. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11332. /** @hidden */
  11333. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate, skipBoundingInfo?: boolean): Nullable<PickingInfo>;
  11334. }
  11335. }
  11336. declare module BABYLON {
  11337. /**
  11338. * Groups all the scene component constants in one place to ease maintenance.
  11339. * @hidden
  11340. */
  11341. export class SceneComponentConstants {
  11342. static readonly NAME_EFFECTLAYER: string;
  11343. static readonly NAME_LAYER: string;
  11344. static readonly NAME_LENSFLARESYSTEM: string;
  11345. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11346. static readonly NAME_PARTICLESYSTEM: string;
  11347. static readonly NAME_GAMEPAD: string;
  11348. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11349. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11350. static readonly NAME_PREPASSRENDERER: string;
  11351. static readonly NAME_DEPTHRENDERER: string;
  11352. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11353. static readonly NAME_SPRITE: string;
  11354. static readonly NAME_SUBSURFACE: string;
  11355. static readonly NAME_OUTLINERENDERER: string;
  11356. static readonly NAME_PROCEDURALTEXTURE: string;
  11357. static readonly NAME_SHADOWGENERATOR: string;
  11358. static readonly NAME_OCTREE: string;
  11359. static readonly NAME_PHYSICSENGINE: string;
  11360. static readonly NAME_AUDIO: string;
  11361. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11362. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11363. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11364. static readonly STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11365. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11366. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  11367. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11368. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11369. static readonly STEP_BEFORERENDERTARGETDRAW_PREPASS: number;
  11370. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11371. static readonly STEP_BEFORERENDERINGMESH_PREPASS: number;
  11372. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11373. static readonly STEP_AFTERRENDERINGMESH_PREPASS: number;
  11374. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11375. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11376. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11377. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11378. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11379. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11380. static readonly STEP_AFTERRENDERTARGETDRAW_PREPASS: number;
  11381. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11382. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  11383. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11384. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11385. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11386. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11387. static readonly STEP_AFTERRENDER_AUDIO: number;
  11388. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11389. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11390. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11391. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11392. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11393. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  11394. static readonly STEP_BEFORERENDERTARGETCLEARSTAGE_PREPASS: number;
  11395. static readonly STEP_POINTERMOVE_SPRITE: number;
  11396. static readonly STEP_POINTERDOWN_SPRITE: number;
  11397. static readonly STEP_POINTERUP_SPRITE: number;
  11398. }
  11399. /**
  11400. * This represents a scene component.
  11401. *
  11402. * This is used to decouple the dependency the scene is having on the different workloads like
  11403. * layers, post processes...
  11404. */
  11405. export interface ISceneComponent {
  11406. /**
  11407. * The name of the component. Each component must have a unique name.
  11408. */
  11409. name: string;
  11410. /**
  11411. * The scene the component belongs to.
  11412. */
  11413. scene: Scene;
  11414. /**
  11415. * Register the component to one instance of a scene.
  11416. */
  11417. register(): void;
  11418. /**
  11419. * Rebuilds the elements related to this component in case of
  11420. * context lost for instance.
  11421. */
  11422. rebuild(): void;
  11423. /**
  11424. * Disposes the component and the associated ressources.
  11425. */
  11426. dispose(): void;
  11427. }
  11428. /**
  11429. * This represents a SERIALIZABLE scene component.
  11430. *
  11431. * This extends Scene Component to add Serialization methods on top.
  11432. */
  11433. export interface ISceneSerializableComponent extends ISceneComponent {
  11434. /**
  11435. * Adds all the elements from the container to the scene
  11436. * @param container the container holding the elements
  11437. */
  11438. addFromContainer(container: AbstractScene): void;
  11439. /**
  11440. * Removes all the elements in the container from the scene
  11441. * @param container contains the elements to remove
  11442. * @param dispose if the removed element should be disposed (default: false)
  11443. */
  11444. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11445. /**
  11446. * Serializes the component data to the specified json object
  11447. * @param serializationObject The object to serialize to
  11448. */
  11449. serialize(serializationObject: any): void;
  11450. }
  11451. /**
  11452. * Strong typing of a Mesh related stage step action
  11453. */
  11454. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11455. /**
  11456. * Strong typing of a Evaluate Sub Mesh related stage step action
  11457. */
  11458. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11459. /**
  11460. * Strong typing of a pre active Mesh related stage step action
  11461. */
  11462. export type PreActiveMeshStageAction = (mesh: AbstractMesh) => void;
  11463. /**
  11464. * Strong typing of a Camera related stage step action
  11465. */
  11466. export type CameraStageAction = (camera: Camera) => void;
  11467. /**
  11468. * Strong typing of a Camera Frame buffer related stage step action
  11469. */
  11470. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11471. /**
  11472. * Strong typing of a Render Target related stage step action
  11473. */
  11474. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture, faceIndex?: number, layer?: number) => void;
  11475. /**
  11476. * Strong typing of a RenderingGroup related stage step action
  11477. */
  11478. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11479. /**
  11480. * Strong typing of a Mesh Render related stage step action
  11481. */
  11482. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch, effect: Nullable<Effect>) => void;
  11483. /**
  11484. * Strong typing of a simple stage step action
  11485. */
  11486. export type SimpleStageAction = () => void;
  11487. /**
  11488. * Strong typing of a render target action.
  11489. */
  11490. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11491. /**
  11492. * Strong typing of a pointer move action.
  11493. */
  11494. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11495. /**
  11496. * Strong typing of a pointer up/down action.
  11497. */
  11498. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: IPointerEvent) => Nullable<PickingInfo>;
  11499. /**
  11500. * Representation of a stage in the scene (Basically a list of ordered steps)
  11501. * @hidden
  11502. */
  11503. export class Stage<T extends Function> extends Array<{
  11504. index: number;
  11505. component: ISceneComponent;
  11506. action: T;
  11507. }> {
  11508. /**
  11509. * Hide ctor from the rest of the world.
  11510. * @param items The items to add.
  11511. */
  11512. private constructor();
  11513. /**
  11514. * Creates a new Stage.
  11515. * @returns A new instance of a Stage
  11516. */
  11517. static Create<T extends Function>(): Stage<T>;
  11518. /**
  11519. * Registers a step in an ordered way in the targeted stage.
  11520. * @param index Defines the position to register the step in
  11521. * @param component Defines the component attached to the step
  11522. * @param action Defines the action to launch during the step
  11523. */
  11524. registerStep(index: number, component: ISceneComponent, action: T): void;
  11525. /**
  11526. * Clears all the steps from the stage.
  11527. */
  11528. clear(): void;
  11529. }
  11530. }
  11531. declare module BABYLON {
  11532. interface Scene {
  11533. /** @hidden */
  11534. _pointerOverSprite: Nullable<Sprite>;
  11535. /** @hidden */
  11536. _pickedDownSprite: Nullable<Sprite>;
  11537. /** @hidden */
  11538. _tempSpritePickingRay: Nullable<Ray>;
  11539. /**
  11540. * All of the sprite managers added to this scene
  11541. * @see https://doc.babylonjs.com/babylon101/sprites
  11542. */
  11543. spriteManagers: Array<ISpriteManager>;
  11544. /**
  11545. * An event triggered when sprites rendering is about to start
  11546. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11547. */
  11548. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11549. /**
  11550. * An event triggered when sprites rendering is done
  11551. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11552. */
  11553. onAfterSpritesRenderingObservable: Observable<Scene>;
  11554. /** @hidden */
  11555. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11556. /** Launch a ray to try to pick a sprite in the scene
  11557. * @param x position on screen
  11558. * @param y position on screen
  11559. * @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
  11560. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11561. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11562. * @returns a PickingInfo
  11563. */
  11564. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11565. /** Use the given ray to pick a sprite in the scene
  11566. * @param ray The ray (in world space) to use to pick meshes
  11567. * @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
  11568. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11569. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11570. * @returns a PickingInfo
  11571. */
  11572. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11573. /** @hidden */
  11574. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11575. /** Launch a ray to try to pick sprites in the scene
  11576. * @param x position on screen
  11577. * @param y position on screen
  11578. * @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
  11579. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11580. * @returns a PickingInfo array
  11581. */
  11582. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11583. /** Use the given ray to pick sprites in the scene
  11584. * @param ray The ray (in world space) to use to pick meshes
  11585. * @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
  11586. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11587. * @returns a PickingInfo array
  11588. */
  11589. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11590. /**
  11591. * Force the sprite under the pointer
  11592. * @param sprite defines the sprite to use
  11593. */
  11594. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11595. /**
  11596. * Gets the sprite under the pointer
  11597. * @returns a Sprite or null if no sprite is under the pointer
  11598. */
  11599. getPointerOverSprite(): Nullable<Sprite>;
  11600. }
  11601. /**
  11602. * Defines the sprite scene component responsible to manage sprites
  11603. * in a given scene.
  11604. */
  11605. export class SpriteSceneComponent implements ISceneComponent {
  11606. /**
  11607. * The component name helpfull to identify the component in the list of scene components.
  11608. */
  11609. readonly name: string;
  11610. /**
  11611. * The scene the component belongs to.
  11612. */
  11613. scene: Scene;
  11614. /** @hidden */
  11615. private _spritePredicate;
  11616. /**
  11617. * Creates a new instance of the component for the given scene
  11618. * @param scene Defines the scene to register the component in
  11619. */
  11620. constructor(scene: Scene);
  11621. /**
  11622. * Registers the component in a given scene
  11623. */
  11624. register(): void;
  11625. /**
  11626. * Rebuilds the elements related to this component in case of
  11627. * context lost for instance.
  11628. */
  11629. rebuild(): void;
  11630. /**
  11631. * Disposes the component and the associated resources.
  11632. */
  11633. dispose(): void;
  11634. private _pickSpriteButKeepRay;
  11635. private _pointerMove;
  11636. private _pointerDown;
  11637. private _pointerUp;
  11638. }
  11639. }
  11640. declare module BABYLON {
  11641. /**
  11642. * Class used to provide helper for timing
  11643. */
  11644. export class TimingTools {
  11645. /**
  11646. * Polyfill for setImmediate
  11647. * @param action defines the action to execute after the current execution block
  11648. */
  11649. static SetImmediate(action: () => void): void;
  11650. }
  11651. }
  11652. declare module BABYLON {
  11653. /**
  11654. * Class used to enable instantiation of objects by class name
  11655. */
  11656. export class InstantiationTools {
  11657. /**
  11658. * Use this object to register external classes like custom textures or material
  11659. * to allow the loaders to instantiate them
  11660. */
  11661. static RegisteredExternalClasses: {
  11662. [key: string]: Object;
  11663. };
  11664. /**
  11665. * Tries to instantiate a new object from a given class name
  11666. * @param className defines the class name to instantiate
  11667. * @returns the new object or null if the system was not able to do the instantiation
  11668. */
  11669. static Instantiate(className: string): any;
  11670. }
  11671. }
  11672. declare module BABYLON {
  11673. /**
  11674. * Class used to host copy specific utilities
  11675. */
  11676. export class CopyTools {
  11677. /**
  11678. * Transform some pixel data to a base64 string
  11679. * @param pixels defines the pixel data to transform to base64
  11680. * @param size defines the width and height of the (texture) data
  11681. * @param invertY true if the data must be inverted for the Y coordinate during the conversion
  11682. * @returns The base64 encoded string or null
  11683. */
  11684. static GenerateBase64StringFromPixelData(pixels: ArrayBufferView, size: ISize, invertY?: boolean): Nullable<string>;
  11685. /**
  11686. * Reads the pixels stored in the webgl texture and returns them as a base64 string
  11687. * @param texture defines the texture to read pixels from
  11688. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  11689. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  11690. * @returns The base64 encoded string or null
  11691. */
  11692. static GenerateBase64StringFromTexture(texture: BaseTexture, faceIndex?: number, level?: number): Nullable<string>;
  11693. /**
  11694. * Reads the pixels stored in the webgl texture and returns them as a base64 string
  11695. * @param texture defines the texture to read pixels from
  11696. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  11697. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  11698. * @returns The base64 encoded string or null wrapped in a promise
  11699. */
  11700. static GenerateBase64StringFromTextureAsync(texture: BaseTexture, faceIndex?: number, level?: number): Promise<Nullable<string>>;
  11701. }
  11702. }
  11703. declare module BABYLON {
  11704. /**
  11705. * Define options used to create a depth texture
  11706. */
  11707. export class DepthTextureCreationOptions {
  11708. /** Specifies whether or not a stencil should be allocated in the texture */
  11709. generateStencil?: boolean;
  11710. /** Specifies whether or not bilinear filtering is enable on the texture */
  11711. bilinearFiltering?: boolean;
  11712. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  11713. comparisonFunction?: number;
  11714. /** Specifies if the created texture is a cube texture */
  11715. isCube?: boolean;
  11716. /** Specifies the sample count of the depth/stencil texture texture */
  11717. samples?: number;
  11718. }
  11719. }
  11720. declare module BABYLON {
  11721. interface ThinEngine {
  11722. /**
  11723. * Creates a depth stencil cube texture.
  11724. * This is only available in WebGL 2.
  11725. * @param size The size of face edge in the cube texture.
  11726. * @param options The options defining the cube texture.
  11727. * @returns The cube texture
  11728. */
  11729. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  11730. /**
  11731. * Creates a cube texture
  11732. * @param rootUrl defines the url where the files to load is located
  11733. * @param scene defines the current scene
  11734. * @param files defines the list of files to load (1 per face)
  11735. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11736. * @param onLoad defines an optional callback raised when the texture is loaded
  11737. * @param onError defines an optional callback raised if there is an issue to load the texture
  11738. * @param format defines the format of the data
  11739. * @param forcedExtension defines the extension to use to pick the right loader
  11740. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  11741. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11742. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11743. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  11744. * @param loaderOptions options to be passed to the loader
  11745. * @returns the cube texture as an InternalTexture
  11746. */
  11747. 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;
  11748. /**
  11749. * Creates a cube texture
  11750. * @param rootUrl defines the url where the files to load is located
  11751. * @param scene defines the current scene
  11752. * @param files defines the list of files to load (1 per face)
  11753. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11754. * @param onLoad defines an optional callback raised when the texture is loaded
  11755. * @param onError defines an optional callback raised if there is an issue to load the texture
  11756. * @param format defines the format of the data
  11757. * @param forcedExtension defines the extension to use to pick the right loader
  11758. * @returns the cube texture as an InternalTexture
  11759. */
  11760. 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;
  11761. /**
  11762. * Creates a cube texture
  11763. * @param rootUrl defines the url where the files to load is located
  11764. * @param scene defines the current scene
  11765. * @param files defines the list of files to load (1 per face)
  11766. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11767. * @param onLoad defines an optional callback raised when the texture is loaded
  11768. * @param onError defines an optional callback raised if there is an issue to load the texture
  11769. * @param format defines the format of the data
  11770. * @param forcedExtension defines the extension to use to pick the right loader
  11771. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  11772. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11773. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11774. * @returns the cube texture as an InternalTexture
  11775. */
  11776. 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;
  11777. /** @hidden */
  11778. 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;
  11779. /** @hidden */
  11780. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  11781. /** @hidden */
  11782. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  11783. /** @hidden */
  11784. _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;
  11785. /** @hidden */
  11786. _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;
  11787. /**
  11788. * @hidden
  11789. */
  11790. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  11791. }
  11792. }
  11793. declare module BABYLON {
  11794. /**
  11795. * Class for creating a cube texture
  11796. */
  11797. export class CubeTexture extends BaseTexture {
  11798. private _delayedOnLoad;
  11799. /**
  11800. * Observable triggered once the texture has been loaded.
  11801. */
  11802. onLoadObservable: Observable<CubeTexture>;
  11803. /**
  11804. * The url of the texture
  11805. */
  11806. url: string;
  11807. /**
  11808. * Gets or sets the center of the bounding box associated with the cube texture.
  11809. * It must define where the camera used to render the texture was set
  11810. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  11811. */
  11812. boundingBoxPosition: Vector3;
  11813. private _boundingBoxSize;
  11814. /**
  11815. * Gets or sets the size of the bounding box associated with the cube texture
  11816. * When defined, the cubemap will switch to local mode
  11817. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  11818. * @example https://www.babylonjs-playground.com/#RNASML
  11819. */
  11820. set boundingBoxSize(value: Vector3);
  11821. /**
  11822. * Returns the bounding box size
  11823. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  11824. */
  11825. get boundingBoxSize(): Vector3;
  11826. protected _rotationY: number;
  11827. /**
  11828. * Sets texture matrix rotation angle around Y axis in radians.
  11829. */
  11830. set rotationY(value: number);
  11831. /**
  11832. * Gets texture matrix rotation angle around Y axis radians.
  11833. */
  11834. get rotationY(): number;
  11835. /**
  11836. * Are mip maps generated for this texture or not.
  11837. */
  11838. get noMipmap(): boolean;
  11839. private _noMipmap;
  11840. private _files;
  11841. protected _forcedExtension: Nullable<string>;
  11842. private _extensions;
  11843. private _textureMatrix;
  11844. private _format;
  11845. private _createPolynomials;
  11846. private _loaderOptions;
  11847. /**
  11848. * Creates a cube texture from an array of image urls
  11849. * @param files defines an array of image urls
  11850. * @param scene defines the hosting scene
  11851. * @param noMipmap specifies if mip maps are not used
  11852. * @returns a cube texture
  11853. */
  11854. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  11855. /**
  11856. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  11857. * @param url defines the url of the prefiltered texture
  11858. * @param scene defines the scene the texture is attached to
  11859. * @param forcedExtension defines the extension of the file if different from the url
  11860. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  11861. * @return the prefiltered texture
  11862. */
  11863. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  11864. /**
  11865. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  11866. * as prefiltered data.
  11867. * @param rootUrl defines the url of the texture or the root name of the six images
  11868. * @param null defines the scene or engine the texture is attached to
  11869. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  11870. * @param noMipmap defines if mipmaps should be created or not
  11871. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  11872. * @param onLoad defines a callback triggered at the end of the file load if no errors occurred
  11873. * @param onError defines a callback triggered in case of error during load
  11874. * @param format defines the internal format to use for the texture once loaded
  11875. * @param prefiltered defines whether or not the texture is created from prefiltered data
  11876. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  11877. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  11878. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11879. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11880. * @param loaderOptions options to be passed to the loader
  11881. * @return the cube texture
  11882. */
  11883. 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);
  11884. /**
  11885. * Get the current class name of the texture useful for serialization or dynamic coding.
  11886. * @returns "CubeTexture"
  11887. */
  11888. getClassName(): string;
  11889. /**
  11890. * Update the url (and optional buffer) of this texture if url was null during construction.
  11891. * @param url the url of the texture
  11892. * @param forcedExtension defines the extension to use
  11893. * @param onLoad callback called when the texture is loaded (defaults to null)
  11894. * @param prefiltered Defines whether the updated texture is prefiltered or not
  11895. */
  11896. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  11897. /**
  11898. * Delays loading of the cube texture
  11899. * @param forcedExtension defines the extension to use
  11900. */
  11901. delayLoad(forcedExtension?: string): void;
  11902. /**
  11903. * Returns the reflection texture matrix
  11904. * @returns the reflection texture matrix
  11905. */
  11906. getReflectionTextureMatrix(): Matrix;
  11907. /**
  11908. * Sets the reflection texture matrix
  11909. * @param value Reflection texture matrix
  11910. */
  11911. setReflectionTextureMatrix(value: Matrix): void;
  11912. /**
  11913. * Parses text to create a cube texture
  11914. * @param parsedTexture define the serialized text to read from
  11915. * @param scene defines the hosting scene
  11916. * @param rootUrl defines the root url of the cube texture
  11917. * @returns a cube texture
  11918. */
  11919. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  11920. /**
  11921. * Makes a clone, or deep copy, of the cube texture
  11922. * @returns a new cube texture
  11923. */
  11924. clone(): CubeTexture;
  11925. }
  11926. }
  11927. declare module BABYLON {
  11928. /**
  11929. * The color grading curves provide additional color adjustment that is applied after any color grading transform (3D LUT).
  11930. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  11931. * 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;
  11932. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  11933. */
  11934. export class ColorCurves {
  11935. private _dirty;
  11936. private _tempColor;
  11937. private _globalCurve;
  11938. private _highlightsCurve;
  11939. private _midtonesCurve;
  11940. private _shadowsCurve;
  11941. private _positiveCurve;
  11942. private _negativeCurve;
  11943. private _globalHue;
  11944. private _globalDensity;
  11945. private _globalSaturation;
  11946. private _globalExposure;
  11947. /**
  11948. * Gets the global Hue value.
  11949. * 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).
  11950. */
  11951. get globalHue(): number;
  11952. /**
  11953. * Sets the global Hue value.
  11954. * 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).
  11955. */
  11956. set globalHue(value: number);
  11957. /**
  11958. * Gets the global Density value.
  11959. * 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.
  11960. * Values less than zero provide a filter of opposite hue.
  11961. */
  11962. get globalDensity(): number;
  11963. /**
  11964. * Sets the global Density value.
  11965. * 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.
  11966. * Values less than zero provide a filter of opposite hue.
  11967. */
  11968. set globalDensity(value: number);
  11969. /**
  11970. * Gets the global Saturation value.
  11971. * 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.
  11972. */
  11973. get globalSaturation(): number;
  11974. /**
  11975. * Sets the global Saturation value.
  11976. * 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.
  11977. */
  11978. set globalSaturation(value: number);
  11979. /**
  11980. * Gets the global Exposure value.
  11981. * 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.
  11982. */
  11983. get globalExposure(): number;
  11984. /**
  11985. * Sets the global Exposure value.
  11986. * 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.
  11987. */
  11988. set globalExposure(value: number);
  11989. private _highlightsHue;
  11990. private _highlightsDensity;
  11991. private _highlightsSaturation;
  11992. private _highlightsExposure;
  11993. /**
  11994. * Gets the highlights Hue value.
  11995. * 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).
  11996. */
  11997. get highlightsHue(): number;
  11998. /**
  11999. * Sets the highlights Hue value.
  12000. * 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).
  12001. */
  12002. set highlightsHue(value: number);
  12003. /**
  12004. * Gets the highlights Density value.
  12005. * 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.
  12006. * Values less than zero provide a filter of opposite hue.
  12007. */
  12008. get highlightsDensity(): number;
  12009. /**
  12010. * Sets the highlights Density value.
  12011. * 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.
  12012. * Values less than zero provide a filter of opposite hue.
  12013. */
  12014. set highlightsDensity(value: number);
  12015. /**
  12016. * Gets the highlights Saturation value.
  12017. * 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.
  12018. */
  12019. get highlightsSaturation(): number;
  12020. /**
  12021. * Sets the highlights Saturation value.
  12022. * 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.
  12023. */
  12024. set highlightsSaturation(value: number);
  12025. /**
  12026. * Gets the highlights Exposure value.
  12027. * 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.
  12028. */
  12029. get highlightsExposure(): number;
  12030. /**
  12031. * Sets the highlights Exposure value.
  12032. * 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.
  12033. */
  12034. set highlightsExposure(value: number);
  12035. private _midtonesHue;
  12036. private _midtonesDensity;
  12037. private _midtonesSaturation;
  12038. private _midtonesExposure;
  12039. /**
  12040. * Gets the midtones Hue value.
  12041. * 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).
  12042. */
  12043. get midtonesHue(): number;
  12044. /**
  12045. * Sets the midtones Hue value.
  12046. * 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).
  12047. */
  12048. set midtonesHue(value: number);
  12049. /**
  12050. * Gets the midtones Density value.
  12051. * 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.
  12052. * Values less than zero provide a filter of opposite hue.
  12053. */
  12054. get midtonesDensity(): number;
  12055. /**
  12056. * Sets the midtones Density value.
  12057. * 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.
  12058. * Values less than zero provide a filter of opposite hue.
  12059. */
  12060. set midtonesDensity(value: number);
  12061. /**
  12062. * Gets the midtones Saturation value.
  12063. * 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.
  12064. */
  12065. get midtonesSaturation(): number;
  12066. /**
  12067. * Sets the midtones Saturation value.
  12068. * 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.
  12069. */
  12070. set midtonesSaturation(value: number);
  12071. /**
  12072. * Gets the midtones Exposure value.
  12073. * 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.
  12074. */
  12075. get midtonesExposure(): number;
  12076. /**
  12077. * Sets the midtones Exposure value.
  12078. * 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.
  12079. */
  12080. set midtonesExposure(value: number);
  12081. private _shadowsHue;
  12082. private _shadowsDensity;
  12083. private _shadowsSaturation;
  12084. private _shadowsExposure;
  12085. /**
  12086. * Gets the shadows Hue value.
  12087. * 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).
  12088. */
  12089. get shadowsHue(): number;
  12090. /**
  12091. * Sets the shadows Hue value.
  12092. * 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).
  12093. */
  12094. set shadowsHue(value: number);
  12095. /**
  12096. * Gets the shadows Density value.
  12097. * 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.
  12098. * Values less than zero provide a filter of opposite hue.
  12099. */
  12100. get shadowsDensity(): number;
  12101. /**
  12102. * Sets the shadows Density value.
  12103. * 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.
  12104. * Values less than zero provide a filter of opposite hue.
  12105. */
  12106. set shadowsDensity(value: number);
  12107. /**
  12108. * Gets the shadows Saturation value.
  12109. * 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.
  12110. */
  12111. get shadowsSaturation(): number;
  12112. /**
  12113. * Sets the shadows Saturation value.
  12114. * 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.
  12115. */
  12116. set shadowsSaturation(value: number);
  12117. /**
  12118. * Gets the shadows Exposure value.
  12119. * 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.
  12120. */
  12121. get shadowsExposure(): number;
  12122. /**
  12123. * Sets the shadows Exposure value.
  12124. * 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.
  12125. */
  12126. set shadowsExposure(value: number);
  12127. /**
  12128. * Returns the class name
  12129. * @returns The class name
  12130. */
  12131. getClassName(): string;
  12132. /**
  12133. * Binds the color curves to the shader.
  12134. * @param colorCurves The color curve to bind
  12135. * @param effect The effect to bind to
  12136. * @param positiveUniform The positive uniform shader parameter
  12137. * @param neutralUniform The neutral uniform shader parameter
  12138. * @param negativeUniform The negative uniform shader parameter
  12139. */
  12140. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  12141. /**
  12142. * Prepare the list of uniforms associated with the ColorCurves effects.
  12143. * @param uniformsList The list of uniforms used in the effect
  12144. */
  12145. static PrepareUniforms(uniformsList: string[]): void;
  12146. /**
  12147. * Returns color grading data based on a hue, density, saturation and exposure value.
  12148. * @param filterHue The hue of the color filter.
  12149. * @param filterDensity The density of the color filter.
  12150. * @param saturation The saturation.
  12151. * @param exposure The exposure.
  12152. * @param result The result data container.
  12153. */
  12154. private getColorGradingDataToRef;
  12155. /**
  12156. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  12157. * @param value The input slider value in range [-100,100].
  12158. * @returns Adjusted value.
  12159. */
  12160. private static applyColorGradingSliderNonlinear;
  12161. /**
  12162. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  12163. * @param hue The hue (H) input.
  12164. * @param saturation The saturation (S) input.
  12165. * @param brightness The brightness (B) input.
  12166. * @result An RGBA color represented as Vector4.
  12167. */
  12168. private static fromHSBToRef;
  12169. /**
  12170. * Returns a value clamped between min and max
  12171. * @param value The value to clamp
  12172. * @param min The minimum of value
  12173. * @param max The maximum of value
  12174. * @returns The clamped value.
  12175. */
  12176. private static clamp;
  12177. /**
  12178. * Clones the current color curve instance.
  12179. * @return The cloned curves
  12180. */
  12181. clone(): ColorCurves;
  12182. /**
  12183. * Serializes the current color curve instance to a json representation.
  12184. * @return a JSON representation
  12185. */
  12186. serialize(): any;
  12187. /**
  12188. * Parses the color curve from a json representation.
  12189. * @param source the JSON source to parse
  12190. * @return The parsed curves
  12191. */
  12192. static Parse(source: any): ColorCurves;
  12193. }
  12194. }
  12195. declare module BABYLON {
  12196. /**
  12197. * Interface to follow in your material defines to integrate easily the
  12198. * Image processing functions.
  12199. * @hidden
  12200. */
  12201. export interface IImageProcessingConfigurationDefines {
  12202. IMAGEPROCESSING: boolean;
  12203. VIGNETTE: boolean;
  12204. VIGNETTEBLENDMODEMULTIPLY: boolean;
  12205. VIGNETTEBLENDMODEOPAQUE: boolean;
  12206. TONEMAPPING: boolean;
  12207. TONEMAPPING_ACES: boolean;
  12208. CONTRAST: boolean;
  12209. EXPOSURE: boolean;
  12210. COLORCURVES: boolean;
  12211. COLORGRADING: boolean;
  12212. COLORGRADING3D: boolean;
  12213. SAMPLER3DGREENDEPTH: boolean;
  12214. SAMPLER3DBGRMAP: boolean;
  12215. IMAGEPROCESSINGPOSTPROCESS: boolean;
  12216. }
  12217. /**
  12218. * @hidden
  12219. */
  12220. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  12221. IMAGEPROCESSING: boolean;
  12222. VIGNETTE: boolean;
  12223. VIGNETTEBLENDMODEMULTIPLY: boolean;
  12224. VIGNETTEBLENDMODEOPAQUE: boolean;
  12225. TONEMAPPING: boolean;
  12226. TONEMAPPING_ACES: boolean;
  12227. CONTRAST: boolean;
  12228. COLORCURVES: boolean;
  12229. COLORGRADING: boolean;
  12230. COLORGRADING3D: boolean;
  12231. SAMPLER3DGREENDEPTH: boolean;
  12232. SAMPLER3DBGRMAP: boolean;
  12233. IMAGEPROCESSINGPOSTPROCESS: boolean;
  12234. EXPOSURE: boolean;
  12235. constructor();
  12236. }
  12237. /**
  12238. * This groups together the common properties used for image processing either in direct forward pass
  12239. * or through post processing effect depending on the use of the image processing pipeline in your scene
  12240. * or not.
  12241. */
  12242. export class ImageProcessingConfiguration {
  12243. /**
  12244. * Default tone mapping applied in BabylonJS.
  12245. */
  12246. static readonly TONEMAPPING_STANDARD: number;
  12247. /**
  12248. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  12249. * to other engines rendering to increase portability.
  12250. */
  12251. static readonly TONEMAPPING_ACES: number;
  12252. /**
  12253. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  12254. */
  12255. colorCurves: Nullable<ColorCurves>;
  12256. private _colorCurvesEnabled;
  12257. /**
  12258. * Gets whether the color curves effect is enabled.
  12259. */
  12260. get colorCurvesEnabled(): boolean;
  12261. /**
  12262. * Sets whether the color curves effect is enabled.
  12263. */
  12264. set colorCurvesEnabled(value: boolean);
  12265. private _colorGradingTexture;
  12266. /**
  12267. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  12268. */
  12269. get colorGradingTexture(): Nullable<BaseTexture>;
  12270. /**
  12271. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  12272. */
  12273. set colorGradingTexture(value: Nullable<BaseTexture>);
  12274. private _colorGradingEnabled;
  12275. /**
  12276. * Gets whether the color grading effect is enabled.
  12277. */
  12278. get colorGradingEnabled(): boolean;
  12279. /**
  12280. * Sets whether the color grading effect is enabled.
  12281. */
  12282. set colorGradingEnabled(value: boolean);
  12283. private _colorGradingWithGreenDepth;
  12284. /**
  12285. * Gets whether the color grading effect is using a green depth for the 3d Texture.
  12286. */
  12287. get colorGradingWithGreenDepth(): boolean;
  12288. /**
  12289. * Sets whether the color grading effect is using a green depth for the 3d Texture.
  12290. */
  12291. set colorGradingWithGreenDepth(value: boolean);
  12292. private _colorGradingBGR;
  12293. /**
  12294. * Gets whether the color grading texture contains BGR values.
  12295. */
  12296. get colorGradingBGR(): boolean;
  12297. /**
  12298. * Sets whether the color grading texture contains BGR values.
  12299. */
  12300. set colorGradingBGR(value: boolean);
  12301. /** @hidden */
  12302. _exposure: number;
  12303. /**
  12304. * Gets the Exposure used in the effect.
  12305. */
  12306. get exposure(): number;
  12307. /**
  12308. * Sets the Exposure used in the effect.
  12309. */
  12310. set exposure(value: number);
  12311. private _toneMappingEnabled;
  12312. /**
  12313. * Gets whether the tone mapping effect is enabled.
  12314. */
  12315. get toneMappingEnabled(): boolean;
  12316. /**
  12317. * Sets whether the tone mapping effect is enabled.
  12318. */
  12319. set toneMappingEnabled(value: boolean);
  12320. private _toneMappingType;
  12321. /**
  12322. * Gets the type of tone mapping effect.
  12323. */
  12324. get toneMappingType(): number;
  12325. /**
  12326. * Sets the type of tone mapping effect used in BabylonJS.
  12327. */
  12328. set toneMappingType(value: number);
  12329. protected _contrast: number;
  12330. /**
  12331. * Gets the contrast used in the effect.
  12332. */
  12333. get contrast(): number;
  12334. /**
  12335. * Sets the contrast used in the effect.
  12336. */
  12337. set contrast(value: number);
  12338. /**
  12339. * Vignette stretch size.
  12340. */
  12341. vignetteStretch: number;
  12342. /**
  12343. * Vignette centre X Offset.
  12344. */
  12345. vignetteCentreX: number;
  12346. /**
  12347. * Vignette centre Y Offset.
  12348. */
  12349. vignetteCentreY: number;
  12350. /**
  12351. * Vignette weight or intensity of the vignette effect.
  12352. */
  12353. vignetteWeight: number;
  12354. /**
  12355. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  12356. * if vignetteEnabled is set to true.
  12357. */
  12358. vignetteColor: Color4;
  12359. /**
  12360. * Camera field of view used by the Vignette effect.
  12361. */
  12362. vignetteCameraFov: number;
  12363. private _vignetteBlendMode;
  12364. /**
  12365. * Gets the vignette blend mode allowing different kind of effect.
  12366. */
  12367. get vignetteBlendMode(): number;
  12368. /**
  12369. * Sets the vignette blend mode allowing different kind of effect.
  12370. */
  12371. set vignetteBlendMode(value: number);
  12372. private _vignetteEnabled;
  12373. /**
  12374. * Gets whether the vignette effect is enabled.
  12375. */
  12376. get vignetteEnabled(): boolean;
  12377. /**
  12378. * Sets whether the vignette effect is enabled.
  12379. */
  12380. set vignetteEnabled(value: boolean);
  12381. private _applyByPostProcess;
  12382. /**
  12383. * Gets whether the image processing is applied through a post process or not.
  12384. */
  12385. get applyByPostProcess(): boolean;
  12386. /**
  12387. * Sets whether the image processing is applied through a post process or not.
  12388. */
  12389. set applyByPostProcess(value: boolean);
  12390. private _isEnabled;
  12391. /**
  12392. * Gets whether the image processing is enabled or not.
  12393. */
  12394. get isEnabled(): boolean;
  12395. /**
  12396. * Sets whether the image processing is enabled or not.
  12397. */
  12398. set isEnabled(value: boolean);
  12399. /**
  12400. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  12401. */
  12402. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  12403. /**
  12404. * Method called each time the image processing information changes requires to recompile the effect.
  12405. */
  12406. protected _updateParameters(): void;
  12407. /**
  12408. * Gets the current class name.
  12409. * @return "ImageProcessingConfiguration"
  12410. */
  12411. getClassName(): string;
  12412. /**
  12413. * Prepare the list of uniforms associated with the Image Processing effects.
  12414. * @param uniforms The list of uniforms used in the effect
  12415. * @param defines the list of defines currently in use
  12416. */
  12417. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  12418. /**
  12419. * Prepare the list of samplers associated with the Image Processing effects.
  12420. * @param samplersList The list of uniforms used in the effect
  12421. * @param defines the list of defines currently in use
  12422. */
  12423. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  12424. /**
  12425. * Prepare the list of defines associated to the shader.
  12426. * @param defines the list of defines to complete
  12427. * @param forPostProcess Define if we are currently in post process mode or not
  12428. */
  12429. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  12430. /**
  12431. * Returns true if all the image processing information are ready.
  12432. * @returns True if ready, otherwise, false
  12433. */
  12434. isReady(): boolean;
  12435. /**
  12436. * Binds the image processing to the shader.
  12437. * @param effect The effect to bind to
  12438. * @param overrideAspectRatio Override the aspect ratio of the effect
  12439. */
  12440. bind(effect: Effect, overrideAspectRatio?: number): void;
  12441. /**
  12442. * Clones the current image processing instance.
  12443. * @return The cloned image processing
  12444. */
  12445. clone(): ImageProcessingConfiguration;
  12446. /**
  12447. * Serializes the current image processing instance to a json representation.
  12448. * @return a JSON representation
  12449. */
  12450. serialize(): any;
  12451. /**
  12452. * Parses the image processing from a json representation.
  12453. * @param source the JSON source to parse
  12454. * @return The parsed image processing
  12455. */
  12456. static Parse(source: any): ImageProcessingConfiguration;
  12457. private static _VIGNETTEMODE_MULTIPLY;
  12458. private static _VIGNETTEMODE_OPAQUE;
  12459. /**
  12460. * Used to apply the vignette as a mix with the pixel color.
  12461. */
  12462. static get VIGNETTEMODE_MULTIPLY(): number;
  12463. /**
  12464. * Used to apply the vignette as a replacement of the pixel color.
  12465. */
  12466. static get VIGNETTEMODE_OPAQUE(): number;
  12467. }
  12468. }
  12469. declare module BABYLON {
  12470. /** @hidden */
  12471. export var postprocessVertexShader: {
  12472. name: string;
  12473. shader: string;
  12474. };
  12475. }
  12476. declare module BABYLON {
  12477. /**
  12478. * Type used to define a render target texture size (either with a number or with a rect width and height)
  12479. */
  12480. export type RenderTargetTextureSize = number | {
  12481. width: number;
  12482. height: number;
  12483. layers?: number;
  12484. };
  12485. interface ThinEngine {
  12486. /**
  12487. * Creates a new render target texture
  12488. * @param size defines the size of the texture
  12489. * @param options defines the options used to create the texture
  12490. * @returns a new render target texture stored in an InternalTexture
  12491. */
  12492. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  12493. /**
  12494. * Creates a depth stencil texture.
  12495. * This is only available in WebGL 2 or with the depth texture extension available.
  12496. * @param size The size of face edge in the texture.
  12497. * @param options The options defining the texture.
  12498. * @returns The texture
  12499. */
  12500. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  12501. /** @hidden */
  12502. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  12503. }
  12504. }
  12505. declare module BABYLON {
  12506. /**
  12507. * Defines the kind of connection point for node based material
  12508. */
  12509. export enum NodeMaterialBlockConnectionPointTypes {
  12510. /** Float */
  12511. Float = 1,
  12512. /** Int */
  12513. Int = 2,
  12514. /** Vector2 */
  12515. Vector2 = 4,
  12516. /** Vector3 */
  12517. Vector3 = 8,
  12518. /** Vector4 */
  12519. Vector4 = 16,
  12520. /** Color3 */
  12521. Color3 = 32,
  12522. /** Color4 */
  12523. Color4 = 64,
  12524. /** Matrix */
  12525. Matrix = 128,
  12526. /** Custom object */
  12527. Object = 256,
  12528. /** Detect type based on connection */
  12529. AutoDetect = 1024,
  12530. /** Output type that will be defined by input type */
  12531. BasedOnInput = 2048
  12532. }
  12533. }
  12534. declare module BABYLON {
  12535. /**
  12536. * Enum used to define the target of a block
  12537. */
  12538. export enum NodeMaterialBlockTargets {
  12539. /** Vertex shader */
  12540. Vertex = 1,
  12541. /** Fragment shader */
  12542. Fragment = 2,
  12543. /** Neutral */
  12544. Neutral = 4,
  12545. /** Vertex and Fragment */
  12546. VertexAndFragment = 3
  12547. }
  12548. }
  12549. declare module BABYLON {
  12550. /**
  12551. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  12552. */
  12553. export enum NodeMaterialBlockConnectionPointMode {
  12554. /** Value is an uniform */
  12555. Uniform = 0,
  12556. /** Value is a mesh attribute */
  12557. Attribute = 1,
  12558. /** Value is a varying between vertex and fragment shaders */
  12559. Varying = 2,
  12560. /** Mode is undefined */
  12561. Undefined = 3
  12562. }
  12563. }
  12564. declare module BABYLON {
  12565. /**
  12566. * Enum used to define system values e.g. values automatically provided by the system
  12567. */
  12568. export enum NodeMaterialSystemValues {
  12569. /** World */
  12570. World = 1,
  12571. /** View */
  12572. View = 2,
  12573. /** Projection */
  12574. Projection = 3,
  12575. /** ViewProjection */
  12576. ViewProjection = 4,
  12577. /** WorldView */
  12578. WorldView = 5,
  12579. /** WorldViewProjection */
  12580. WorldViewProjection = 6,
  12581. /** CameraPosition */
  12582. CameraPosition = 7,
  12583. /** Fog Color */
  12584. FogColor = 8,
  12585. /** Delta time */
  12586. DeltaTime = 9
  12587. }
  12588. }
  12589. declare module BABYLON {
  12590. /**
  12591. * Represents a camera frustum
  12592. */
  12593. export class Frustum {
  12594. /**
  12595. * Gets the planes representing the frustum
  12596. * @param transform matrix to be applied to the returned planes
  12597. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  12598. */
  12599. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  12600. /**
  12601. * Gets the near frustum plane transformed by the transform matrix
  12602. * @param transform transformation matrix to be applied to the resulting frustum plane
  12603. * @param frustumPlane the resuling frustum plane
  12604. */
  12605. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12606. /**
  12607. * Gets the far frustum plane transformed by the transform matrix
  12608. * @param transform transformation matrix to be applied to the resulting frustum plane
  12609. * @param frustumPlane the resuling frustum plane
  12610. */
  12611. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12612. /**
  12613. * Gets the left frustum plane transformed by the transform matrix
  12614. * @param transform transformation matrix to be applied to the resulting frustum plane
  12615. * @param frustumPlane the resuling frustum plane
  12616. */
  12617. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12618. /**
  12619. * Gets the right frustum plane transformed by the transform matrix
  12620. * @param transform transformation matrix to be applied to the resulting frustum plane
  12621. * @param frustumPlane the resuling frustum plane
  12622. */
  12623. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12624. /**
  12625. * Gets the top frustum plane transformed by the transform matrix
  12626. * @param transform transformation matrix to be applied to the resulting frustum plane
  12627. * @param frustumPlane the resuling frustum plane
  12628. */
  12629. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12630. /**
  12631. * Gets the bottom frustum plane transformed by the transform matrix
  12632. * @param transform transformation matrix to be applied to the resulting frustum plane
  12633. * @param frustumPlane the resuling frustum plane
  12634. */
  12635. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12636. /**
  12637. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  12638. * @param transform transformation matrix to be applied to the resulting frustum planes
  12639. * @param frustumPlanes the resuling frustum planes
  12640. */
  12641. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  12642. }
  12643. }
  12644. declare module BABYLON {
  12645. /**
  12646. * Contains position and normal vectors for a vertex
  12647. */
  12648. export class PositionNormalVertex {
  12649. /** the position of the vertex (defaut: 0,0,0) */
  12650. position: Vector3;
  12651. /** the normal of the vertex (defaut: 0,1,0) */
  12652. normal: Vector3;
  12653. /**
  12654. * Creates a PositionNormalVertex
  12655. * @param position the position of the vertex (defaut: 0,0,0)
  12656. * @param normal the normal of the vertex (defaut: 0,1,0)
  12657. */
  12658. constructor(
  12659. /** the position of the vertex (defaut: 0,0,0) */
  12660. position?: Vector3,
  12661. /** the normal of the vertex (defaut: 0,1,0) */
  12662. normal?: Vector3);
  12663. /**
  12664. * Clones the PositionNormalVertex
  12665. * @returns the cloned PositionNormalVertex
  12666. */
  12667. clone(): PositionNormalVertex;
  12668. }
  12669. /**
  12670. * Contains position, normal and uv vectors for a vertex
  12671. */
  12672. export class PositionNormalTextureVertex {
  12673. /** the position of the vertex (defaut: 0,0,0) */
  12674. position: Vector3;
  12675. /** the normal of the vertex (defaut: 0,1,0) */
  12676. normal: Vector3;
  12677. /** the uv of the vertex (default: 0,0) */
  12678. uv: Vector2;
  12679. /**
  12680. * Creates a PositionNormalTextureVertex
  12681. * @param position the position of the vertex (defaut: 0,0,0)
  12682. * @param normal the normal of the vertex (defaut: 0,1,0)
  12683. * @param uv the uv of the vertex (default: 0,0)
  12684. */
  12685. constructor(
  12686. /** the position of the vertex (defaut: 0,0,0) */
  12687. position?: Vector3,
  12688. /** the normal of the vertex (defaut: 0,1,0) */
  12689. normal?: Vector3,
  12690. /** the uv of the vertex (default: 0,0) */
  12691. uv?: Vector2);
  12692. /**
  12693. * Clones the PositionNormalTextureVertex
  12694. * @returns the cloned PositionNormalTextureVertex
  12695. */
  12696. clone(): PositionNormalTextureVertex;
  12697. }
  12698. }
  12699. declare module BABYLON {
  12700. /**
  12701. * Enum defining the type of animations supported by InputBlock
  12702. */
  12703. export enum AnimatedInputBlockTypes {
  12704. /** No animation */
  12705. None = 0,
  12706. /** Time based animation. Will only work for floats */
  12707. Time = 1
  12708. }
  12709. }
  12710. declare module BABYLON {
  12711. /**
  12712. * Block used to expose an input value
  12713. */
  12714. export class InputBlock extends NodeMaterialBlock {
  12715. private _mode;
  12716. private _associatedVariableName;
  12717. private _storedValue;
  12718. private _valueCallback;
  12719. private _type;
  12720. private _animationType;
  12721. /** Gets or set a value used to limit the range of float values */
  12722. min: number;
  12723. /** Gets or set a value used to limit the range of float values */
  12724. max: number;
  12725. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  12726. isBoolean: boolean;
  12727. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  12728. matrixMode: number;
  12729. /** @hidden */
  12730. _systemValue: Nullable<NodeMaterialSystemValues>;
  12731. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  12732. isConstant: boolean;
  12733. /** Gets or sets the group to use to display this block in the Inspector */
  12734. groupInInspector: string;
  12735. /** Gets an observable raised when the value is changed */
  12736. onValueChangedObservable: Observable<InputBlock>;
  12737. /** Gets or sets a boolean indicating if content needs to be converted to gamma space (for color3/4 only) */
  12738. convertToGammaSpace: boolean;
  12739. /** Gets or sets a boolean indicating if content needs to be converted to linear space (for color3/4 only) */
  12740. convertToLinearSpace: boolean;
  12741. /**
  12742. * Gets or sets the connection point type (default is float)
  12743. */
  12744. get type(): NodeMaterialBlockConnectionPointTypes;
  12745. /**
  12746. * Creates a new InputBlock
  12747. * @param name defines the block name
  12748. * @param target defines the target of that block (Vertex by default)
  12749. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  12750. */
  12751. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  12752. /**
  12753. * Validates if a name is a reserve word.
  12754. * @param newName the new name to be given to the node.
  12755. * @returns false if the name is a reserve word, else true.
  12756. */
  12757. validateBlockName(newName: string): boolean;
  12758. /**
  12759. * Gets the output component
  12760. */
  12761. get output(): NodeMaterialConnectionPoint;
  12762. /**
  12763. * Set the source of this connection point to a vertex attribute
  12764. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  12765. * @returns the current connection point
  12766. */
  12767. setAsAttribute(attributeName?: string): InputBlock;
  12768. /**
  12769. * Set the source of this connection point to a system value
  12770. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  12771. * @returns the current connection point
  12772. */
  12773. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  12774. /**
  12775. * Gets or sets the value of that point.
  12776. * Please note that this value will be ignored if valueCallback is defined
  12777. */
  12778. get value(): any;
  12779. set value(value: any);
  12780. /**
  12781. * Gets or sets a callback used to get the value of that point.
  12782. * Please note that setting this value will force the connection point to ignore the value property
  12783. */
  12784. get valueCallback(): () => any;
  12785. set valueCallback(value: () => any);
  12786. /**
  12787. * Gets or sets the associated variable name in the shader
  12788. */
  12789. get associatedVariableName(): string;
  12790. set associatedVariableName(value: string);
  12791. /** Gets or sets the type of animation applied to the input */
  12792. get animationType(): AnimatedInputBlockTypes;
  12793. set animationType(value: AnimatedInputBlockTypes);
  12794. /**
  12795. * Gets a boolean indicating that this connection point not defined yet
  12796. */
  12797. get isUndefined(): boolean;
  12798. /**
  12799. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  12800. * In this case the connection point name must be the name of the uniform to use.
  12801. * Can only be set on inputs
  12802. */
  12803. get isUniform(): boolean;
  12804. set isUniform(value: boolean);
  12805. /**
  12806. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  12807. * In this case the connection point name must be the name of the attribute to use
  12808. * Can only be set on inputs
  12809. */
  12810. get isAttribute(): boolean;
  12811. set isAttribute(value: boolean);
  12812. /**
  12813. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  12814. * Can only be set on exit points
  12815. */
  12816. get isVarying(): boolean;
  12817. set isVarying(value: boolean);
  12818. /**
  12819. * Gets a boolean indicating that the current connection point is a system value
  12820. */
  12821. get isSystemValue(): boolean;
  12822. /**
  12823. * Gets or sets the current well known value or null if not defined as a system value
  12824. */
  12825. get systemValue(): Nullable<NodeMaterialSystemValues>;
  12826. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  12827. /**
  12828. * Gets the current class name
  12829. * @returns the class name
  12830. */
  12831. getClassName(): string;
  12832. /**
  12833. * Animate the input if animationType !== None
  12834. * @param scene defines the rendering scene
  12835. */
  12836. animate(scene: Scene): void;
  12837. private _emitDefine;
  12838. initialize(state: NodeMaterialBuildState): void;
  12839. /**
  12840. * Set the input block to its default value (based on its type)
  12841. */
  12842. setDefaultValue(): void;
  12843. private _emitConstant;
  12844. /** @hidden */
  12845. get _noContextSwitch(): boolean;
  12846. private _emit;
  12847. /** @hidden */
  12848. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  12849. /** @hidden */
  12850. _transmit(effect: Effect, scene: Scene): void;
  12851. protected _buildBlock(state: NodeMaterialBuildState): void;
  12852. protected _dumpPropertiesCode(): string;
  12853. dispose(): void;
  12854. serialize(): any;
  12855. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12856. }
  12857. }
  12858. declare module BABYLON {
  12859. /**
  12860. * Enum used to define the compatibility state between two connection points
  12861. */
  12862. export enum NodeMaterialConnectionPointCompatibilityStates {
  12863. /** Points are compatibles */
  12864. Compatible = 0,
  12865. /** Points are incompatible because of their types */
  12866. TypeIncompatible = 1,
  12867. /** Points are incompatible because of their targets (vertex vs fragment) */
  12868. TargetIncompatible = 2
  12869. }
  12870. /**
  12871. * Defines the direction of a connection point
  12872. */
  12873. export enum NodeMaterialConnectionPointDirection {
  12874. /** Input */
  12875. Input = 0,
  12876. /** Output */
  12877. Output = 1
  12878. }
  12879. /**
  12880. * Defines a connection point for a block
  12881. */
  12882. export class NodeMaterialConnectionPoint {
  12883. /**
  12884. * Checks if two types are equivalent
  12885. * @param type1 type 1 to check
  12886. * @param type2 type 2 to check
  12887. * @returns true if both types are equivalent, else false
  12888. */
  12889. static AreEquivalentTypes(type1: number, type2: number): boolean;
  12890. /** @hidden */
  12891. _ownerBlock: NodeMaterialBlock;
  12892. /** @hidden */
  12893. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  12894. private _endpoints;
  12895. private _associatedVariableName;
  12896. private _direction;
  12897. /** @hidden */
  12898. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  12899. /** @hidden */
  12900. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  12901. /** @hidden */
  12902. _acceptedConnectionPointType: Nullable<NodeMaterialConnectionPoint>;
  12903. private _type;
  12904. /** @hidden */
  12905. _enforceAssociatedVariableName: boolean;
  12906. /** Gets the direction of the point */
  12907. get direction(): NodeMaterialConnectionPointDirection;
  12908. /** Indicates that this connection point needs dual validation before being connected to another point */
  12909. needDualDirectionValidation: boolean;
  12910. /**
  12911. * Gets or sets the additional types supported by this connection point
  12912. */
  12913. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  12914. /**
  12915. * Gets or sets the additional types excluded by this connection point
  12916. */
  12917. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  12918. /**
  12919. * Observable triggered when this point is connected
  12920. */
  12921. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  12922. /**
  12923. * Gets or sets the associated variable name in the shader
  12924. */
  12925. get associatedVariableName(): string;
  12926. set associatedVariableName(value: string);
  12927. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  12928. get innerType(): NodeMaterialBlockConnectionPointTypes;
  12929. /**
  12930. * Gets or sets the connection point type (default is float)
  12931. */
  12932. get type(): NodeMaterialBlockConnectionPointTypes;
  12933. set type(value: NodeMaterialBlockConnectionPointTypes);
  12934. /**
  12935. * Gets or sets the connection point name
  12936. */
  12937. name: string;
  12938. /**
  12939. * Gets or sets the connection point name
  12940. */
  12941. displayName: string;
  12942. /**
  12943. * Gets or sets a boolean indicating that this connection point can be omitted
  12944. */
  12945. isOptional: boolean;
  12946. /**
  12947. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  12948. */
  12949. isExposedOnFrame: boolean;
  12950. /**
  12951. * Gets or sets number indicating the position that the port is exposed to on a frame
  12952. */
  12953. exposedPortPosition: number;
  12954. /**
  12955. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  12956. */
  12957. define: string;
  12958. /** @hidden */
  12959. _prioritizeVertex: boolean;
  12960. private _target;
  12961. /** Gets or sets the target of that connection point */
  12962. get target(): NodeMaterialBlockTargets;
  12963. set target(value: NodeMaterialBlockTargets);
  12964. /**
  12965. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  12966. */
  12967. get isConnected(): boolean;
  12968. /**
  12969. * Gets a boolean indicating that the current point is connected to an input block
  12970. */
  12971. get isConnectedToInputBlock(): boolean;
  12972. /**
  12973. * Gets a the connected input block (if any)
  12974. */
  12975. get connectInputBlock(): Nullable<InputBlock>;
  12976. /** Get the other side of the connection (if any) */
  12977. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  12978. /** Get the block that owns this connection point */
  12979. get ownerBlock(): NodeMaterialBlock;
  12980. /** Get the block connected on the other side of this connection (if any) */
  12981. get sourceBlock(): Nullable<NodeMaterialBlock>;
  12982. /** Get the block connected on the endpoints of this connection (if any) */
  12983. get connectedBlocks(): Array<NodeMaterialBlock>;
  12984. /** Gets the list of connected endpoints */
  12985. get endpoints(): NodeMaterialConnectionPoint[];
  12986. /** Gets a boolean indicating if that output point is connected to at least one input */
  12987. get hasEndpoints(): boolean;
  12988. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  12989. get isConnectedInVertexShader(): boolean;
  12990. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  12991. get isConnectedInFragmentShader(): boolean;
  12992. /**
  12993. * Creates a block suitable to be used as an input for this input point.
  12994. * If null is returned, a block based on the point type will be created.
  12995. * @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
  12996. */
  12997. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  12998. /**
  12999. * Creates a new connection point
  13000. * @param name defines the connection point name
  13001. * @param ownerBlock defines the block hosting this connection point
  13002. * @param direction defines the direction of the connection point
  13003. */
  13004. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  13005. /**
  13006. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  13007. * @returns the class name
  13008. */
  13009. getClassName(): string;
  13010. /**
  13011. * Gets a boolean indicating if the current point can be connected to another point
  13012. * @param connectionPoint defines the other connection point
  13013. * @returns a boolean
  13014. */
  13015. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  13016. /**
  13017. * Gets a number indicating if the current point can be connected to another point
  13018. * @param connectionPoint defines the other connection point
  13019. * @returns a number defining the compatibility state
  13020. */
  13021. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  13022. /**
  13023. * Connect this point to another connection point
  13024. * @param connectionPoint defines the other connection point
  13025. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  13026. * @returns the current connection point
  13027. */
  13028. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  13029. /**
  13030. * Disconnect this point from one of his endpoint
  13031. * @param endpoint defines the other connection point
  13032. * @returns the current connection point
  13033. */
  13034. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  13035. /**
  13036. * Serializes this point in a JSON representation
  13037. * @param isInput defines if the connection point is an input (default is true)
  13038. * @returns the serialized point object
  13039. */
  13040. serialize(isInput?: boolean): any;
  13041. /**
  13042. * Release resources
  13043. */
  13044. dispose(): void;
  13045. }
  13046. }
  13047. declare module BABYLON {
  13048. /**
  13049. * Enum used to define the material modes
  13050. */
  13051. export enum NodeMaterialModes {
  13052. /** Regular material */
  13053. Material = 0,
  13054. /** For post process */
  13055. PostProcess = 1,
  13056. /** For particle system */
  13057. Particle = 2,
  13058. /** For procedural texture */
  13059. ProceduralTexture = 3
  13060. }
  13061. }
  13062. declare module BABYLON {
  13063. /** @hidden */
  13064. export var helperFunctions: {
  13065. name: string;
  13066. shader: string;
  13067. };
  13068. }
  13069. declare module BABYLON {
  13070. /**
  13071. * Block used to read a texture from a sampler
  13072. */
  13073. export class TextureBlock extends NodeMaterialBlock {
  13074. private _defineName;
  13075. private _linearDefineName;
  13076. private _gammaDefineName;
  13077. private _tempTextureRead;
  13078. private _samplerName;
  13079. private _transformedUVName;
  13080. private _textureTransformName;
  13081. private _textureInfoName;
  13082. private _mainUVName;
  13083. private _mainUVDefineName;
  13084. private _fragmentOnly;
  13085. protected _texture: Nullable<Texture>;
  13086. /**
  13087. * Gets or sets the texture associated with the node
  13088. */
  13089. get texture(): Nullable<Texture>;
  13090. set texture(texture: Nullable<Texture>);
  13091. /**
  13092. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  13093. */
  13094. convertToGammaSpace: boolean;
  13095. /**
  13096. * Gets or sets a boolean indicating if content needs to be converted to linear space
  13097. */
  13098. convertToLinearSpace: boolean;
  13099. /**
  13100. * Create a new TextureBlock
  13101. * @param name defines the block name
  13102. */
  13103. constructor(name: string, fragmentOnly?: boolean);
  13104. /**
  13105. * Gets the current class name
  13106. * @returns the class name
  13107. */
  13108. getClassName(): string;
  13109. /**
  13110. * Gets the uv input component
  13111. */
  13112. get uv(): NodeMaterialConnectionPoint;
  13113. /**
  13114. * Gets the rgba output component
  13115. */
  13116. get rgba(): NodeMaterialConnectionPoint;
  13117. /**
  13118. * Gets the rgb output component
  13119. */
  13120. get rgb(): NodeMaterialConnectionPoint;
  13121. /**
  13122. * Gets the r output component
  13123. */
  13124. get r(): NodeMaterialConnectionPoint;
  13125. /**
  13126. * Gets the g output component
  13127. */
  13128. get g(): NodeMaterialConnectionPoint;
  13129. /**
  13130. * Gets the b output component
  13131. */
  13132. get b(): NodeMaterialConnectionPoint;
  13133. /**
  13134. * Gets the a output component
  13135. */
  13136. get a(): NodeMaterialConnectionPoint;
  13137. get target(): NodeMaterialBlockTargets;
  13138. autoConfigure(material: NodeMaterial): void;
  13139. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  13140. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  13141. isReady(): boolean;
  13142. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  13143. private get _isMixed();
  13144. private _injectVertexCode;
  13145. private _writeTextureRead;
  13146. private _generateConversionCode;
  13147. private _writeOutput;
  13148. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  13149. protected _dumpPropertiesCode(): string;
  13150. serialize(): any;
  13151. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13152. }
  13153. }
  13154. declare module BABYLON {
  13155. /** @hidden */
  13156. export var reflectionFunction: {
  13157. name: string;
  13158. shader: string;
  13159. };
  13160. }
  13161. declare module BABYLON {
  13162. /**
  13163. * Base block used to read a reflection texture from a sampler
  13164. */
  13165. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  13166. /** @hidden */
  13167. _define3DName: string;
  13168. /** @hidden */
  13169. _defineCubicName: string;
  13170. /** @hidden */
  13171. _defineExplicitName: string;
  13172. /** @hidden */
  13173. _defineProjectionName: string;
  13174. /** @hidden */
  13175. _defineLocalCubicName: string;
  13176. /** @hidden */
  13177. _defineSphericalName: string;
  13178. /** @hidden */
  13179. _definePlanarName: string;
  13180. /** @hidden */
  13181. _defineEquirectangularName: string;
  13182. /** @hidden */
  13183. _defineMirroredEquirectangularFixedName: string;
  13184. /** @hidden */
  13185. _defineEquirectangularFixedName: string;
  13186. /** @hidden */
  13187. _defineSkyboxName: string;
  13188. /** @hidden */
  13189. _defineOppositeZ: string;
  13190. /** @hidden */
  13191. _cubeSamplerName: string;
  13192. /** @hidden */
  13193. _2DSamplerName: string;
  13194. protected _positionUVWName: string;
  13195. protected _directionWName: string;
  13196. protected _reflectionVectorName: string;
  13197. /** @hidden */
  13198. _reflectionCoordsName: string;
  13199. /** @hidden */
  13200. _reflectionMatrixName: string;
  13201. protected _reflectionColorName: string;
  13202. protected _texture: Nullable<BaseTexture>;
  13203. /**
  13204. * Gets or sets the texture associated with the node
  13205. */
  13206. get texture(): Nullable<BaseTexture>;
  13207. set texture(texture: Nullable<BaseTexture>);
  13208. /**
  13209. * Create a new ReflectionTextureBaseBlock
  13210. * @param name defines the block name
  13211. */
  13212. constructor(name: string);
  13213. /**
  13214. * Gets the current class name
  13215. * @returns the class name
  13216. */
  13217. getClassName(): string;
  13218. /**
  13219. * Gets the world position input component
  13220. */
  13221. abstract get position(): NodeMaterialConnectionPoint;
  13222. /**
  13223. * Gets the world position input component
  13224. */
  13225. abstract get worldPosition(): NodeMaterialConnectionPoint;
  13226. /**
  13227. * Gets the world normal input component
  13228. */
  13229. abstract get worldNormal(): NodeMaterialConnectionPoint;
  13230. /**
  13231. * Gets the world input component
  13232. */
  13233. abstract get world(): NodeMaterialConnectionPoint;
  13234. /**
  13235. * Gets the camera (or eye) position component
  13236. */
  13237. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  13238. /**
  13239. * Gets the view input component
  13240. */
  13241. abstract get view(): NodeMaterialConnectionPoint;
  13242. protected _getTexture(): Nullable<BaseTexture>;
  13243. autoConfigure(material: NodeMaterial): void;
  13244. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  13245. isReady(): boolean;
  13246. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  13247. /**
  13248. * Gets the code to inject in the vertex shader
  13249. * @param state current state of the node material building
  13250. * @returns the shader code
  13251. */
  13252. handleVertexSide(state: NodeMaterialBuildState): string;
  13253. /**
  13254. * Handles the inits for the fragment code path
  13255. * @param state node material build state
  13256. */
  13257. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  13258. /**
  13259. * Generates the reflection coords code for the fragment code path
  13260. * @param worldNormalVarName name of the world normal variable
  13261. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  13262. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  13263. * @returns the shader code
  13264. */
  13265. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  13266. /**
  13267. * Generates the reflection color code for the fragment code path
  13268. * @param lodVarName name of the lod variable
  13269. * @param swizzleLookupTexture swizzle to use for the final color variable
  13270. * @returns the shader code
  13271. */
  13272. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  13273. /**
  13274. * Generates the code corresponding to the connected output points
  13275. * @param state node material build state
  13276. * @param varName name of the variable to output
  13277. * @returns the shader code
  13278. */
  13279. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  13280. protected _buildBlock(state: NodeMaterialBuildState): this;
  13281. protected _dumpPropertiesCode(): string;
  13282. serialize(): any;
  13283. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13284. }
  13285. }
  13286. declare module BABYLON {
  13287. /**
  13288. * Defines a connection point to be used for points with a custom object type
  13289. */
  13290. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  13291. private _blockType;
  13292. private _blockName;
  13293. private _nameForCheking?;
  13294. /**
  13295. * Creates a new connection point
  13296. * @param name defines the connection point name
  13297. * @param ownerBlock defines the block hosting this connection point
  13298. * @param direction defines the direction of the connection point
  13299. */
  13300. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  13301. /**
  13302. * Gets a number indicating if the current point can be connected to another point
  13303. * @param connectionPoint defines the other connection point
  13304. * @returns a number defining the compatibility state
  13305. */
  13306. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  13307. /**
  13308. * Creates a block suitable to be used as an input for this input point.
  13309. * If null is returned, a block based on the point type will be created.
  13310. * @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
  13311. */
  13312. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  13313. }
  13314. }
  13315. declare module BABYLON {
  13316. /**
  13317. * Enum defining the type of properties that can be edited in the property pages in the NME
  13318. */
  13319. export enum PropertyTypeForEdition {
  13320. /** property is a boolean */
  13321. Boolean = 0,
  13322. /** property is a float */
  13323. Float = 1,
  13324. /** property is a Vector2 */
  13325. Vector2 = 2,
  13326. /** property is a list of values */
  13327. List = 3
  13328. }
  13329. /**
  13330. * Interface that defines an option in a variable of type list
  13331. */
  13332. export interface IEditablePropertyListOption {
  13333. /** label of the option */
  13334. "label": string;
  13335. /** value of the option */
  13336. "value": number;
  13337. }
  13338. /**
  13339. * Interface that defines the options available for an editable property
  13340. */
  13341. export interface IEditablePropertyOption {
  13342. /** min value */
  13343. "min"?: number;
  13344. /** max value */
  13345. "max"?: number;
  13346. /** notifiers: indicates which actions to take when the property is changed */
  13347. "notifiers"?: {
  13348. /** the material should be rebuilt */
  13349. "rebuild"?: boolean;
  13350. /** the preview should be updated */
  13351. "update"?: boolean;
  13352. };
  13353. /** list of the options for a variable of type list */
  13354. "options"?: IEditablePropertyListOption[];
  13355. }
  13356. /**
  13357. * Interface that describes an editable property
  13358. */
  13359. export interface IPropertyDescriptionForEdition {
  13360. /** name of the property */
  13361. "propertyName": string;
  13362. /** display name of the property */
  13363. "displayName": string;
  13364. /** type of the property */
  13365. "type": PropertyTypeForEdition;
  13366. /** group of the property - all properties with the same group value will be displayed in a specific section */
  13367. "groupName": string;
  13368. /** options for the property */
  13369. "options": IEditablePropertyOption;
  13370. }
  13371. /**
  13372. * Decorator that flags a property in a node material block as being editable
  13373. */
  13374. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  13375. }
  13376. declare module BABYLON {
  13377. /**
  13378. * Block used to implement the refraction part of the sub surface module of the PBR material
  13379. */
  13380. export class RefractionBlock extends NodeMaterialBlock {
  13381. /** @hidden */
  13382. _define3DName: string;
  13383. /** @hidden */
  13384. _refractionMatrixName: string;
  13385. /** @hidden */
  13386. _defineLODRefractionAlpha: string;
  13387. /** @hidden */
  13388. _defineLinearSpecularRefraction: string;
  13389. /** @hidden */
  13390. _defineOppositeZ: string;
  13391. /** @hidden */
  13392. _cubeSamplerName: string;
  13393. /** @hidden */
  13394. _2DSamplerName: string;
  13395. /** @hidden */
  13396. _vRefractionMicrosurfaceInfosName: string;
  13397. /** @hidden */
  13398. _vRefractionInfosName: string;
  13399. /** @hidden */
  13400. _vRefractionFilteringInfoName: string;
  13401. private _scene;
  13402. /**
  13403. * The properties below are set by the main PBR block prior to calling methods of this class.
  13404. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  13405. * It's less burden on the user side in the editor part.
  13406. */
  13407. /** @hidden */
  13408. viewConnectionPoint: NodeMaterialConnectionPoint;
  13409. /** @hidden */
  13410. indexOfRefractionConnectionPoint: NodeMaterialConnectionPoint;
  13411. /**
  13412. * This parameters will make the material used its opacity to control how much it is refracting against not.
  13413. * Materials half opaque for instance using refraction could benefit from this control.
  13414. */
  13415. linkRefractionWithTransparency: boolean;
  13416. /**
  13417. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  13418. */
  13419. invertRefractionY: boolean;
  13420. /**
  13421. * Gets or sets the texture associated with the node
  13422. */
  13423. texture: Nullable<BaseTexture>;
  13424. /**
  13425. * Create a new RefractionBlock
  13426. * @param name defines the block name
  13427. */
  13428. constructor(name: string);
  13429. /**
  13430. * Gets the current class name
  13431. * @returns the class name
  13432. */
  13433. getClassName(): string;
  13434. /**
  13435. * Gets the intensity input component
  13436. */
  13437. get intensity(): NodeMaterialConnectionPoint;
  13438. /**
  13439. * Gets the tint at distance input component
  13440. */
  13441. get tintAtDistance(): NodeMaterialConnectionPoint;
  13442. /**
  13443. * Gets the view input component
  13444. */
  13445. get view(): NodeMaterialConnectionPoint;
  13446. /**
  13447. * Gets the refraction object output component
  13448. */
  13449. get refraction(): NodeMaterialConnectionPoint;
  13450. /**
  13451. * Returns true if the block has a texture
  13452. */
  13453. get hasTexture(): boolean;
  13454. protected _getTexture(): Nullable<BaseTexture>;
  13455. autoConfigure(material: NodeMaterial): void;
  13456. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  13457. isReady(): boolean;
  13458. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  13459. /**
  13460. * Gets the main code of the block (fragment side)
  13461. * @param state current state of the node material building
  13462. * @returns the shader code
  13463. */
  13464. getCode(state: NodeMaterialBuildState): string;
  13465. protected _buildBlock(state: NodeMaterialBuildState): this;
  13466. protected _dumpPropertiesCode(): string;
  13467. serialize(): any;
  13468. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13469. }
  13470. }
  13471. declare module BABYLON {
  13472. /**
  13473. * Base block used as input for post process
  13474. */
  13475. export class CurrentScreenBlock extends NodeMaterialBlock {
  13476. private _samplerName;
  13477. private _linearDefineName;
  13478. private _gammaDefineName;
  13479. private _mainUVName;
  13480. private _tempTextureRead;
  13481. /**
  13482. * Gets or sets the texture associated with the node
  13483. */
  13484. texture: Nullable<BaseTexture>;
  13485. /**
  13486. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  13487. */
  13488. convertToGammaSpace: boolean;
  13489. /**
  13490. * Gets or sets a boolean indicating if content needs to be converted to linear space
  13491. */
  13492. convertToLinearSpace: boolean;
  13493. /**
  13494. * Create a new CurrentScreenBlock
  13495. * @param name defines the block name
  13496. */
  13497. constructor(name: string);
  13498. /**
  13499. * Gets the current class name
  13500. * @returns the class name
  13501. */
  13502. getClassName(): string;
  13503. /**
  13504. * Gets the uv input component
  13505. */
  13506. get uv(): NodeMaterialConnectionPoint;
  13507. /**
  13508. * Gets the rgba output component
  13509. */
  13510. get rgba(): NodeMaterialConnectionPoint;
  13511. /**
  13512. * Gets the rgb output component
  13513. */
  13514. get rgb(): NodeMaterialConnectionPoint;
  13515. /**
  13516. * Gets the r output component
  13517. */
  13518. get r(): NodeMaterialConnectionPoint;
  13519. /**
  13520. * Gets the g output component
  13521. */
  13522. get g(): NodeMaterialConnectionPoint;
  13523. /**
  13524. * Gets the b output component
  13525. */
  13526. get b(): NodeMaterialConnectionPoint;
  13527. /**
  13528. * Gets the a output component
  13529. */
  13530. get a(): NodeMaterialConnectionPoint;
  13531. /**
  13532. * Initialize the block and prepare the context for build
  13533. * @param state defines the state that will be used for the build
  13534. */
  13535. initialize(state: NodeMaterialBuildState): void;
  13536. get target(): NodeMaterialBlockTargets;
  13537. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  13538. isReady(): boolean;
  13539. private _injectVertexCode;
  13540. private _writeTextureRead;
  13541. private _writeOutput;
  13542. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  13543. serialize(): any;
  13544. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13545. }
  13546. }
  13547. declare module BABYLON {
  13548. /**
  13549. * Base block used for the particle texture
  13550. */
  13551. export class ParticleTextureBlock extends NodeMaterialBlock {
  13552. private _samplerName;
  13553. private _linearDefineName;
  13554. private _gammaDefineName;
  13555. private _tempTextureRead;
  13556. /**
  13557. * Gets or sets the texture associated with the node
  13558. */
  13559. texture: Nullable<BaseTexture>;
  13560. /**
  13561. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  13562. */
  13563. convertToGammaSpace: boolean;
  13564. /**
  13565. * Gets or sets a boolean indicating if content needs to be converted to linear space
  13566. */
  13567. convertToLinearSpace: boolean;
  13568. /**
  13569. * Create a new ParticleTextureBlock
  13570. * @param name defines the block name
  13571. */
  13572. constructor(name: string);
  13573. /**
  13574. * Gets the current class name
  13575. * @returns the class name
  13576. */
  13577. getClassName(): string;
  13578. /**
  13579. * Gets the uv input component
  13580. */
  13581. get uv(): NodeMaterialConnectionPoint;
  13582. /**
  13583. * Gets the rgba output component
  13584. */
  13585. get rgba(): NodeMaterialConnectionPoint;
  13586. /**
  13587. * Gets the rgb output component
  13588. */
  13589. get rgb(): NodeMaterialConnectionPoint;
  13590. /**
  13591. * Gets the r output component
  13592. */
  13593. get r(): NodeMaterialConnectionPoint;
  13594. /**
  13595. * Gets the g output component
  13596. */
  13597. get g(): NodeMaterialConnectionPoint;
  13598. /**
  13599. * Gets the b output component
  13600. */
  13601. get b(): NodeMaterialConnectionPoint;
  13602. /**
  13603. * Gets the a output component
  13604. */
  13605. get a(): NodeMaterialConnectionPoint;
  13606. /**
  13607. * Initialize the block and prepare the context for build
  13608. * @param state defines the state that will be used for the build
  13609. */
  13610. initialize(state: NodeMaterialBuildState): void;
  13611. autoConfigure(material: NodeMaterial): void;
  13612. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  13613. isReady(): boolean;
  13614. private _writeOutput;
  13615. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  13616. serialize(): any;
  13617. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13618. }
  13619. }
  13620. declare module BABYLON {
  13621. /**
  13622. * Class used to store shared data between 2 NodeMaterialBuildState
  13623. */
  13624. export class NodeMaterialBuildStateSharedData {
  13625. /**
  13626. * Gets the list of emitted varyings
  13627. */
  13628. temps: string[];
  13629. /**
  13630. * Gets the list of emitted varyings
  13631. */
  13632. varyings: string[];
  13633. /**
  13634. * Gets the varying declaration string
  13635. */
  13636. varyingDeclaration: string;
  13637. /**
  13638. * Input blocks
  13639. */
  13640. inputBlocks: InputBlock[];
  13641. /**
  13642. * Input blocks
  13643. */
  13644. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  13645. /**
  13646. * Bindable blocks (Blocks that need to set data to the effect)
  13647. */
  13648. bindableBlocks: NodeMaterialBlock[];
  13649. /**
  13650. * List of blocks that can provide a compilation fallback
  13651. */
  13652. blocksWithFallbacks: NodeMaterialBlock[];
  13653. /**
  13654. * List of blocks that can provide a define update
  13655. */
  13656. blocksWithDefines: NodeMaterialBlock[];
  13657. /**
  13658. * List of blocks that can provide a repeatable content
  13659. */
  13660. repeatableContentBlocks: NodeMaterialBlock[];
  13661. /**
  13662. * List of blocks that can provide a dynamic list of uniforms
  13663. */
  13664. dynamicUniformBlocks: NodeMaterialBlock[];
  13665. /**
  13666. * List of blocks that can block the isReady function for the material
  13667. */
  13668. blockingBlocks: NodeMaterialBlock[];
  13669. /**
  13670. * Gets the list of animated inputs
  13671. */
  13672. animatedInputs: InputBlock[];
  13673. /**
  13674. * Build Id used to avoid multiple recompilations
  13675. */
  13676. buildId: number;
  13677. /** List of emitted variables */
  13678. variableNames: {
  13679. [key: string]: number;
  13680. };
  13681. /** List of emitted defines */
  13682. defineNames: {
  13683. [key: string]: number;
  13684. };
  13685. /** Should emit comments? */
  13686. emitComments: boolean;
  13687. /** Emit build activity */
  13688. verbose: boolean;
  13689. /** Gets or sets the hosting scene */
  13690. scene: Scene;
  13691. /**
  13692. * Gets the compilation hints emitted at compilation time
  13693. */
  13694. hints: {
  13695. needWorldViewMatrix: boolean;
  13696. needWorldViewProjectionMatrix: boolean;
  13697. needAlphaBlending: boolean;
  13698. needAlphaTesting: boolean;
  13699. };
  13700. /**
  13701. * List of compilation checks
  13702. */
  13703. checks: {
  13704. emitVertex: boolean;
  13705. emitFragment: boolean;
  13706. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  13707. };
  13708. /**
  13709. * Is vertex program allowed to be empty?
  13710. */
  13711. allowEmptyVertexProgram: boolean;
  13712. /** Creates a new shared data */
  13713. constructor();
  13714. /**
  13715. * Emits console errors and exceptions if there is a failing check
  13716. */
  13717. emitErrors(): void;
  13718. }
  13719. }
  13720. declare module BABYLON {
  13721. /**
  13722. * Class used to store node based material build state
  13723. */
  13724. export class NodeMaterialBuildState {
  13725. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  13726. supportUniformBuffers: boolean;
  13727. /**
  13728. * Gets the list of emitted attributes
  13729. */
  13730. attributes: string[];
  13731. /**
  13732. * Gets the list of emitted uniforms
  13733. */
  13734. uniforms: string[];
  13735. /**
  13736. * Gets the list of emitted constants
  13737. */
  13738. constants: string[];
  13739. /**
  13740. * Gets the list of emitted samplers
  13741. */
  13742. samplers: string[];
  13743. /**
  13744. * Gets the list of emitted functions
  13745. */
  13746. functions: {
  13747. [key: string]: string;
  13748. };
  13749. /**
  13750. * Gets the list of emitted extensions
  13751. */
  13752. extensions: {
  13753. [key: string]: string;
  13754. };
  13755. /**
  13756. * Gets the target of the compilation state
  13757. */
  13758. target: NodeMaterialBlockTargets;
  13759. /**
  13760. * Gets the list of emitted counters
  13761. */
  13762. counters: {
  13763. [key: string]: number;
  13764. };
  13765. /**
  13766. * Shared data between multiple NodeMaterialBuildState instances
  13767. */
  13768. sharedData: NodeMaterialBuildStateSharedData;
  13769. /** @hidden */
  13770. _vertexState: NodeMaterialBuildState;
  13771. /** @hidden */
  13772. _attributeDeclaration: string;
  13773. /** @hidden */
  13774. _uniformDeclaration: string;
  13775. /** @hidden */
  13776. _constantDeclaration: string;
  13777. /** @hidden */
  13778. _samplerDeclaration: string;
  13779. /** @hidden */
  13780. _varyingTransfer: string;
  13781. /** @hidden */
  13782. _injectAtEnd: string;
  13783. private _repeatableContentAnchorIndex;
  13784. /** @hidden */
  13785. _builtCompilationString: string;
  13786. /**
  13787. * Gets the emitted compilation strings
  13788. */
  13789. compilationString: string;
  13790. /**
  13791. * Finalize the compilation strings
  13792. * @param state defines the current compilation state
  13793. */
  13794. finalize(state: NodeMaterialBuildState): void;
  13795. /** @hidden */
  13796. get _repeatableContentAnchor(): string;
  13797. /** @hidden */
  13798. _getFreeVariableName(prefix: string): string;
  13799. /** @hidden */
  13800. _getFreeDefineName(prefix: string): string;
  13801. /** @hidden */
  13802. _excludeVariableName(name: string): void;
  13803. /** @hidden */
  13804. _emit2DSampler(name: string): void;
  13805. /** @hidden */
  13806. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  13807. /** @hidden */
  13808. _emitExtension(name: string, extension: string, define?: string): void;
  13809. /** @hidden */
  13810. _emitFunction(name: string, code: string, comments: string): void;
  13811. /** @hidden */
  13812. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  13813. replaceStrings?: {
  13814. search: RegExp;
  13815. replace: string;
  13816. }[];
  13817. repeatKey?: string;
  13818. }): string;
  13819. /** @hidden */
  13820. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  13821. repeatKey?: string;
  13822. removeAttributes?: boolean;
  13823. removeUniforms?: boolean;
  13824. removeVaryings?: boolean;
  13825. removeIfDef?: boolean;
  13826. replaceStrings?: {
  13827. search: RegExp;
  13828. replace: string;
  13829. }[];
  13830. }, storeKey?: string): void;
  13831. /** @hidden */
  13832. _registerTempVariable(name: string): boolean;
  13833. /** @hidden */
  13834. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  13835. /** @hidden */
  13836. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  13837. /** @hidden */
  13838. _emitFloat(value: number): string;
  13839. }
  13840. }
  13841. declare module BABYLON {
  13842. /**
  13843. * Helper class used to generate session unique ID
  13844. */
  13845. export class UniqueIdGenerator {
  13846. private static _UniqueIdCounter;
  13847. /**
  13848. * Gets an unique (relatively to the current scene) Id
  13849. */
  13850. static get UniqueId(): number;
  13851. }
  13852. }
  13853. declare module BABYLON {
  13854. /**
  13855. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  13856. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  13857. */
  13858. export class EffectFallbacks implements IEffectFallbacks {
  13859. private _defines;
  13860. private _currentRank;
  13861. private _maxRank;
  13862. private _mesh;
  13863. /**
  13864. * Removes the fallback from the bound mesh.
  13865. */
  13866. unBindMesh(): void;
  13867. /**
  13868. * Adds a fallback on the specified property.
  13869. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  13870. * @param define The name of the define in the shader
  13871. */
  13872. addFallback(rank: number, define: string): void;
  13873. /**
  13874. * Sets the mesh to use CPU skinning when needing to fallback.
  13875. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  13876. * @param mesh The mesh to use the fallbacks.
  13877. */
  13878. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  13879. /**
  13880. * Checks to see if more fallbacks are still available.
  13881. */
  13882. get hasMoreFallbacks(): boolean;
  13883. /**
  13884. * Removes the defines that should be removed when falling back.
  13885. * @param currentDefines defines the current define statements for the shader.
  13886. * @param effect defines the current effect we try to compile
  13887. * @returns The resulting defines with defines of the current rank removed.
  13888. */
  13889. reduce(currentDefines: string, effect: Effect): string;
  13890. }
  13891. }
  13892. declare module BABYLON {
  13893. /**
  13894. * Defines a block that can be used inside a node based material
  13895. */
  13896. export class NodeMaterialBlock {
  13897. private _buildId;
  13898. private _buildTarget;
  13899. private _target;
  13900. private _isFinalMerger;
  13901. private _isInput;
  13902. private _name;
  13903. protected _isUnique: boolean;
  13904. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  13905. inputsAreExclusive: boolean;
  13906. /** @hidden */
  13907. _codeVariableName: string;
  13908. /** @hidden */
  13909. _inputs: NodeMaterialConnectionPoint[];
  13910. /** @hidden */
  13911. _outputs: NodeMaterialConnectionPoint[];
  13912. /** @hidden */
  13913. _preparationId: number;
  13914. /** @hidden */
  13915. readonly _originalTargetIsNeutral: boolean;
  13916. /**
  13917. * Gets the name of the block
  13918. */
  13919. get name(): string;
  13920. /**
  13921. * Sets the name of the block. Will check if the name is valid.
  13922. */
  13923. set name(newName: string);
  13924. /**
  13925. * Gets or sets the unique id of the node
  13926. */
  13927. uniqueId: number;
  13928. /**
  13929. * Gets or sets the comments associated with this block
  13930. */
  13931. comments: string;
  13932. /**
  13933. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  13934. */
  13935. get isUnique(): boolean;
  13936. /**
  13937. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  13938. */
  13939. get isFinalMerger(): boolean;
  13940. /**
  13941. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  13942. */
  13943. get isInput(): boolean;
  13944. /**
  13945. * Gets or sets the build Id
  13946. */
  13947. get buildId(): number;
  13948. set buildId(value: number);
  13949. /**
  13950. * Gets or sets the target of the block
  13951. */
  13952. get target(): NodeMaterialBlockTargets;
  13953. set target(value: NodeMaterialBlockTargets);
  13954. /**
  13955. * Gets the list of input points
  13956. */
  13957. get inputs(): NodeMaterialConnectionPoint[];
  13958. /** Gets the list of output points */
  13959. get outputs(): NodeMaterialConnectionPoint[];
  13960. /**
  13961. * Find an input by its name
  13962. * @param name defines the name of the input to look for
  13963. * @returns the input or null if not found
  13964. */
  13965. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  13966. /**
  13967. * Find an output by its name
  13968. * @param name defines the name of the output to look for
  13969. * @returns the output or null if not found
  13970. */
  13971. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  13972. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  13973. visibleInInspector: boolean;
  13974. /** Gets or sets a boolean indicating that this input can be edited from a collapsed frame*/
  13975. visibleOnFrame: boolean;
  13976. /**
  13977. * Creates a new NodeMaterialBlock
  13978. * @param name defines the block name
  13979. * @param target defines the target of that block (Vertex by default)
  13980. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  13981. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  13982. */
  13983. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  13984. /**
  13985. * Initialize the block and prepare the context for build
  13986. * @param state defines the state that will be used for the build
  13987. */
  13988. initialize(state: NodeMaterialBuildState): void;
  13989. /**
  13990. * Bind data to effect. Will only be called for blocks with isBindable === true
  13991. * @param effect defines the effect to bind data to
  13992. * @param nodeMaterial defines the hosting NodeMaterial
  13993. * @param mesh defines the mesh that will be rendered
  13994. * @param subMesh defines the submesh that will be rendered
  13995. */
  13996. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  13997. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  13998. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  13999. protected _writeFloat(value: number): string;
  14000. /**
  14001. * Gets the current class name e.g. "NodeMaterialBlock"
  14002. * @returns the class name
  14003. */
  14004. getClassName(): string;
  14005. /**
  14006. * Register a new input. Must be called inside a block constructor
  14007. * @param name defines the connection point name
  14008. * @param type defines the connection point type
  14009. * @param isOptional defines a boolean indicating that this input can be omitted
  14010. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  14011. * @param point an already created connection point. If not provided, create a new one
  14012. * @returns the current block
  14013. */
  14014. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  14015. /**
  14016. * Register a new output. Must be called inside a block constructor
  14017. * @param name defines the connection point name
  14018. * @param type defines the connection point type
  14019. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  14020. * @param point an already created connection point. If not provided, create a new one
  14021. * @returns the current block
  14022. */
  14023. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  14024. /**
  14025. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  14026. * @param forOutput defines an optional connection point to check compatibility with
  14027. * @returns the first available input or null
  14028. */
  14029. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  14030. /**
  14031. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  14032. * @param forBlock defines an optional block to check compatibility with
  14033. * @returns the first available input or null
  14034. */
  14035. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  14036. /**
  14037. * Gets the sibling of the given output
  14038. * @param current defines the current output
  14039. * @returns the next output in the list or null
  14040. */
  14041. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  14042. /**
  14043. * Connect current block with another block
  14044. * @param other defines the block to connect with
  14045. * @param options define the various options to help pick the right connections
  14046. * @returns the current block
  14047. */
  14048. connectTo(other: NodeMaterialBlock, options?: {
  14049. input?: string;
  14050. output?: string;
  14051. outputSwizzle?: string;
  14052. }): this | undefined;
  14053. protected _buildBlock(state: NodeMaterialBuildState): void;
  14054. /**
  14055. * Add uniforms, samplers and uniform buffers at compilation time
  14056. * @param state defines the state to update
  14057. * @param nodeMaterial defines the node material requesting the update
  14058. * @param defines defines the material defines to update
  14059. * @param uniformBuffers defines the list of uniform buffer names
  14060. */
  14061. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  14062. /**
  14063. * Add potential fallbacks if shader compilation fails
  14064. * @param mesh defines the mesh to be rendered
  14065. * @param fallbacks defines the current prioritized list of fallbacks
  14066. */
  14067. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  14068. /**
  14069. * Initialize defines for shader compilation
  14070. * @param mesh defines the mesh to be rendered
  14071. * @param nodeMaterial defines the node material requesting the update
  14072. * @param defines defines the material defines to update
  14073. * @param useInstances specifies that instances should be used
  14074. */
  14075. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  14076. /**
  14077. * Update defines for shader compilation
  14078. * @param mesh defines the mesh to be rendered
  14079. * @param nodeMaterial defines the node material requesting the update
  14080. * @param defines defines the material defines to update
  14081. * @param useInstances specifies that instances should be used
  14082. * @param subMesh defines which submesh to render
  14083. */
  14084. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  14085. /**
  14086. * Lets the block try to connect some inputs automatically
  14087. * @param material defines the hosting NodeMaterial
  14088. */
  14089. autoConfigure(material: NodeMaterial): void;
  14090. /**
  14091. * Function called when a block is declared as repeatable content generator
  14092. * @param vertexShaderState defines the current compilation state for the vertex shader
  14093. * @param fragmentShaderState defines the current compilation state for the fragment shader
  14094. * @param mesh defines the mesh to be rendered
  14095. * @param defines defines the material defines to update
  14096. */
  14097. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  14098. /**
  14099. * Checks if the block is ready
  14100. * @param mesh defines the mesh to be rendered
  14101. * @param nodeMaterial defines the node material requesting the update
  14102. * @param defines defines the material defines to update
  14103. * @param useInstances specifies that instances should be used
  14104. * @returns true if the block is ready
  14105. */
  14106. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  14107. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number, looseCoupling?: boolean): void;
  14108. private _processBuild;
  14109. /**
  14110. * Validates the new name for the block node.
  14111. * @param newName the new name to be given to the node.
  14112. * @returns false if the name is a reserve word, else true.
  14113. */
  14114. validateBlockName(newName: string): boolean;
  14115. /**
  14116. * Compile the current node and generate the shader code
  14117. * @param state defines the current compilation state (uniforms, samplers, current string)
  14118. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  14119. * @returns true if already built
  14120. */
  14121. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  14122. protected _inputRename(name: string): string;
  14123. protected _outputRename(name: string): string;
  14124. protected _dumpPropertiesCode(): string;
  14125. /** @hidden */
  14126. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  14127. /** @hidden */
  14128. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  14129. /**
  14130. * Clone the current block to a new identical block
  14131. * @param scene defines the hosting scene
  14132. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  14133. * @returns a copy of the current block
  14134. */
  14135. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  14136. /**
  14137. * Serializes this block in a JSON representation
  14138. * @returns the serialized block object
  14139. */
  14140. serialize(): any;
  14141. /** @hidden */
  14142. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  14143. private _deserializePortDisplayNamesAndExposedOnFrame;
  14144. /**
  14145. * Release resources
  14146. */
  14147. dispose(): void;
  14148. }
  14149. }
  14150. declare module BABYLON {
  14151. /**
  14152. * Base class of materials working in push mode in babylon JS
  14153. * @hidden
  14154. */
  14155. export class PushMaterial extends Material {
  14156. protected _activeEffect: Effect;
  14157. protected _normalMatrix: Matrix;
  14158. constructor(name: string, scene: Scene);
  14159. getEffect(): Effect;
  14160. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  14161. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  14162. /**
  14163. * Binds the given world matrix to the active effect
  14164. *
  14165. * @param world the matrix to bind
  14166. */
  14167. bindOnlyWorldMatrix(world: Matrix): void;
  14168. /**
  14169. * Binds the given normal matrix to the active effect
  14170. *
  14171. * @param normalMatrix the matrix to bind
  14172. */
  14173. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  14174. bind(world: Matrix, mesh?: Mesh): void;
  14175. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  14176. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  14177. }
  14178. }
  14179. declare module BABYLON {
  14180. /**
  14181. * Root class for all node material optimizers
  14182. */
  14183. export class NodeMaterialOptimizer {
  14184. /**
  14185. * Function used to optimize a NodeMaterial graph
  14186. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  14187. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  14188. */
  14189. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  14190. }
  14191. }
  14192. declare module BABYLON {
  14193. /**
  14194. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  14195. */
  14196. export class TransformBlock extends NodeMaterialBlock {
  14197. /**
  14198. * Defines the value to use to complement W value to transform it to a Vector4
  14199. */
  14200. complementW: number;
  14201. /**
  14202. * Defines the value to use to complement z value to transform it to a Vector4
  14203. */
  14204. complementZ: number;
  14205. /**
  14206. * Creates a new TransformBlock
  14207. * @param name defines the block name
  14208. */
  14209. constructor(name: string);
  14210. /**
  14211. * Gets the current class name
  14212. * @returns the class name
  14213. */
  14214. getClassName(): string;
  14215. /**
  14216. * Gets the vector input
  14217. */
  14218. get vector(): NodeMaterialConnectionPoint;
  14219. /**
  14220. * Gets the output component
  14221. */
  14222. get output(): NodeMaterialConnectionPoint;
  14223. /**
  14224. * Gets the xyz output component
  14225. */
  14226. get xyz(): NodeMaterialConnectionPoint;
  14227. /**
  14228. * Gets the matrix transform input
  14229. */
  14230. get transform(): NodeMaterialConnectionPoint;
  14231. protected _buildBlock(state: NodeMaterialBuildState): this;
  14232. /**
  14233. * Update defines for shader compilation
  14234. * @param mesh defines the mesh to be rendered
  14235. * @param nodeMaterial defines the node material requesting the update
  14236. * @param defines defines the material defines to update
  14237. * @param useInstances specifies that instances should be used
  14238. * @param subMesh defines which submesh to render
  14239. */
  14240. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  14241. serialize(): any;
  14242. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  14243. protected _dumpPropertiesCode(): string;
  14244. }
  14245. }
  14246. declare module BABYLON {
  14247. /**
  14248. * Block used to output the vertex position
  14249. */
  14250. export class VertexOutputBlock extends NodeMaterialBlock {
  14251. /**
  14252. * Creates a new VertexOutputBlock
  14253. * @param name defines the block name
  14254. */
  14255. constructor(name: string);
  14256. /**
  14257. * Gets the current class name
  14258. * @returns the class name
  14259. */
  14260. getClassName(): string;
  14261. /**
  14262. * Gets the vector input component
  14263. */
  14264. get vector(): NodeMaterialConnectionPoint;
  14265. protected _buildBlock(state: NodeMaterialBuildState): this;
  14266. }
  14267. }
  14268. declare module BABYLON {
  14269. /**
  14270. * Block used to output the final color
  14271. */
  14272. export class FragmentOutputBlock extends NodeMaterialBlock {
  14273. private _linearDefineName;
  14274. private _gammaDefineName;
  14275. /**
  14276. * Create a new FragmentOutputBlock
  14277. * @param name defines the block name
  14278. */
  14279. constructor(name: string);
  14280. /** Gets or sets a boolean indicating if content needs to be converted to gamma space */
  14281. convertToGammaSpace: boolean;
  14282. /** Gets or sets a boolean indicating if content needs to be converted to linear space */
  14283. convertToLinearSpace: boolean;
  14284. /**
  14285. * Gets the current class name
  14286. * @returns the class name
  14287. */
  14288. getClassName(): string;
  14289. /**
  14290. * Gets the rgba input component
  14291. */
  14292. get rgba(): NodeMaterialConnectionPoint;
  14293. /**
  14294. * Gets the rgb input component
  14295. */
  14296. get rgb(): NodeMaterialConnectionPoint;
  14297. /**
  14298. * Gets the a input component
  14299. */
  14300. get a(): NodeMaterialConnectionPoint;
  14301. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  14302. protected _buildBlock(state: NodeMaterialBuildState): this;
  14303. protected _dumpPropertiesCode(): string;
  14304. serialize(): any;
  14305. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  14306. }
  14307. }
  14308. declare module BABYLON {
  14309. /**
  14310. * Block used for the particle ramp gradient section
  14311. */
  14312. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  14313. /**
  14314. * Create a new ParticleRampGradientBlock
  14315. * @param name defines the block name
  14316. */
  14317. constructor(name: string);
  14318. /**
  14319. * Gets the current class name
  14320. * @returns the class name
  14321. */
  14322. getClassName(): string;
  14323. /**
  14324. * Gets the color input component
  14325. */
  14326. get color(): NodeMaterialConnectionPoint;
  14327. /**
  14328. * Gets the rampColor output component
  14329. */
  14330. get rampColor(): NodeMaterialConnectionPoint;
  14331. /**
  14332. * Initialize the block and prepare the context for build
  14333. * @param state defines the state that will be used for the build
  14334. */
  14335. initialize(state: NodeMaterialBuildState): void;
  14336. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  14337. }
  14338. }
  14339. declare module BABYLON {
  14340. /**
  14341. * Block used for the particle blend multiply section
  14342. */
  14343. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  14344. /**
  14345. * Create a new ParticleBlendMultiplyBlock
  14346. * @param name defines the block name
  14347. */
  14348. constructor(name: string);
  14349. /**
  14350. * Gets the current class name
  14351. * @returns the class name
  14352. */
  14353. getClassName(): string;
  14354. /**
  14355. * Gets the color input component
  14356. */
  14357. get color(): NodeMaterialConnectionPoint;
  14358. /**
  14359. * Gets the alphaTexture input component
  14360. */
  14361. get alphaTexture(): NodeMaterialConnectionPoint;
  14362. /**
  14363. * Gets the alphaColor input component
  14364. */
  14365. get alphaColor(): NodeMaterialConnectionPoint;
  14366. /**
  14367. * Gets the blendColor output component
  14368. */
  14369. get blendColor(): NodeMaterialConnectionPoint;
  14370. /**
  14371. * Initialize the block and prepare the context for build
  14372. * @param state defines the state that will be used for the build
  14373. */
  14374. initialize(state: NodeMaterialBuildState): void;
  14375. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  14376. }
  14377. }
  14378. declare module BABYLON {
  14379. /**
  14380. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  14381. */
  14382. export class VectorMergerBlock extends NodeMaterialBlock {
  14383. /**
  14384. * Create a new VectorMergerBlock
  14385. * @param name defines the block name
  14386. */
  14387. constructor(name: string);
  14388. /**
  14389. * Gets the current class name
  14390. * @returns the class name
  14391. */
  14392. getClassName(): string;
  14393. /**
  14394. * Gets the xyz component (input)
  14395. */
  14396. get xyzIn(): NodeMaterialConnectionPoint;
  14397. /**
  14398. * Gets the xy component (input)
  14399. */
  14400. get xyIn(): NodeMaterialConnectionPoint;
  14401. /**
  14402. * Gets the x component (input)
  14403. */
  14404. get x(): NodeMaterialConnectionPoint;
  14405. /**
  14406. * Gets the y component (input)
  14407. */
  14408. get y(): NodeMaterialConnectionPoint;
  14409. /**
  14410. * Gets the z component (input)
  14411. */
  14412. get z(): NodeMaterialConnectionPoint;
  14413. /**
  14414. * Gets the w component (input)
  14415. */
  14416. get w(): NodeMaterialConnectionPoint;
  14417. /**
  14418. * Gets the xyzw component (output)
  14419. */
  14420. get xyzw(): NodeMaterialConnectionPoint;
  14421. /**
  14422. * Gets the xyz component (output)
  14423. */
  14424. get xyzOut(): NodeMaterialConnectionPoint;
  14425. /**
  14426. * Gets the xy component (output)
  14427. */
  14428. get xyOut(): NodeMaterialConnectionPoint;
  14429. /**
  14430. * Gets the xy component (output)
  14431. * @deprecated Please use xyOut instead.
  14432. */
  14433. get xy(): NodeMaterialConnectionPoint;
  14434. /**
  14435. * Gets the xyz component (output)
  14436. * @deprecated Please use xyzOut instead.
  14437. */
  14438. get xyz(): NodeMaterialConnectionPoint;
  14439. protected _buildBlock(state: NodeMaterialBuildState): this;
  14440. }
  14441. }
  14442. declare module BABYLON {
  14443. /**
  14444. * Block used to remap a float from a range to a new one
  14445. */
  14446. export class RemapBlock extends NodeMaterialBlock {
  14447. /**
  14448. * Gets or sets the source range
  14449. */
  14450. sourceRange: Vector2;
  14451. /**
  14452. * Gets or sets the target range
  14453. */
  14454. targetRange: Vector2;
  14455. /**
  14456. * Creates a new RemapBlock
  14457. * @param name defines the block name
  14458. */
  14459. constructor(name: string);
  14460. /**
  14461. * Gets the current class name
  14462. * @returns the class name
  14463. */
  14464. getClassName(): string;
  14465. /**
  14466. * Gets the input component
  14467. */
  14468. get input(): NodeMaterialConnectionPoint;
  14469. /**
  14470. * Gets the source min input component
  14471. */
  14472. get sourceMin(): NodeMaterialConnectionPoint;
  14473. /**
  14474. * Gets the source max input component
  14475. */
  14476. get sourceMax(): NodeMaterialConnectionPoint;
  14477. /**
  14478. * Gets the target min input component
  14479. */
  14480. get targetMin(): NodeMaterialConnectionPoint;
  14481. /**
  14482. * Gets the target max input component
  14483. */
  14484. get targetMax(): NodeMaterialConnectionPoint;
  14485. /**
  14486. * Gets the output component
  14487. */
  14488. get output(): NodeMaterialConnectionPoint;
  14489. protected _buildBlock(state: NodeMaterialBuildState): this;
  14490. protected _dumpPropertiesCode(): string;
  14491. serialize(): any;
  14492. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  14493. }
  14494. }
  14495. declare module BABYLON {
  14496. /**
  14497. * Block used to multiply 2 values
  14498. */
  14499. export class MultiplyBlock extends NodeMaterialBlock {
  14500. /**
  14501. * Creates a new MultiplyBlock
  14502. * @param name defines the block name
  14503. */
  14504. constructor(name: string);
  14505. /**
  14506. * Gets the current class name
  14507. * @returns the class name
  14508. */
  14509. getClassName(): string;
  14510. /**
  14511. * Gets the left operand input component
  14512. */
  14513. get left(): NodeMaterialConnectionPoint;
  14514. /**
  14515. * Gets the right operand input component
  14516. */
  14517. get right(): NodeMaterialConnectionPoint;
  14518. /**
  14519. * Gets the output component
  14520. */
  14521. get output(): NodeMaterialConnectionPoint;
  14522. protected _buildBlock(state: NodeMaterialBuildState): this;
  14523. }
  14524. }
  14525. declare module BABYLON {
  14526. /** Interface used by value gradients (color, factor, ...) */
  14527. export interface IValueGradient {
  14528. /**
  14529. * Gets or sets the gradient value (between 0 and 1)
  14530. */
  14531. gradient: number;
  14532. }
  14533. /** Class used to store color4 gradient */
  14534. export class ColorGradient implements IValueGradient {
  14535. /**
  14536. * Gets or sets the gradient value (between 0 and 1)
  14537. */
  14538. gradient: number;
  14539. /**
  14540. * Gets or sets first associated color
  14541. */
  14542. color1: Color4;
  14543. /**
  14544. * Gets or sets second associated color
  14545. */
  14546. color2?: Color4 | undefined;
  14547. /**
  14548. * Creates a new color4 gradient
  14549. * @param gradient gets or sets the gradient value (between 0 and 1)
  14550. * @param color1 gets or sets first associated color
  14551. * @param color2 gets or sets first second color
  14552. */
  14553. constructor(
  14554. /**
  14555. * Gets or sets the gradient value (between 0 and 1)
  14556. */
  14557. gradient: number,
  14558. /**
  14559. * Gets or sets first associated color
  14560. */
  14561. color1: Color4,
  14562. /**
  14563. * Gets or sets second associated color
  14564. */
  14565. color2?: Color4 | undefined);
  14566. /**
  14567. * Will get a color picked randomly between color1 and color2.
  14568. * If color2 is undefined then color1 will be used
  14569. * @param result defines the target Color4 to store the result in
  14570. */
  14571. getColorToRef(result: Color4): void;
  14572. }
  14573. /** Class used to store color 3 gradient */
  14574. export class Color3Gradient implements IValueGradient {
  14575. /**
  14576. * Gets or sets the gradient value (between 0 and 1)
  14577. */
  14578. gradient: number;
  14579. /**
  14580. * Gets or sets the associated color
  14581. */
  14582. color: Color3;
  14583. /**
  14584. * Creates a new color3 gradient
  14585. * @param gradient gets or sets the gradient value (between 0 and 1)
  14586. * @param color gets or sets associated color
  14587. */
  14588. constructor(
  14589. /**
  14590. * Gets or sets the gradient value (between 0 and 1)
  14591. */
  14592. gradient: number,
  14593. /**
  14594. * Gets or sets the associated color
  14595. */
  14596. color: Color3);
  14597. }
  14598. /** Class used to store factor gradient */
  14599. export class FactorGradient implements IValueGradient {
  14600. /**
  14601. * Gets or sets the gradient value (between 0 and 1)
  14602. */
  14603. gradient: number;
  14604. /**
  14605. * Gets or sets first associated factor
  14606. */
  14607. factor1: number;
  14608. /**
  14609. * Gets or sets second associated factor
  14610. */
  14611. factor2?: number | undefined;
  14612. /**
  14613. * Creates a new factor gradient
  14614. * @param gradient gets or sets the gradient value (between 0 and 1)
  14615. * @param factor1 gets or sets first associated factor
  14616. * @param factor2 gets or sets second associated factor
  14617. */
  14618. constructor(
  14619. /**
  14620. * Gets or sets the gradient value (between 0 and 1)
  14621. */
  14622. gradient: number,
  14623. /**
  14624. * Gets or sets first associated factor
  14625. */
  14626. factor1: number,
  14627. /**
  14628. * Gets or sets second associated factor
  14629. */
  14630. factor2?: number | undefined);
  14631. /**
  14632. * Will get a number picked randomly between factor1 and factor2.
  14633. * If factor2 is undefined then factor1 will be used
  14634. * @returns the picked number
  14635. */
  14636. getFactor(): number;
  14637. }
  14638. /**
  14639. * Helper used to simplify some generic gradient tasks
  14640. */
  14641. export class GradientHelper {
  14642. /**
  14643. * Gets the current gradient from an array of IValueGradient
  14644. * @param ratio defines the current ratio to get
  14645. * @param gradients defines the array of IValueGradient
  14646. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  14647. */
  14648. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  14649. }
  14650. }
  14651. declare module BABYLON {
  14652. interface ThinEngine {
  14653. /**
  14654. * Creates a raw texture
  14655. * @param data defines the data to store in the texture
  14656. * @param width defines the width of the texture
  14657. * @param height defines the height of the texture
  14658. * @param format defines the format of the data
  14659. * @param generateMipMaps defines if the engine should generate the mip levels
  14660. * @param invertY defines if data must be stored with Y axis inverted
  14661. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  14662. * @param compression defines the compression used (null by default)
  14663. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14664. * @returns the raw texture inside an InternalTexture
  14665. */
  14666. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  14667. /**
  14668. * Update a raw texture
  14669. * @param texture defines the texture to update
  14670. * @param data defines the data to store in the texture
  14671. * @param format defines the format of the data
  14672. * @param invertY defines if data must be stored with Y axis inverted
  14673. */
  14674. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  14675. /**
  14676. * Update a raw texture
  14677. * @param texture defines the texture to update
  14678. * @param data defines the data to store in the texture
  14679. * @param format defines the format of the data
  14680. * @param invertY defines if data must be stored with Y axis inverted
  14681. * @param compression defines the compression used (null by default)
  14682. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14683. */
  14684. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  14685. /**
  14686. * Creates a new raw cube texture
  14687. * @param data defines the array of data to use to create each face
  14688. * @param size defines the size of the textures
  14689. * @param format defines the format of the data
  14690. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  14691. * @param generateMipMaps defines if the engine should generate the mip levels
  14692. * @param invertY defines if data must be stored with Y axis inverted
  14693. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14694. * @param compression defines the compression used (null by default)
  14695. * @returns the cube texture as an InternalTexture
  14696. */
  14697. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  14698. /**
  14699. * Update a raw cube texture
  14700. * @param texture defines the texture to update
  14701. * @param data defines the data to store
  14702. * @param format defines the data format
  14703. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14704. * @param invertY defines if data must be stored with Y axis inverted
  14705. */
  14706. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  14707. /**
  14708. * Update a raw cube texture
  14709. * @param texture defines the texture to update
  14710. * @param data defines the data to store
  14711. * @param format defines the data format
  14712. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14713. * @param invertY defines if data must be stored with Y axis inverted
  14714. * @param compression defines the compression used (null by default)
  14715. */
  14716. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  14717. /**
  14718. * Update a raw cube texture
  14719. * @param texture defines the texture to update
  14720. * @param data defines the data to store
  14721. * @param format defines the data format
  14722. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14723. * @param invertY defines if data must be stored with Y axis inverted
  14724. * @param compression defines the compression used (null by default)
  14725. * @param level defines which level of the texture to update
  14726. */
  14727. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  14728. /**
  14729. * Creates a new raw cube texture from a specified url
  14730. * @param url defines the url where the data is located
  14731. * @param scene defines the current scene
  14732. * @param size defines the size of the textures
  14733. * @param format defines the format of the data
  14734. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  14735. * @param noMipmap defines if the engine should avoid generating the mip levels
  14736. * @param callback defines a callback used to extract texture data from loaded data
  14737. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  14738. * @param onLoad defines a callback called when texture is loaded
  14739. * @param onError defines a callback called if there is an error
  14740. * @returns the cube texture as an InternalTexture
  14741. */
  14742. 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;
  14743. /**
  14744. * Creates a new raw cube texture from a specified url
  14745. * @param url defines the url where the data is located
  14746. * @param scene defines the current scene
  14747. * @param size defines the size of the textures
  14748. * @param format defines the format of the data
  14749. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  14750. * @param noMipmap defines if the engine should avoid generating the mip levels
  14751. * @param callback defines a callback used to extract texture data from loaded data
  14752. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  14753. * @param onLoad defines a callback called when texture is loaded
  14754. * @param onError defines a callback called if there is an error
  14755. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14756. * @param invertY defines if data must be stored with Y axis inverted
  14757. * @returns the cube texture as an InternalTexture
  14758. */
  14759. 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;
  14760. /**
  14761. * Creates a new raw 3D texture
  14762. * @param data defines the data used to create the texture
  14763. * @param width defines the width of the texture
  14764. * @param height defines the height of the texture
  14765. * @param depth defines the depth of the texture
  14766. * @param format defines the format of the texture
  14767. * @param generateMipMaps defines if the engine must generate mip levels
  14768. * @param invertY defines if data must be stored with Y axis inverted
  14769. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14770. * @param compression defines the compressed used (can be null)
  14771. * @param textureType defines the compressed used (can be null)
  14772. * @returns a new raw 3D texture (stored in an InternalTexture)
  14773. */
  14774. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  14775. /**
  14776. * Update a raw 3D texture
  14777. * @param texture defines the texture to update
  14778. * @param data defines the data to store
  14779. * @param format defines the data format
  14780. * @param invertY defines if data must be stored with Y axis inverted
  14781. */
  14782. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  14783. /**
  14784. * Update a raw 3D texture
  14785. * @param texture defines the texture to update
  14786. * @param data defines the data to store
  14787. * @param format defines the data format
  14788. * @param invertY defines if data must be stored with Y axis inverted
  14789. * @param compression defines the used compression (can be null)
  14790. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  14791. */
  14792. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  14793. /**
  14794. * Creates a new raw 2D array texture
  14795. * @param data defines the data used to create the texture
  14796. * @param width defines the width of the texture
  14797. * @param height defines the height of the texture
  14798. * @param depth defines the number of layers of the texture
  14799. * @param format defines the format of the texture
  14800. * @param generateMipMaps defines if the engine must generate mip levels
  14801. * @param invertY defines if data must be stored with Y axis inverted
  14802. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14803. * @param compression defines the compressed used (can be null)
  14804. * @param textureType defines the compressed used (can be null)
  14805. * @returns a new raw 2D array texture (stored in an InternalTexture)
  14806. */
  14807. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  14808. /**
  14809. * Update a raw 2D array texture
  14810. * @param texture defines the texture to update
  14811. * @param data defines the data to store
  14812. * @param format defines the data format
  14813. * @param invertY defines if data must be stored with Y axis inverted
  14814. */
  14815. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  14816. /**
  14817. * Update a raw 2D array texture
  14818. * @param texture defines the texture to update
  14819. * @param data defines the data to store
  14820. * @param format defines the data format
  14821. * @param invertY defines if data must be stored with Y axis inverted
  14822. * @param compression defines the used compression (can be null)
  14823. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  14824. */
  14825. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  14826. }
  14827. }
  14828. declare module BABYLON {
  14829. /**
  14830. * Raw texture can help creating a texture directly from an array of data.
  14831. * This can be super useful if you either get the data from an uncompressed source or
  14832. * if you wish to create your texture pixel by pixel.
  14833. */
  14834. export class RawTexture extends Texture {
  14835. /**
  14836. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  14837. */
  14838. format: number;
  14839. /**
  14840. * Instantiates a new RawTexture.
  14841. * Raw texture can help creating a texture directly from an array of data.
  14842. * This can be super useful if you either get the data from an uncompressed source or
  14843. * if you wish to create your texture pixel by pixel.
  14844. * @param data define the array of data to use to create the texture
  14845. * @param width define the width of the texture
  14846. * @param height define the height of the texture
  14847. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  14848. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14849. * @param generateMipMaps define whether mip maps should be generated or not
  14850. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14851. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14852. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14853. */
  14854. constructor(data: ArrayBufferView, width: number, height: number,
  14855. /**
  14856. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  14857. */
  14858. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  14859. /**
  14860. * Updates the texture underlying data.
  14861. * @param data Define the new data of the texture
  14862. */
  14863. update(data: ArrayBufferView): void;
  14864. /**
  14865. * Creates a luminance texture from some data.
  14866. * @param data Define the texture data
  14867. * @param width Define the width of the texture
  14868. * @param height Define the height of the texture
  14869. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14870. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14871. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14872. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14873. * @returns the luminance texture
  14874. */
  14875. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  14876. /**
  14877. * Creates a luminance alpha texture from some data.
  14878. * @param data Define the texture data
  14879. * @param width Define the width of the texture
  14880. * @param height Define the height of the texture
  14881. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14882. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14883. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14884. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14885. * @returns the luminance alpha texture
  14886. */
  14887. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  14888. /**
  14889. * Creates an alpha texture from some data.
  14890. * @param data Define the texture data
  14891. * @param width Define the width of the texture
  14892. * @param height Define the height of the texture
  14893. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14894. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14895. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14896. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14897. * @returns the alpha texture
  14898. */
  14899. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  14900. /**
  14901. * Creates a RGB texture from some data.
  14902. * @param data Define the texture data
  14903. * @param width Define the width of the texture
  14904. * @param height Define the height of the texture
  14905. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14906. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14907. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14908. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14909. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14910. * @returns the RGB alpha texture
  14911. */
  14912. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14913. /**
  14914. * Creates a RGBA texture from some data.
  14915. * @param data Define the texture data
  14916. * @param width Define the width of the texture
  14917. * @param height Define the height of the texture
  14918. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14919. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14920. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14921. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14922. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14923. * @returns the RGBA texture
  14924. */
  14925. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14926. /**
  14927. * Creates a R texture from some data.
  14928. * @param data Define the texture data
  14929. * @param width Define the width of the texture
  14930. * @param height Define the height of the texture
  14931. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14932. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14933. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14934. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14935. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14936. * @returns the R texture
  14937. */
  14938. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14939. }
  14940. }
  14941. declare module BABYLON {
  14942. interface ThinEngine {
  14943. /**
  14944. * Update a dynamic index buffer
  14945. * @param indexBuffer defines the target index buffer
  14946. * @param indices defines the data to update
  14947. * @param offset defines the offset in the target index buffer where update should start
  14948. */
  14949. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  14950. /**
  14951. * Updates a dynamic vertex buffer.
  14952. * @param vertexBuffer the vertex buffer to update
  14953. * @param data the data used to update the vertex buffer
  14954. * @param byteOffset the byte offset of the data
  14955. * @param byteLength the byte length of the data
  14956. */
  14957. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  14958. }
  14959. }
  14960. declare module BABYLON {
  14961. interface AbstractScene {
  14962. /**
  14963. * The list of procedural textures added to the scene
  14964. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14965. */
  14966. proceduralTextures: Array<ProceduralTexture>;
  14967. }
  14968. /**
  14969. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  14970. * in a given scene.
  14971. */
  14972. export class ProceduralTextureSceneComponent implements ISceneComponent {
  14973. /**
  14974. * The component name helpful to identify the component in the list of scene components.
  14975. */
  14976. readonly name: string;
  14977. /**
  14978. * The scene the component belongs to.
  14979. */
  14980. scene: Scene;
  14981. /**
  14982. * Creates a new instance of the component for the given scene
  14983. * @param scene Defines the scene to register the component in
  14984. */
  14985. constructor(scene: Scene);
  14986. /**
  14987. * Registers the component in a given scene
  14988. */
  14989. register(): void;
  14990. /**
  14991. * Rebuilds the elements related to this component in case of
  14992. * context lost for instance.
  14993. */
  14994. rebuild(): void;
  14995. /**
  14996. * Disposes the component and the associated resources.
  14997. */
  14998. dispose(): void;
  14999. private _beforeClear;
  15000. }
  15001. }
  15002. declare module BABYLON {
  15003. interface ThinEngine {
  15004. /**
  15005. * Creates a new render target cube texture
  15006. * @param size defines the size of the texture
  15007. * @param options defines the options used to create the texture
  15008. * @returns a new render target cube texture stored in an InternalTexture
  15009. */
  15010. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  15011. }
  15012. }
  15013. declare module BABYLON {
  15014. /** @hidden */
  15015. export var proceduralVertexShader: {
  15016. name: string;
  15017. shader: string;
  15018. };
  15019. }
  15020. declare module BABYLON {
  15021. /**
  15022. * 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.
  15023. * This is the base class of any Procedural texture and contains most of the shareable code.
  15024. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  15025. */
  15026. export class ProceduralTexture extends Texture {
  15027. /**
  15028. * Define if the texture is enabled or not (disabled texture will not render)
  15029. */
  15030. isEnabled: boolean;
  15031. /**
  15032. * Define if the texture must be cleared before rendering (default is true)
  15033. */
  15034. autoClear: boolean;
  15035. /**
  15036. * Callback called when the texture is generated
  15037. */
  15038. onGenerated: () => void;
  15039. /**
  15040. * Event raised when the texture is generated
  15041. */
  15042. onGeneratedObservable: Observable<ProceduralTexture>;
  15043. /**
  15044. * Event raised before the texture is generated
  15045. */
  15046. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  15047. /**
  15048. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  15049. */
  15050. nodeMaterialSource: Nullable<NodeMaterial>;
  15051. /** @hidden */
  15052. _generateMipMaps: boolean;
  15053. /** @hidden **/
  15054. _effect: Effect;
  15055. /** @hidden */
  15056. _textures: {
  15057. [key: string]: Texture;
  15058. };
  15059. /** @hidden */
  15060. protected _fallbackTexture: Nullable<Texture>;
  15061. private _size;
  15062. private _textureType;
  15063. private _currentRefreshId;
  15064. private _frameId;
  15065. private _refreshRate;
  15066. private _vertexBuffers;
  15067. private _indexBuffer;
  15068. private _uniforms;
  15069. private _samplers;
  15070. private _fragment;
  15071. private _floats;
  15072. private _ints;
  15073. private _floatsArrays;
  15074. private _colors3;
  15075. private _colors4;
  15076. private _vectors2;
  15077. private _vectors3;
  15078. private _matrices;
  15079. private _fallbackTextureUsed;
  15080. private _fullEngine;
  15081. private _cachedDefines;
  15082. private _contentUpdateId;
  15083. private _contentData;
  15084. /**
  15085. * Instantiates a new procedural texture.
  15086. * 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.
  15087. * This is the base class of any Procedural texture and contains most of the shareable code.
  15088. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  15089. * @param name Define the name of the texture
  15090. * @param size Define the size of the texture to create
  15091. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  15092. * @param scene Define the scene the texture belongs to
  15093. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  15094. * @param generateMipMaps Define if the texture should creates mip maps or not
  15095. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  15096. * @param textureType The FBO internal texture type
  15097. */
  15098. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  15099. /**
  15100. * The effect that is created when initializing the post process.
  15101. * @returns The created effect corresponding the the postprocess.
  15102. */
  15103. getEffect(): Effect;
  15104. /**
  15105. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  15106. * @returns an ArrayBufferView promise (Uint8Array or Float32Array)
  15107. */
  15108. getContent(): Nullable<Promise<ArrayBufferView>>;
  15109. private _createIndexBuffer;
  15110. /** @hidden */
  15111. _rebuild(): void;
  15112. /**
  15113. * Resets the texture in order to recreate its associated resources.
  15114. * This can be called in case of context loss
  15115. */
  15116. reset(): void;
  15117. protected _getDefines(): string;
  15118. /**
  15119. * Is the texture ready to be used ? (rendered at least once)
  15120. * @returns true if ready, otherwise, false.
  15121. */
  15122. isReady(): boolean;
  15123. /**
  15124. * Resets the refresh counter of the texture and start bak from scratch.
  15125. * Could be useful to regenerate the texture if it is setup to render only once.
  15126. */
  15127. resetRefreshCounter(): void;
  15128. /**
  15129. * Set the fragment shader to use in order to render the texture.
  15130. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  15131. */
  15132. setFragment(fragment: any): void;
  15133. /**
  15134. * Define the refresh rate of the texture or the rendering frequency.
  15135. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  15136. */
  15137. get refreshRate(): number;
  15138. set refreshRate(value: number);
  15139. /** @hidden */
  15140. _shouldRender(): boolean;
  15141. /**
  15142. * Get the size the texture is rendering at.
  15143. * @returns the size (on cube texture it is always squared)
  15144. */
  15145. getRenderSize(): RenderTargetTextureSize;
  15146. /**
  15147. * Resize the texture to new value.
  15148. * @param size Define the new size the texture should have
  15149. * @param generateMipMaps Define whether the new texture should create mip maps
  15150. */
  15151. resize(size: number, generateMipMaps: boolean): void;
  15152. private _checkUniform;
  15153. /**
  15154. * Set a texture in the shader program used to render.
  15155. * @param name Define the name of the uniform samplers as defined in the shader
  15156. * @param texture Define the texture to bind to this sampler
  15157. * @return the texture itself allowing "fluent" like uniform updates
  15158. */
  15159. setTexture(name: string, texture: Texture): ProceduralTexture;
  15160. /**
  15161. * Set a float in the shader.
  15162. * @param name Define the name of the uniform as defined in the shader
  15163. * @param value Define the value to give to the uniform
  15164. * @return the texture itself allowing "fluent" like uniform updates
  15165. */
  15166. setFloat(name: string, value: number): ProceduralTexture;
  15167. /**
  15168. * Set a int in the shader.
  15169. * @param name Define the name of the uniform as defined in the shader
  15170. * @param value Define the value to give to the uniform
  15171. * @return the texture itself allowing "fluent" like uniform updates
  15172. */
  15173. setInt(name: string, value: number): ProceduralTexture;
  15174. /**
  15175. * Set an array of floats in the shader.
  15176. * @param name Define the name of the uniform as defined in the shader
  15177. * @param value Define the value to give to the uniform
  15178. * @return the texture itself allowing "fluent" like uniform updates
  15179. */
  15180. setFloats(name: string, value: number[]): ProceduralTexture;
  15181. /**
  15182. * Set a vec3 in the shader from a Color3.
  15183. * @param name Define the name of the uniform as defined in the shader
  15184. * @param value Define the value to give to the uniform
  15185. * @return the texture itself allowing "fluent" like uniform updates
  15186. */
  15187. setColor3(name: string, value: Color3): ProceduralTexture;
  15188. /**
  15189. * Set a vec4 in the shader from a Color4.
  15190. * @param name Define the name of the uniform as defined in the shader
  15191. * @param value Define the value to give to the uniform
  15192. * @return the texture itself allowing "fluent" like uniform updates
  15193. */
  15194. setColor4(name: string, value: Color4): ProceduralTexture;
  15195. /**
  15196. * Set a vec2 in the shader from a Vector2.
  15197. * @param name Define the name of the uniform as defined in the shader
  15198. * @param value Define the value to give to the uniform
  15199. * @return the texture itself allowing "fluent" like uniform updates
  15200. */
  15201. setVector2(name: string, value: Vector2): ProceduralTexture;
  15202. /**
  15203. * Set a vec3 in the shader from a Vector3.
  15204. * @param name Define the name of the uniform as defined in the shader
  15205. * @param value Define the value to give to the uniform
  15206. * @return the texture itself allowing "fluent" like uniform updates
  15207. */
  15208. setVector3(name: string, value: Vector3): ProceduralTexture;
  15209. /**
  15210. * Set a mat4 in the shader from a MAtrix.
  15211. * @param name Define the name of the uniform as defined in the shader
  15212. * @param value Define the value to give to the uniform
  15213. * @return the texture itself allowing "fluent" like uniform updates
  15214. */
  15215. setMatrix(name: string, value: Matrix): ProceduralTexture;
  15216. /**
  15217. * Render the texture to its associated render target.
  15218. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  15219. */
  15220. render(useCameraPostProcess?: boolean): void;
  15221. /**
  15222. * Clone the texture.
  15223. * @returns the cloned texture
  15224. */
  15225. clone(): ProceduralTexture;
  15226. /**
  15227. * Dispose the texture and release its associated resources.
  15228. */
  15229. dispose(): void;
  15230. }
  15231. }
  15232. declare module BABYLON {
  15233. /**
  15234. * This represents the base class for particle system in Babylon.
  15235. * 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.
  15236. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  15237. * @example https://doc.babylonjs.com/babylon101/particles
  15238. */
  15239. export class BaseParticleSystem {
  15240. /**
  15241. * Source color is added to the destination color without alpha affecting the result
  15242. */
  15243. static BLENDMODE_ONEONE: number;
  15244. /**
  15245. * Blend current color and particle color using particle’s alpha
  15246. */
  15247. static BLENDMODE_STANDARD: number;
  15248. /**
  15249. * Add current color and particle color multiplied by particle’s alpha
  15250. */
  15251. static BLENDMODE_ADD: number;
  15252. /**
  15253. * Multiply current color with particle color
  15254. */
  15255. static BLENDMODE_MULTIPLY: number;
  15256. /**
  15257. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  15258. */
  15259. static BLENDMODE_MULTIPLYADD: number;
  15260. /**
  15261. * List of animations used by the particle system.
  15262. */
  15263. animations: Animation[];
  15264. /**
  15265. * Gets or sets the unique id of the particle system
  15266. */
  15267. uniqueId: number;
  15268. /**
  15269. * The id of the Particle system.
  15270. */
  15271. id: string;
  15272. /**
  15273. * The friendly name of the Particle system.
  15274. */
  15275. name: string;
  15276. /**
  15277. * Snippet ID if the particle system was created from the snippet server
  15278. */
  15279. snippetId: string;
  15280. /**
  15281. * The rendering group used by the Particle system to chose when to render.
  15282. */
  15283. renderingGroupId: number;
  15284. /**
  15285. * The emitter represents the Mesh or position we are attaching the particle system to.
  15286. */
  15287. emitter: Nullable<AbstractMesh | Vector3>;
  15288. /**
  15289. * The maximum number of particles to emit per frame
  15290. */
  15291. emitRate: number;
  15292. /**
  15293. * If you want to launch only a few particles at once, that can be done, as well.
  15294. */
  15295. manualEmitCount: number;
  15296. /**
  15297. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  15298. */
  15299. updateSpeed: number;
  15300. /**
  15301. * The amount of time the particle system is running (depends of the overall update speed).
  15302. */
  15303. targetStopDuration: number;
  15304. /**
  15305. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  15306. */
  15307. disposeOnStop: boolean;
  15308. /**
  15309. * Minimum power of emitting particles.
  15310. */
  15311. minEmitPower: number;
  15312. /**
  15313. * Maximum power of emitting particles.
  15314. */
  15315. maxEmitPower: number;
  15316. /**
  15317. * Minimum life time of emitting particles.
  15318. */
  15319. minLifeTime: number;
  15320. /**
  15321. * Maximum life time of emitting particles.
  15322. */
  15323. maxLifeTime: number;
  15324. /**
  15325. * Minimum Size of emitting particles.
  15326. */
  15327. minSize: number;
  15328. /**
  15329. * Maximum Size of emitting particles.
  15330. */
  15331. maxSize: number;
  15332. /**
  15333. * Minimum scale of emitting particles on X axis.
  15334. */
  15335. minScaleX: number;
  15336. /**
  15337. * Maximum scale of emitting particles on X axis.
  15338. */
  15339. maxScaleX: number;
  15340. /**
  15341. * Minimum scale of emitting particles on Y axis.
  15342. */
  15343. minScaleY: number;
  15344. /**
  15345. * Maximum scale of emitting particles on Y axis.
  15346. */
  15347. maxScaleY: number;
  15348. /**
  15349. * Gets or sets the minimal initial rotation in radians.
  15350. */
  15351. minInitialRotation: number;
  15352. /**
  15353. * Gets or sets the maximal initial rotation in radians.
  15354. */
  15355. maxInitialRotation: number;
  15356. /**
  15357. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  15358. */
  15359. minAngularSpeed: number;
  15360. /**
  15361. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  15362. */
  15363. maxAngularSpeed: number;
  15364. /**
  15365. * The texture used to render each particle. (this can be a spritesheet)
  15366. */
  15367. particleTexture: Nullable<BaseTexture>;
  15368. /**
  15369. * The layer mask we are rendering the particles through.
  15370. */
  15371. layerMask: number;
  15372. /**
  15373. * This can help using your own shader to render the particle system.
  15374. * The according effect will be created
  15375. */
  15376. customShader: any;
  15377. /**
  15378. * By default particle system starts as soon as they are created. This prevents the
  15379. * automatic start to happen and let you decide when to start emitting particles.
  15380. */
  15381. preventAutoStart: boolean;
  15382. protected _rootUrl: string;
  15383. private _noiseTexture;
  15384. /**
  15385. * Gets or sets a texture used to add random noise to particle positions
  15386. */
  15387. get noiseTexture(): Nullable<ProceduralTexture>;
  15388. set noiseTexture(value: Nullable<ProceduralTexture>);
  15389. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  15390. noiseStrength: Vector3;
  15391. /**
  15392. * Callback triggered when the particle animation is ending.
  15393. */
  15394. onAnimationEnd: Nullable<() => void>;
  15395. /**
  15396. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  15397. */
  15398. blendMode: number;
  15399. /**
  15400. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  15401. * to override the particles.
  15402. */
  15403. forceDepthWrite: boolean;
  15404. /** 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 */
  15405. preWarmCycles: number;
  15406. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  15407. preWarmStepOffset: number;
  15408. /**
  15409. * 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)
  15410. */
  15411. spriteCellChangeSpeed: number;
  15412. /**
  15413. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  15414. */
  15415. startSpriteCellID: number;
  15416. /**
  15417. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  15418. */
  15419. endSpriteCellID: number;
  15420. /**
  15421. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  15422. */
  15423. spriteCellWidth: number;
  15424. /**
  15425. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  15426. */
  15427. spriteCellHeight: number;
  15428. /**
  15429. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  15430. */
  15431. spriteRandomStartCell: boolean;
  15432. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  15433. translationPivot: Vector2;
  15434. /** @hidden */
  15435. protected _isAnimationSheetEnabled: boolean;
  15436. /**
  15437. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  15438. */
  15439. beginAnimationOnStart: boolean;
  15440. /**
  15441. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  15442. */
  15443. beginAnimationFrom: number;
  15444. /**
  15445. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  15446. */
  15447. beginAnimationTo: number;
  15448. /**
  15449. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  15450. */
  15451. beginAnimationLoop: boolean;
  15452. /**
  15453. * Gets or sets a world offset applied to all particles
  15454. */
  15455. worldOffset: Vector3;
  15456. /**
  15457. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  15458. */
  15459. get isAnimationSheetEnabled(): boolean;
  15460. set isAnimationSheetEnabled(value: boolean);
  15461. /**
  15462. * Get hosting scene
  15463. * @returns the scene
  15464. */
  15465. getScene(): Nullable<Scene>;
  15466. /**
  15467. * You can use gravity if you want to give an orientation to your particles.
  15468. */
  15469. gravity: Vector3;
  15470. protected _colorGradients: Nullable<Array<ColorGradient>>;
  15471. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  15472. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  15473. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  15474. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  15475. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  15476. protected _dragGradients: Nullable<Array<FactorGradient>>;
  15477. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  15478. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  15479. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  15480. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  15481. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  15482. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  15483. /**
  15484. * Defines the delay in milliseconds before starting the system (0 by default)
  15485. */
  15486. startDelay: number;
  15487. /**
  15488. * Gets the current list of drag gradients.
  15489. * You must use addDragGradient and removeDragGradient to update this list
  15490. * @returns the list of drag gradients
  15491. */
  15492. getDragGradients(): Nullable<Array<FactorGradient>>;
  15493. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  15494. limitVelocityDamping: number;
  15495. /**
  15496. * Gets the current list of limit velocity gradients.
  15497. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to update this list
  15498. * @returns the list of limit velocity gradients
  15499. */
  15500. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  15501. /**
  15502. * Gets the current list of color gradients.
  15503. * You must use addColorGradient and removeColorGradient to update this list
  15504. * @returns the list of color gradients
  15505. */
  15506. getColorGradients(): Nullable<Array<ColorGradient>>;
  15507. /**
  15508. * Gets the current list of size gradients.
  15509. * You must use addSizeGradient and removeSizeGradient to update this list
  15510. * @returns the list of size gradients
  15511. */
  15512. getSizeGradients(): Nullable<Array<FactorGradient>>;
  15513. /**
  15514. * Gets the current list of color remap gradients.
  15515. * You must use addColorRemapGradient and removeColorRemapGradient to update this list
  15516. * @returns the list of color remap gradients
  15517. */
  15518. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  15519. /**
  15520. * Gets the current list of alpha remap gradients.
  15521. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to update this list
  15522. * @returns the list of alpha remap gradients
  15523. */
  15524. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  15525. /**
  15526. * Gets the current list of life time gradients.
  15527. * You must use addLifeTimeGradient and removeLifeTimeGradient to update this list
  15528. * @returns the list of life time gradients
  15529. */
  15530. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  15531. /**
  15532. * Gets the current list of angular speed gradients.
  15533. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to update this list
  15534. * @returns the list of angular speed gradients
  15535. */
  15536. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  15537. /**
  15538. * Gets the current list of velocity gradients.
  15539. * You must use addVelocityGradient and removeVelocityGradient to update this list
  15540. * @returns the list of velocity gradients
  15541. */
  15542. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  15543. /**
  15544. * Gets the current list of start size gradients.
  15545. * You must use addStartSizeGradient and removeStartSizeGradient to update this list
  15546. * @returns the list of start size gradients
  15547. */
  15548. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  15549. /**
  15550. * Gets the current list of emit rate gradients.
  15551. * You must use addEmitRateGradient and removeEmitRateGradient to update this list
  15552. * @returns the list of emit rate gradients
  15553. */
  15554. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  15555. /**
  15556. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15557. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15558. */
  15559. get direction1(): Vector3;
  15560. set direction1(value: Vector3);
  15561. /**
  15562. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15563. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15564. */
  15565. get direction2(): Vector3;
  15566. set direction2(value: Vector3);
  15567. /**
  15568. * 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.
  15569. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15570. */
  15571. get minEmitBox(): Vector3;
  15572. set minEmitBox(value: Vector3);
  15573. /**
  15574. * 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.
  15575. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15576. */
  15577. get maxEmitBox(): Vector3;
  15578. set maxEmitBox(value: Vector3);
  15579. /**
  15580. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  15581. */
  15582. color1: Color4;
  15583. /**
  15584. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  15585. */
  15586. color2: Color4;
  15587. /**
  15588. * Color the particle will have at the end of its lifetime
  15589. */
  15590. colorDead: Color4;
  15591. /**
  15592. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  15593. */
  15594. textureMask: Color4;
  15595. /**
  15596. * The particle emitter type defines the emitter used by the particle system.
  15597. * It can be for example box, sphere, or cone...
  15598. */
  15599. particleEmitterType: IParticleEmitterType;
  15600. /** @hidden */
  15601. _isSubEmitter: boolean;
  15602. /**
  15603. * Gets or sets the billboard mode to use when isBillboardBased = true.
  15604. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  15605. */
  15606. billboardMode: number;
  15607. protected _isBillboardBased: boolean;
  15608. /**
  15609. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  15610. */
  15611. get isBillboardBased(): boolean;
  15612. set isBillboardBased(value: boolean);
  15613. /**
  15614. * The scene the particle system belongs to.
  15615. */
  15616. protected _scene: Nullable<Scene>;
  15617. /**
  15618. * The engine the particle system belongs to.
  15619. */
  15620. protected _engine: ThinEngine;
  15621. /**
  15622. * Local cache of defines for image processing.
  15623. */
  15624. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  15625. /**
  15626. * Default configuration related to image processing available in the standard Material.
  15627. */
  15628. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  15629. /**
  15630. * Gets the image processing configuration used either in this material.
  15631. */
  15632. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  15633. /**
  15634. * Sets the Default image processing configuration used either in the this material.
  15635. *
  15636. * If sets to null, the scene one is in use.
  15637. */
  15638. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  15639. /**
  15640. * Attaches a new image processing configuration to the Standard Material.
  15641. * @param configuration
  15642. */
  15643. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  15644. /** @hidden */
  15645. protected _reset(): void;
  15646. /** @hidden */
  15647. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  15648. /**
  15649. * Instantiates a particle system.
  15650. * 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.
  15651. * @param name The name of the particle system
  15652. */
  15653. constructor(name: string);
  15654. /**
  15655. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  15656. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15657. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15658. * @returns the emitter
  15659. */
  15660. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  15661. /**
  15662. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  15663. * @param radius The radius of the hemisphere to emit from
  15664. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15665. * @returns the emitter
  15666. */
  15667. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  15668. /**
  15669. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  15670. * @param radius The radius of the sphere to emit from
  15671. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15672. * @returns the emitter
  15673. */
  15674. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  15675. /**
  15676. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  15677. * @param radius The radius of the sphere to emit from
  15678. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  15679. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  15680. * @returns the emitter
  15681. */
  15682. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  15683. /**
  15684. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  15685. * @param radius The radius of the emission cylinder
  15686. * @param height The height of the emission cylinder
  15687. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  15688. * @param directionRandomizer How much to randomize the particle direction [0-1]
  15689. * @returns the emitter
  15690. */
  15691. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  15692. /**
  15693. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  15694. * @param radius The radius of the cylinder to emit from
  15695. * @param height The height of the emission cylinder
  15696. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15697. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  15698. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  15699. * @returns the emitter
  15700. */
  15701. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  15702. /**
  15703. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  15704. * @param radius The radius of the cone to emit from
  15705. * @param angle The base angle of the cone
  15706. * @returns the emitter
  15707. */
  15708. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  15709. /**
  15710. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  15711. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15712. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15713. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15714. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15715. * @returns the emitter
  15716. */
  15717. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  15718. }
  15719. }
  15720. declare module BABYLON {
  15721. /**
  15722. * Type of sub emitter
  15723. */
  15724. export enum SubEmitterType {
  15725. /**
  15726. * Attached to the particle over it's lifetime
  15727. */
  15728. ATTACHED = 0,
  15729. /**
  15730. * Created when the particle dies
  15731. */
  15732. END = 1
  15733. }
  15734. /**
  15735. * Sub emitter class used to emit particles from an existing particle
  15736. */
  15737. export class SubEmitter {
  15738. /**
  15739. * the particle system to be used by the sub emitter
  15740. */
  15741. particleSystem: ParticleSystem;
  15742. /**
  15743. * Type of the submitter (Default: END)
  15744. */
  15745. type: SubEmitterType;
  15746. /**
  15747. * 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)
  15748. * Note: This only is supported when using an emitter of type Mesh
  15749. */
  15750. inheritDirection: boolean;
  15751. /**
  15752. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  15753. */
  15754. inheritedVelocityAmount: number;
  15755. /**
  15756. * Creates a sub emitter
  15757. * @param particleSystem the particle system to be used by the sub emitter
  15758. */
  15759. constructor(
  15760. /**
  15761. * the particle system to be used by the sub emitter
  15762. */
  15763. particleSystem: ParticleSystem);
  15764. /**
  15765. * Clones the sub emitter
  15766. * @returns the cloned sub emitter
  15767. */
  15768. clone(): SubEmitter;
  15769. /**
  15770. * Serialize current object to a JSON object
  15771. * @returns the serialized object
  15772. */
  15773. serialize(): any;
  15774. /** @hidden */
  15775. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  15776. /**
  15777. * Creates a new SubEmitter from a serialized JSON version
  15778. * @param serializationObject defines the JSON object to read from
  15779. * @param sceneOrEngine defines the hosting scene or the hosting engine
  15780. * @param rootUrl defines the rootUrl for data loading
  15781. * @returns a new SubEmitter
  15782. */
  15783. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  15784. /** Release associated resources */
  15785. dispose(): void;
  15786. }
  15787. }
  15788. declare module BABYLON {
  15789. /** @hidden */
  15790. export var clipPlaneFragmentDeclaration: {
  15791. name: string;
  15792. shader: string;
  15793. };
  15794. }
  15795. declare module BABYLON {
  15796. /** @hidden */
  15797. export var imageProcessingDeclaration: {
  15798. name: string;
  15799. shader: string;
  15800. };
  15801. }
  15802. declare module BABYLON {
  15803. /** @hidden */
  15804. export var imageProcessingFunctions: {
  15805. name: string;
  15806. shader: string;
  15807. };
  15808. }
  15809. declare module BABYLON {
  15810. /** @hidden */
  15811. export var clipPlaneFragment: {
  15812. name: string;
  15813. shader: string;
  15814. };
  15815. }
  15816. declare module BABYLON {
  15817. /** @hidden */
  15818. export var particlesPixelShader: {
  15819. name: string;
  15820. shader: string;
  15821. };
  15822. }
  15823. declare module BABYLON {
  15824. /** @hidden */
  15825. export var clipPlaneVertexDeclaration: {
  15826. name: string;
  15827. shader: string;
  15828. };
  15829. }
  15830. declare module BABYLON {
  15831. /** @hidden */
  15832. export var clipPlaneVertex: {
  15833. name: string;
  15834. shader: string;
  15835. };
  15836. }
  15837. declare module BABYLON {
  15838. /** @hidden */
  15839. export var particlesVertexShader: {
  15840. name: string;
  15841. shader: string;
  15842. };
  15843. }
  15844. declare module BABYLON {
  15845. /**
  15846. * Interface used to define entities containing multiple clip planes
  15847. */
  15848. export interface IClipPlanesHolder {
  15849. /**
  15850. * Gets or sets the active clipplane 1
  15851. */
  15852. clipPlane: Nullable<Plane>;
  15853. /**
  15854. * Gets or sets the active clipplane 2
  15855. */
  15856. clipPlane2: Nullable<Plane>;
  15857. /**
  15858. * Gets or sets the active clipplane 3
  15859. */
  15860. clipPlane3: Nullable<Plane>;
  15861. /**
  15862. * Gets or sets the active clipplane 4
  15863. */
  15864. clipPlane4: Nullable<Plane>;
  15865. /**
  15866. * Gets or sets the active clipplane 5
  15867. */
  15868. clipPlane5: Nullable<Plane>;
  15869. /**
  15870. * Gets or sets the active clipplane 6
  15871. */
  15872. clipPlane6: Nullable<Plane>;
  15873. }
  15874. }
  15875. declare module BABYLON {
  15876. /**
  15877. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  15878. *
  15879. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  15880. *
  15881. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  15882. */
  15883. export class ThinMaterialHelper {
  15884. /**
  15885. * Binds the clip plane information from the holder to the effect.
  15886. * @param effect The effect we are binding the data to
  15887. * @param holder The entity containing the clip plane information
  15888. */
  15889. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  15890. }
  15891. }
  15892. declare module BABYLON {
  15893. interface ThinEngine {
  15894. /**
  15895. * Sets alpha constants used by some alpha blending modes
  15896. * @param r defines the red component
  15897. * @param g defines the green component
  15898. * @param b defines the blue component
  15899. * @param a defines the alpha component
  15900. */
  15901. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  15902. /**
  15903. * Sets the current alpha mode
  15904. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  15905. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  15906. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  15907. */
  15908. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  15909. /**
  15910. * Gets the current alpha mode
  15911. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  15912. * @returns the current alpha mode
  15913. */
  15914. getAlphaMode(): number;
  15915. /**
  15916. * Sets the current alpha equation
  15917. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  15918. */
  15919. setAlphaEquation(equation: number): void;
  15920. /**
  15921. * Gets the current alpha equation.
  15922. * @returns the current alpha equation
  15923. */
  15924. getAlphaEquation(): number;
  15925. }
  15926. }
  15927. declare module BABYLON {
  15928. /**
  15929. * This represents a particle system in Babylon.
  15930. * 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.
  15931. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  15932. * @example https://doc.babylonjs.com/babylon101/particles
  15933. */
  15934. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  15935. /**
  15936. * Billboard mode will only apply to Y axis
  15937. */
  15938. static readonly BILLBOARDMODE_Y: number;
  15939. /**
  15940. * Billboard mode will apply to all axes
  15941. */
  15942. static readonly BILLBOARDMODE_ALL: number;
  15943. /**
  15944. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  15945. */
  15946. static readonly BILLBOARDMODE_STRETCHED: number;
  15947. /**
  15948. * This function can be defined to provide custom update for active particles.
  15949. * This function will be called instead of regular update (age, position, color, etc.).
  15950. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  15951. */
  15952. updateFunction: (particles: Particle[]) => void;
  15953. private _emitterWorldMatrix;
  15954. /**
  15955. * This function can be defined to specify initial direction for every new particle.
  15956. * It by default use the emitterType defined function
  15957. */
  15958. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  15959. /**
  15960. * This function can be defined to specify initial position for every new particle.
  15961. * It by default use the emitterType defined function
  15962. */
  15963. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  15964. /**
  15965. * @hidden
  15966. */
  15967. _inheritedVelocityOffset: Vector3;
  15968. /**
  15969. * An event triggered when the system is disposed
  15970. */
  15971. onDisposeObservable: Observable<IParticleSystem>;
  15972. /**
  15973. * An event triggered when the system is stopped
  15974. */
  15975. onStoppedObservable: Observable<IParticleSystem>;
  15976. private _onDisposeObserver;
  15977. /**
  15978. * Sets a callback that will be triggered when the system is disposed
  15979. */
  15980. set onDispose(callback: () => void);
  15981. private _particles;
  15982. private _epsilon;
  15983. private _capacity;
  15984. private _stockParticles;
  15985. private _newPartsExcess;
  15986. private _vertexData;
  15987. private _vertexBuffer;
  15988. private _vertexBuffers;
  15989. private _spriteBuffer;
  15990. private _indexBuffer;
  15991. private _effect;
  15992. private _customEffect;
  15993. private _cachedDefines;
  15994. private _scaledColorStep;
  15995. private _colorDiff;
  15996. private _scaledDirection;
  15997. private _scaledGravity;
  15998. private _currentRenderId;
  15999. private _alive;
  16000. private _useInstancing;
  16001. private _vertexArrayObject;
  16002. private _started;
  16003. private _stopped;
  16004. private _actualFrame;
  16005. private _scaledUpdateSpeed;
  16006. private _vertexBufferSize;
  16007. /** @hidden */
  16008. _currentEmitRateGradient: Nullable<FactorGradient>;
  16009. /** @hidden */
  16010. _currentEmitRate1: number;
  16011. /** @hidden */
  16012. _currentEmitRate2: number;
  16013. /** @hidden */
  16014. _currentStartSizeGradient: Nullable<FactorGradient>;
  16015. /** @hidden */
  16016. _currentStartSize1: number;
  16017. /** @hidden */
  16018. _currentStartSize2: number;
  16019. private readonly _rawTextureWidth;
  16020. private _rampGradientsTexture;
  16021. private _useRampGradients;
  16022. /** Gets or sets a matrix to use to compute projection */
  16023. defaultProjectionMatrix: Matrix;
  16024. /** Gets or sets a matrix to use to compute view */
  16025. defaultViewMatrix: Matrix;
  16026. /** Gets or sets a boolean indicating that ramp gradients must be used
  16027. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16028. */
  16029. get useRampGradients(): boolean;
  16030. set useRampGradients(value: boolean);
  16031. /**
  16032. * 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.
  16033. * 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: [])
  16034. */
  16035. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  16036. private _subEmitters;
  16037. /**
  16038. * @hidden
  16039. * If the particle systems emitter should be disposed when the particle system is disposed
  16040. */
  16041. _disposeEmitterOnDispose: boolean;
  16042. /**
  16043. * The current active Sub-systems, this property is used by the root particle system only.
  16044. */
  16045. activeSubSystems: Array<ParticleSystem>;
  16046. /**
  16047. * Specifies if the particles are updated in emitter local space or world space
  16048. */
  16049. isLocal: boolean;
  16050. private _rootParticleSystem;
  16051. /**
  16052. * Gets the current list of active particles
  16053. */
  16054. get particles(): Particle[];
  16055. /**
  16056. * Gets the number of particles active at the same time.
  16057. * @returns The number of active particles.
  16058. */
  16059. getActiveCount(): number;
  16060. /**
  16061. * Returns the string "ParticleSystem"
  16062. * @returns a string containing the class name
  16063. */
  16064. getClassName(): string;
  16065. /**
  16066. * Gets a boolean indicating that the system is stopping
  16067. * @returns true if the system is currently stopping
  16068. */
  16069. isStopping(): boolean;
  16070. /**
  16071. * Gets the custom effect used to render the particles
  16072. * @param blendMode Blend mode for which the effect should be retrieved
  16073. * @returns The effect
  16074. */
  16075. getCustomEffect(blendMode?: number): Nullable<Effect>;
  16076. /**
  16077. * Sets the custom effect used to render the particles
  16078. * @param effect The effect to set
  16079. * @param blendMode Blend mode for which the effect should be set
  16080. */
  16081. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  16082. /** @hidden */
  16083. private _onBeforeDrawParticlesObservable;
  16084. /**
  16085. * Observable that will be called just before the particles are drawn
  16086. */
  16087. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  16088. /**
  16089. * Gets the name of the particle vertex shader
  16090. */
  16091. get vertexShaderName(): string;
  16092. /**
  16093. * Instantiates a particle system.
  16094. * 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.
  16095. * @param name The name of the particle system
  16096. * @param capacity The max number of particles alive at the same time
  16097. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  16098. * @param customEffect a custom effect used to change the way particles are rendered by default
  16099. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  16100. * @param epsilon Offset used to render the particles
  16101. */
  16102. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  16103. private _addFactorGradient;
  16104. private _removeFactorGradient;
  16105. /**
  16106. * Adds a new life time gradient
  16107. * @param gradient defines the gradient to use (between 0 and 1)
  16108. * @param factor defines the life time factor to affect to the specified gradient
  16109. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16110. * @returns the current particle system
  16111. */
  16112. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16113. /**
  16114. * Remove a specific life time gradient
  16115. * @param gradient defines the gradient to remove
  16116. * @returns the current particle system
  16117. */
  16118. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16119. /**
  16120. * Adds a new size gradient
  16121. * @param gradient defines the gradient to use (between 0 and 1)
  16122. * @param factor defines the size factor to affect to the specified gradient
  16123. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16124. * @returns the current particle system
  16125. */
  16126. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16127. /**
  16128. * Remove a specific size gradient
  16129. * @param gradient defines the gradient to remove
  16130. * @returns the current particle system
  16131. */
  16132. removeSizeGradient(gradient: number): IParticleSystem;
  16133. /**
  16134. * Adds a new color remap gradient
  16135. * @param gradient defines the gradient to use (between 0 and 1)
  16136. * @param min defines the color remap minimal range
  16137. * @param max defines the color remap maximal range
  16138. * @returns the current particle system
  16139. */
  16140. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16141. /**
  16142. * Remove a specific color remap gradient
  16143. * @param gradient defines the gradient to remove
  16144. * @returns the current particle system
  16145. */
  16146. removeColorRemapGradient(gradient: number): IParticleSystem;
  16147. /**
  16148. * Adds a new alpha remap gradient
  16149. * @param gradient defines the gradient to use (between 0 and 1)
  16150. * @param min defines the alpha remap minimal range
  16151. * @param max defines the alpha remap maximal range
  16152. * @returns the current particle system
  16153. */
  16154. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16155. /**
  16156. * Remove a specific alpha remap gradient
  16157. * @param gradient defines the gradient to remove
  16158. * @returns the current particle system
  16159. */
  16160. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  16161. /**
  16162. * Adds a new angular speed gradient
  16163. * @param gradient defines the gradient to use (between 0 and 1)
  16164. * @param factor defines the angular speed to affect to the specified gradient
  16165. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16166. * @returns the current particle system
  16167. */
  16168. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16169. /**
  16170. * Remove a specific angular speed gradient
  16171. * @param gradient defines the gradient to remove
  16172. * @returns the current particle system
  16173. */
  16174. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16175. /**
  16176. * Adds a new velocity gradient
  16177. * @param gradient defines the gradient to use (between 0 and 1)
  16178. * @param factor defines the velocity to affect to the specified gradient
  16179. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16180. * @returns the current particle system
  16181. */
  16182. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16183. /**
  16184. * Remove a specific velocity gradient
  16185. * @param gradient defines the gradient to remove
  16186. * @returns the current particle system
  16187. */
  16188. removeVelocityGradient(gradient: number): IParticleSystem;
  16189. /**
  16190. * Adds a new limit velocity gradient
  16191. * @param gradient defines the gradient to use (between 0 and 1)
  16192. * @param factor defines the limit velocity value to affect to the specified gradient
  16193. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16194. * @returns the current particle system
  16195. */
  16196. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16197. /**
  16198. * Remove a specific limit velocity gradient
  16199. * @param gradient defines the gradient to remove
  16200. * @returns the current particle system
  16201. */
  16202. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16203. /**
  16204. * Adds a new drag gradient
  16205. * @param gradient defines the gradient to use (between 0 and 1)
  16206. * @param factor defines the drag value to affect to the specified gradient
  16207. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16208. * @returns the current particle system
  16209. */
  16210. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16211. /**
  16212. * Remove a specific drag gradient
  16213. * @param gradient defines the gradient to remove
  16214. * @returns the current particle system
  16215. */
  16216. removeDragGradient(gradient: number): IParticleSystem;
  16217. /**
  16218. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16219. * @param gradient defines the gradient to use (between 0 and 1)
  16220. * @param factor defines the emit rate value to affect to the specified gradient
  16221. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16222. * @returns the current particle system
  16223. */
  16224. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16225. /**
  16226. * Remove a specific emit rate gradient
  16227. * @param gradient defines the gradient to remove
  16228. * @returns the current particle system
  16229. */
  16230. removeEmitRateGradient(gradient: number): IParticleSystem;
  16231. /**
  16232. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16233. * @param gradient defines the gradient to use (between 0 and 1)
  16234. * @param factor defines the start size value to affect to the specified gradient
  16235. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16236. * @returns the current particle system
  16237. */
  16238. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16239. /**
  16240. * Remove a specific start size gradient
  16241. * @param gradient defines the gradient to remove
  16242. * @returns the current particle system
  16243. */
  16244. removeStartSizeGradient(gradient: number): IParticleSystem;
  16245. private _createRampGradientTexture;
  16246. /**
  16247. * Gets the current list of ramp gradients.
  16248. * You must use addRampGradient and removeRampGradient to update this list
  16249. * @returns the list of ramp gradients
  16250. */
  16251. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16252. /** Force the system to rebuild all gradients that need to be resync */
  16253. forceRefreshGradients(): void;
  16254. private _syncRampGradientTexture;
  16255. /**
  16256. * Adds a new ramp gradient used to remap particle colors
  16257. * @param gradient defines the gradient to use (between 0 and 1)
  16258. * @param color defines the color to affect to the specified gradient
  16259. * @returns the current particle system
  16260. */
  16261. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  16262. /**
  16263. * Remove a specific ramp gradient
  16264. * @param gradient defines the gradient to remove
  16265. * @returns the current particle system
  16266. */
  16267. removeRampGradient(gradient: number): ParticleSystem;
  16268. /**
  16269. * Adds a new color gradient
  16270. * @param gradient defines the gradient to use (between 0 and 1)
  16271. * @param color1 defines the color to affect to the specified gradient
  16272. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16273. * @returns this particle system
  16274. */
  16275. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16276. /**
  16277. * Remove a specific color gradient
  16278. * @param gradient defines the gradient to remove
  16279. * @returns this particle system
  16280. */
  16281. removeColorGradient(gradient: number): IParticleSystem;
  16282. private _fetchR;
  16283. protected _reset(): void;
  16284. private _resetEffect;
  16285. private _createVertexBuffers;
  16286. private _createIndexBuffer;
  16287. /**
  16288. * Gets the maximum number of particles active at the same time.
  16289. * @returns The max number of active particles.
  16290. */
  16291. getCapacity(): number;
  16292. /**
  16293. * Gets whether there are still active particles in the system.
  16294. * @returns True if it is alive, otherwise false.
  16295. */
  16296. isAlive(): boolean;
  16297. /**
  16298. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16299. * @returns True if it has been started, otherwise false.
  16300. */
  16301. isStarted(): boolean;
  16302. private _prepareSubEmitterInternalArray;
  16303. /**
  16304. * Starts the particle system and begins to emit
  16305. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  16306. */
  16307. start(delay?: number): void;
  16308. /**
  16309. * Stops the particle system.
  16310. * @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.
  16311. */
  16312. stop(stopSubEmitters?: boolean): void;
  16313. /**
  16314. * Remove all active particles
  16315. */
  16316. reset(): void;
  16317. /**
  16318. * @hidden (for internal use only)
  16319. */
  16320. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  16321. /**
  16322. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  16323. * Its lifetime will start back at 0.
  16324. */
  16325. recycleParticle: (particle: Particle) => void;
  16326. private _stopSubEmitters;
  16327. private _createParticle;
  16328. private _removeFromRoot;
  16329. private _emitFromParticle;
  16330. private _update;
  16331. /** @hidden */
  16332. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  16333. /** @hidden */
  16334. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  16335. /**
  16336. * Fill the defines array according to the current settings of the particle system
  16337. * @param defines Array to be updated
  16338. * @param blendMode blend mode to take into account when updating the array
  16339. */
  16340. fillDefines(defines: Array<string>, blendMode: number): void;
  16341. /**
  16342. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  16343. * @param uniforms Uniforms array to fill
  16344. * @param attributes Attributes array to fill
  16345. * @param samplers Samplers array to fill
  16346. */
  16347. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  16348. /** @hidden */
  16349. private _getEffect;
  16350. /**
  16351. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  16352. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  16353. */
  16354. animate(preWarmOnly?: boolean): void;
  16355. private _appendParticleVertices;
  16356. /**
  16357. * Rebuilds the particle system.
  16358. */
  16359. rebuild(): void;
  16360. /**
  16361. * Is this system ready to be used/rendered
  16362. * @return true if the system is ready
  16363. */
  16364. isReady(): boolean;
  16365. private _render;
  16366. /**
  16367. * Renders the particle system in its current state.
  16368. * @returns the current number of particles
  16369. */
  16370. render(): number;
  16371. /**
  16372. * Disposes the particle system and free the associated resources
  16373. * @param disposeTexture defines if the particle texture must be disposed as well (true by default)
  16374. */
  16375. dispose(disposeTexture?: boolean): void;
  16376. /**
  16377. * Clones the particle system.
  16378. * @param name The name of the cloned object
  16379. * @param newEmitter The new emitter to use
  16380. * @returns the cloned particle system
  16381. */
  16382. clone(name: string, newEmitter: any): ParticleSystem;
  16383. /**
  16384. * Serializes the particle system to a JSON object
  16385. * @param serializeTexture defines if the texture must be serialized as well
  16386. * @returns the JSON object
  16387. */
  16388. serialize(serializeTexture?: boolean): any;
  16389. /** @hidden */
  16390. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  16391. /** @hidden */
  16392. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  16393. /**
  16394. * Parses a JSON object to create a particle system.
  16395. * @param parsedParticleSystem The JSON object to parse
  16396. * @param sceneOrEngine The scene or the engine to create the particle system in
  16397. * @param rootUrl The root url to use to load external dependencies like texture
  16398. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  16399. * @returns the Parsed particle system
  16400. */
  16401. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  16402. }
  16403. }
  16404. declare module BABYLON {
  16405. /**
  16406. * A particle represents one of the element emitted by a particle system.
  16407. * This is mainly define by its coordinates, direction, velocity and age.
  16408. */
  16409. export class Particle {
  16410. /**
  16411. * The particle system the particle belongs to.
  16412. */
  16413. particleSystem: ParticleSystem;
  16414. private static _Count;
  16415. /**
  16416. * Unique ID of the particle
  16417. */
  16418. id: number;
  16419. /**
  16420. * The world position of the particle in the scene.
  16421. */
  16422. position: Vector3;
  16423. /**
  16424. * The world direction of the particle in the scene.
  16425. */
  16426. direction: Vector3;
  16427. /**
  16428. * The color of the particle.
  16429. */
  16430. color: Color4;
  16431. /**
  16432. * The color change of the particle per step.
  16433. */
  16434. colorStep: Color4;
  16435. /**
  16436. * Defines how long will the life of the particle be.
  16437. */
  16438. lifeTime: number;
  16439. /**
  16440. * The current age of the particle.
  16441. */
  16442. age: number;
  16443. /**
  16444. * The current size of the particle.
  16445. */
  16446. size: number;
  16447. /**
  16448. * The current scale of the particle.
  16449. */
  16450. scale: Vector2;
  16451. /**
  16452. * The current angle of the particle.
  16453. */
  16454. angle: number;
  16455. /**
  16456. * Defines how fast is the angle changing.
  16457. */
  16458. angularSpeed: number;
  16459. /**
  16460. * Defines the cell index used by the particle to be rendered from a sprite.
  16461. */
  16462. cellIndex: number;
  16463. /**
  16464. * The information required to support color remapping
  16465. */
  16466. remapData: Vector4;
  16467. /** @hidden */
  16468. _randomCellOffset?: number;
  16469. /** @hidden */
  16470. _initialDirection: Nullable<Vector3>;
  16471. /** @hidden */
  16472. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  16473. /** @hidden */
  16474. _initialStartSpriteCellID: number;
  16475. /** @hidden */
  16476. _initialEndSpriteCellID: number;
  16477. /** @hidden */
  16478. _currentColorGradient: Nullable<ColorGradient>;
  16479. /** @hidden */
  16480. _currentColor1: Color4;
  16481. /** @hidden */
  16482. _currentColor2: Color4;
  16483. /** @hidden */
  16484. _currentSizeGradient: Nullable<FactorGradient>;
  16485. /** @hidden */
  16486. _currentSize1: number;
  16487. /** @hidden */
  16488. _currentSize2: number;
  16489. /** @hidden */
  16490. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  16491. /** @hidden */
  16492. _currentAngularSpeed1: number;
  16493. /** @hidden */
  16494. _currentAngularSpeed2: number;
  16495. /** @hidden */
  16496. _currentVelocityGradient: Nullable<FactorGradient>;
  16497. /** @hidden */
  16498. _currentVelocity1: number;
  16499. /** @hidden */
  16500. _currentVelocity2: number;
  16501. /** @hidden */
  16502. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  16503. /** @hidden */
  16504. _currentLimitVelocity1: number;
  16505. /** @hidden */
  16506. _currentLimitVelocity2: number;
  16507. /** @hidden */
  16508. _currentDragGradient: Nullable<FactorGradient>;
  16509. /** @hidden */
  16510. _currentDrag1: number;
  16511. /** @hidden */
  16512. _currentDrag2: number;
  16513. /** @hidden */
  16514. _randomNoiseCoordinates1: Vector3;
  16515. /** @hidden */
  16516. _randomNoiseCoordinates2: Vector3;
  16517. /** @hidden */
  16518. _localPosition?: Vector3;
  16519. /**
  16520. * Creates a new instance Particle
  16521. * @param particleSystem the particle system the particle belongs to
  16522. */
  16523. constructor(
  16524. /**
  16525. * The particle system the particle belongs to.
  16526. */
  16527. particleSystem: ParticleSystem);
  16528. private updateCellInfoFromSystem;
  16529. /**
  16530. * Defines how the sprite cell index is updated for the particle
  16531. */
  16532. updateCellIndex(): void;
  16533. /** @hidden */
  16534. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  16535. /** @hidden */
  16536. _inheritParticleInfoToSubEmitters(): void;
  16537. /** @hidden */
  16538. _reset(): void;
  16539. /**
  16540. * Copy the properties of particle to another one.
  16541. * @param other the particle to copy the information to.
  16542. */
  16543. copyTo(other: Particle): void;
  16544. }
  16545. }
  16546. declare module BABYLON {
  16547. /**
  16548. * Particle emitter represents a volume emitting particles.
  16549. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  16550. */
  16551. export interface IParticleEmitterType {
  16552. /**
  16553. * Called by the particle System when the direction is computed for the created particle.
  16554. * @param worldMatrix is the world matrix of the particle system
  16555. * @param directionToUpdate is the direction vector to update with the result
  16556. * @param particle is the particle we are computed the direction for
  16557. * @param isLocal defines if the direction should be set in local space
  16558. */
  16559. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16560. /**
  16561. * Called by the particle System when the position is computed for the created particle.
  16562. * @param worldMatrix is the world matrix of the particle system
  16563. * @param positionToUpdate is the position vector to update with the result
  16564. * @param particle is the particle we are computed the position for
  16565. * @param isLocal defines if the position should be set in local space
  16566. */
  16567. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16568. /**
  16569. * Clones the current emitter and returns a copy of it
  16570. * @returns the new emitter
  16571. */
  16572. clone(): IParticleEmitterType;
  16573. /**
  16574. * Called by the GPUParticleSystem to setup the update shader
  16575. * @param effect defines the update shader
  16576. */
  16577. applyToShader(effect: Effect): void;
  16578. /**
  16579. * Returns a string to use to update the GPU particles update shader
  16580. * @returns the effect defines string
  16581. */
  16582. getEffectDefines(): string;
  16583. /**
  16584. * Returns a string representing the class name
  16585. * @returns a string containing the class name
  16586. */
  16587. getClassName(): string;
  16588. /**
  16589. * Serializes the particle system to a JSON object.
  16590. * @returns the JSON object
  16591. */
  16592. serialize(): any;
  16593. /**
  16594. * Parse properties from a JSON object
  16595. * @param serializationObject defines the JSON object
  16596. * @param scene defines the hosting scene
  16597. */
  16598. parse(serializationObject: any, scene: Nullable<Scene>): void;
  16599. }
  16600. }
  16601. declare module BABYLON {
  16602. /**
  16603. * Particle emitter emitting particles from the inside of a box.
  16604. * It emits the particles randomly between 2 given directions.
  16605. */
  16606. export class BoxParticleEmitter implements IParticleEmitterType {
  16607. /**
  16608. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16609. */
  16610. direction1: Vector3;
  16611. /**
  16612. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16613. */
  16614. direction2: Vector3;
  16615. /**
  16616. * 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.
  16617. */
  16618. minEmitBox: Vector3;
  16619. /**
  16620. * 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.
  16621. */
  16622. maxEmitBox: Vector3;
  16623. /**
  16624. * Creates a new instance BoxParticleEmitter
  16625. */
  16626. constructor();
  16627. /**
  16628. * Called by the particle System when the direction is computed for the created particle.
  16629. * @param worldMatrix is the world matrix of the particle system
  16630. * @param directionToUpdate is the direction vector to update with the result
  16631. * @param particle is the particle we are computed the direction for
  16632. * @param isLocal defines if the direction should be set in local space
  16633. */
  16634. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16635. /**
  16636. * Called by the particle System when the position is computed for the created particle.
  16637. * @param worldMatrix is the world matrix of the particle system
  16638. * @param positionToUpdate is the position vector to update with the result
  16639. * @param particle is the particle we are computed the position for
  16640. * @param isLocal defines if the position should be set in local space
  16641. */
  16642. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16643. /**
  16644. * Clones the current emitter and returns a copy of it
  16645. * @returns the new emitter
  16646. */
  16647. clone(): BoxParticleEmitter;
  16648. /**
  16649. * Called by the GPUParticleSystem to setup the update shader
  16650. * @param effect defines the update shader
  16651. */
  16652. applyToShader(effect: Effect): void;
  16653. /**
  16654. * Returns a string to use to update the GPU particles update shader
  16655. * @returns a string containing the defines string
  16656. */
  16657. getEffectDefines(): string;
  16658. /**
  16659. * Returns the string "BoxParticleEmitter"
  16660. * @returns a string containing the class name
  16661. */
  16662. getClassName(): string;
  16663. /**
  16664. * Serializes the particle system to a JSON object.
  16665. * @returns the JSON object
  16666. */
  16667. serialize(): any;
  16668. /**
  16669. * Parse properties from a JSON object
  16670. * @param serializationObject defines the JSON object
  16671. */
  16672. parse(serializationObject: any): void;
  16673. }
  16674. }
  16675. declare module BABYLON {
  16676. /**
  16677. * Particle emitter emitting particles from the inside of a cone.
  16678. * It emits the particles alongside the cone volume from the base to the particle.
  16679. * The emission direction might be randomized.
  16680. */
  16681. export class ConeParticleEmitter implements IParticleEmitterType {
  16682. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  16683. directionRandomizer: number;
  16684. private _radius;
  16685. private _angle;
  16686. private _height;
  16687. /**
  16688. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  16689. */
  16690. radiusRange: number;
  16691. /**
  16692. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  16693. */
  16694. heightRange: number;
  16695. /**
  16696. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  16697. */
  16698. emitFromSpawnPointOnly: boolean;
  16699. /**
  16700. * Gets or sets the radius of the emission cone
  16701. */
  16702. get radius(): number;
  16703. set radius(value: number);
  16704. /**
  16705. * Gets or sets the angle of the emission cone
  16706. */
  16707. get angle(): number;
  16708. set angle(value: number);
  16709. private _buildHeight;
  16710. /**
  16711. * Creates a new instance ConeParticleEmitter
  16712. * @param radius the radius of the emission cone (1 by default)
  16713. * @param angle the cone base angle (PI by default)
  16714. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  16715. */
  16716. constructor(radius?: number, angle?: number,
  16717. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  16718. directionRandomizer?: number);
  16719. /**
  16720. * Called by the particle System when the direction is computed for the created particle.
  16721. * @param worldMatrix is the world matrix of the particle system
  16722. * @param directionToUpdate is the direction vector to update with the result
  16723. * @param particle is the particle we are computed the direction for
  16724. * @param isLocal defines if the direction should be set in local space
  16725. */
  16726. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16727. /**
  16728. * Called by the particle System when the position is computed for the created particle.
  16729. * @param worldMatrix is the world matrix of the particle system
  16730. * @param positionToUpdate is the position vector to update with the result
  16731. * @param particle is the particle we are computed the position for
  16732. * @param isLocal defines if the position should be set in local space
  16733. */
  16734. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16735. /**
  16736. * Clones the current emitter and returns a copy of it
  16737. * @returns the new emitter
  16738. */
  16739. clone(): ConeParticleEmitter;
  16740. /**
  16741. * Called by the GPUParticleSystem to setup the update shader
  16742. * @param effect defines the update shader
  16743. */
  16744. applyToShader(effect: Effect): void;
  16745. /**
  16746. * Returns a string to use to update the GPU particles update shader
  16747. * @returns a string containing the defines string
  16748. */
  16749. getEffectDefines(): string;
  16750. /**
  16751. * Returns the string "ConeParticleEmitter"
  16752. * @returns a string containing the class name
  16753. */
  16754. getClassName(): string;
  16755. /**
  16756. * Serializes the particle system to a JSON object.
  16757. * @returns the JSON object
  16758. */
  16759. serialize(): any;
  16760. /**
  16761. * Parse properties from a JSON object
  16762. * @param serializationObject defines the JSON object
  16763. */
  16764. parse(serializationObject: any): void;
  16765. }
  16766. }
  16767. declare module BABYLON {
  16768. /**
  16769. * Particle emitter emitting particles from the inside of a cylinder.
  16770. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  16771. */
  16772. export class CylinderParticleEmitter implements IParticleEmitterType {
  16773. /**
  16774. * The radius of the emission cylinder.
  16775. */
  16776. radius: number;
  16777. /**
  16778. * The height of the emission cylinder.
  16779. */
  16780. height: number;
  16781. /**
  16782. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16783. */
  16784. radiusRange: number;
  16785. /**
  16786. * How much to randomize the particle direction [0-1].
  16787. */
  16788. directionRandomizer: number;
  16789. /**
  16790. * Creates a new instance CylinderParticleEmitter
  16791. * @param radius the radius of the emission cylinder (1 by default)
  16792. * @param height the height of the emission cylinder (1 by default)
  16793. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16794. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16795. */
  16796. constructor(
  16797. /**
  16798. * The radius of the emission cylinder.
  16799. */
  16800. radius?: number,
  16801. /**
  16802. * The height of the emission cylinder.
  16803. */
  16804. height?: number,
  16805. /**
  16806. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16807. */
  16808. radiusRange?: number,
  16809. /**
  16810. * How much to randomize the particle direction [0-1].
  16811. */
  16812. directionRandomizer?: number);
  16813. /**
  16814. * Called by the particle System when the direction is computed for the created particle.
  16815. * @param worldMatrix is the world matrix of the particle system
  16816. * @param directionToUpdate is the direction vector to update with the result
  16817. * @param particle is the particle we are computed the direction for
  16818. * @param isLocal defines if the direction should be set in local space
  16819. */
  16820. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16821. /**
  16822. * Called by the particle System when the position is computed for the created particle.
  16823. * @param worldMatrix is the world matrix of the particle system
  16824. * @param positionToUpdate is the position vector to update with the result
  16825. * @param particle is the particle we are computed the position for
  16826. * @param isLocal defines if the position should be set in local space
  16827. */
  16828. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16829. /**
  16830. * Clones the current emitter and returns a copy of it
  16831. * @returns the new emitter
  16832. */
  16833. clone(): CylinderParticleEmitter;
  16834. /**
  16835. * Called by the GPUParticleSystem to setup the update shader
  16836. * @param effect defines the update shader
  16837. */
  16838. applyToShader(effect: Effect): void;
  16839. /**
  16840. * Returns a string to use to update the GPU particles update shader
  16841. * @returns a string containing the defines string
  16842. */
  16843. getEffectDefines(): string;
  16844. /**
  16845. * Returns the string "CylinderParticleEmitter"
  16846. * @returns a string containing the class name
  16847. */
  16848. getClassName(): string;
  16849. /**
  16850. * Serializes the particle system to a JSON object.
  16851. * @returns the JSON object
  16852. */
  16853. serialize(): any;
  16854. /**
  16855. * Parse properties from a JSON object
  16856. * @param serializationObject defines the JSON object
  16857. */
  16858. parse(serializationObject: any): void;
  16859. }
  16860. /**
  16861. * Particle emitter emitting particles from the inside of a cylinder.
  16862. * It emits the particles randomly between two vectors.
  16863. */
  16864. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  16865. /**
  16866. * The min limit of the emission direction.
  16867. */
  16868. direction1: Vector3;
  16869. /**
  16870. * The max limit of the emission direction.
  16871. */
  16872. direction2: Vector3;
  16873. /**
  16874. * Creates a new instance CylinderDirectedParticleEmitter
  16875. * @param radius the radius of the emission cylinder (1 by default)
  16876. * @param height the height of the emission cylinder (1 by default)
  16877. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16878. * @param direction1 the min limit of the emission direction (up vector by default)
  16879. * @param direction2 the max limit of the emission direction (up vector by default)
  16880. */
  16881. constructor(radius?: number, height?: number, radiusRange?: number,
  16882. /**
  16883. * The min limit of the emission direction.
  16884. */
  16885. direction1?: Vector3,
  16886. /**
  16887. * The max limit of the emission direction.
  16888. */
  16889. direction2?: Vector3);
  16890. /**
  16891. * Called by the particle System when the direction is computed for the created particle.
  16892. * @param worldMatrix is the world matrix of the particle system
  16893. * @param directionToUpdate is the direction vector to update with the result
  16894. * @param particle is the particle we are computed the direction for
  16895. */
  16896. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16897. /**
  16898. * Clones the current emitter and returns a copy of it
  16899. * @returns the new emitter
  16900. */
  16901. clone(): CylinderDirectedParticleEmitter;
  16902. /**
  16903. * Called by the GPUParticleSystem to setup the update shader
  16904. * @param effect defines the update shader
  16905. */
  16906. applyToShader(effect: Effect): void;
  16907. /**
  16908. * Returns a string to use to update the GPU particles update shader
  16909. * @returns a string containing the defines string
  16910. */
  16911. getEffectDefines(): string;
  16912. /**
  16913. * Returns the string "CylinderDirectedParticleEmitter"
  16914. * @returns a string containing the class name
  16915. */
  16916. getClassName(): string;
  16917. /**
  16918. * Serializes the particle system to a JSON object.
  16919. * @returns the JSON object
  16920. */
  16921. serialize(): any;
  16922. /**
  16923. * Parse properties from a JSON object
  16924. * @param serializationObject defines the JSON object
  16925. */
  16926. parse(serializationObject: any): void;
  16927. }
  16928. }
  16929. declare module BABYLON {
  16930. /**
  16931. * Particle emitter emitting particles from the inside of a hemisphere.
  16932. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  16933. */
  16934. export class HemisphericParticleEmitter implements IParticleEmitterType {
  16935. /**
  16936. * The radius of the emission hemisphere.
  16937. */
  16938. radius: number;
  16939. /**
  16940. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16941. */
  16942. radiusRange: number;
  16943. /**
  16944. * How much to randomize the particle direction [0-1].
  16945. */
  16946. directionRandomizer: number;
  16947. /**
  16948. * Creates a new instance HemisphericParticleEmitter
  16949. * @param radius the radius of the emission hemisphere (1 by default)
  16950. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16951. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16952. */
  16953. constructor(
  16954. /**
  16955. * The radius of the emission hemisphere.
  16956. */
  16957. radius?: number,
  16958. /**
  16959. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16960. */
  16961. radiusRange?: number,
  16962. /**
  16963. * How much to randomize the particle direction [0-1].
  16964. */
  16965. directionRandomizer?: number);
  16966. /**
  16967. * Called by the particle System when the direction is computed for the created particle.
  16968. * @param worldMatrix is the world matrix of the particle system
  16969. * @param directionToUpdate is the direction vector to update with the result
  16970. * @param particle is the particle we are computed the direction for
  16971. * @param isLocal defines if the direction should be set in local space
  16972. */
  16973. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16974. /**
  16975. * Called by the particle System when the position is computed for the created particle.
  16976. * @param worldMatrix is the world matrix of the particle system
  16977. * @param positionToUpdate is the position vector to update with the result
  16978. * @param particle is the particle we are computed the position for
  16979. * @param isLocal defines if the position should be set in local space
  16980. */
  16981. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16982. /**
  16983. * Clones the current emitter and returns a copy of it
  16984. * @returns the new emitter
  16985. */
  16986. clone(): HemisphericParticleEmitter;
  16987. /**
  16988. * Called by the GPUParticleSystem to setup the update shader
  16989. * @param effect defines the update shader
  16990. */
  16991. applyToShader(effect: Effect): void;
  16992. /**
  16993. * Returns a string to use to update the GPU particles update shader
  16994. * @returns a string containing the defines string
  16995. */
  16996. getEffectDefines(): string;
  16997. /**
  16998. * Returns the string "HemisphericParticleEmitter"
  16999. * @returns a string containing the class name
  17000. */
  17001. getClassName(): string;
  17002. /**
  17003. * Serializes the particle system to a JSON object.
  17004. * @returns the JSON object
  17005. */
  17006. serialize(): any;
  17007. /**
  17008. * Parse properties from a JSON object
  17009. * @param serializationObject defines the JSON object
  17010. */
  17011. parse(serializationObject: any): void;
  17012. }
  17013. }
  17014. declare module BABYLON {
  17015. /**
  17016. * Particle emitter emitting particles from a point.
  17017. * It emits the particles randomly between 2 given directions.
  17018. */
  17019. export class PointParticleEmitter implements IParticleEmitterType {
  17020. /**
  17021. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17022. */
  17023. direction1: Vector3;
  17024. /**
  17025. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17026. */
  17027. direction2: Vector3;
  17028. /**
  17029. * Creates a new instance PointParticleEmitter
  17030. */
  17031. constructor();
  17032. /**
  17033. * Called by the particle System when the direction is computed for the created particle.
  17034. * @param worldMatrix is the world matrix of the particle system
  17035. * @param directionToUpdate is the direction vector to update with the result
  17036. * @param particle is the particle we are computed the direction for
  17037. * @param isLocal defines if the direction should be set in local space
  17038. */
  17039. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  17040. /**
  17041. * Called by the particle System when the position is computed for the created particle.
  17042. * @param worldMatrix is the world matrix of the particle system
  17043. * @param positionToUpdate is the position vector to update with the result
  17044. * @param particle is the particle we are computed the position for
  17045. * @param isLocal defines if the position should be set in local space
  17046. */
  17047. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  17048. /**
  17049. * Clones the current emitter and returns a copy of it
  17050. * @returns the new emitter
  17051. */
  17052. clone(): PointParticleEmitter;
  17053. /**
  17054. * Called by the GPUParticleSystem to setup the update shader
  17055. * @param effect defines the update shader
  17056. */
  17057. applyToShader(effect: Effect): void;
  17058. /**
  17059. * Returns a string to use to update the GPU particles update shader
  17060. * @returns a string containing the defines string
  17061. */
  17062. getEffectDefines(): string;
  17063. /**
  17064. * Returns the string "PointParticleEmitter"
  17065. * @returns a string containing the class name
  17066. */
  17067. getClassName(): string;
  17068. /**
  17069. * Serializes the particle system to a JSON object.
  17070. * @returns the JSON object
  17071. */
  17072. serialize(): any;
  17073. /**
  17074. * Parse properties from a JSON object
  17075. * @param serializationObject defines the JSON object
  17076. */
  17077. parse(serializationObject: any): void;
  17078. }
  17079. }
  17080. declare module BABYLON {
  17081. /**
  17082. * Particle emitter emitting particles from the inside of a sphere.
  17083. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  17084. */
  17085. export class SphereParticleEmitter implements IParticleEmitterType {
  17086. /**
  17087. * The radius of the emission sphere.
  17088. */
  17089. radius: number;
  17090. /**
  17091. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17092. */
  17093. radiusRange: number;
  17094. /**
  17095. * How much to randomize the particle direction [0-1].
  17096. */
  17097. directionRandomizer: number;
  17098. /**
  17099. * Creates a new instance SphereParticleEmitter
  17100. * @param radius the radius of the emission sphere (1 by default)
  17101. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17102. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17103. */
  17104. constructor(
  17105. /**
  17106. * The radius of the emission sphere.
  17107. */
  17108. radius?: number,
  17109. /**
  17110. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17111. */
  17112. radiusRange?: number,
  17113. /**
  17114. * How much to randomize the particle direction [0-1].
  17115. */
  17116. directionRandomizer?: number);
  17117. /**
  17118. * Called by the particle System when the direction is computed for the created particle.
  17119. * @param worldMatrix is the world matrix of the particle system
  17120. * @param directionToUpdate is the direction vector to update with the result
  17121. * @param particle is the particle we are computed the direction for
  17122. * @param isLocal defines if the direction should be set in local space
  17123. */
  17124. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  17125. /**
  17126. * Called by the particle System when the position is computed for the created particle.
  17127. * @param worldMatrix is the world matrix of the particle system
  17128. * @param positionToUpdate is the position vector to update with the result
  17129. * @param particle is the particle we are computed the position for
  17130. * @param isLocal defines if the position should be set in local space
  17131. */
  17132. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  17133. /**
  17134. * Clones the current emitter and returns a copy of it
  17135. * @returns the new emitter
  17136. */
  17137. clone(): SphereParticleEmitter;
  17138. /**
  17139. * Called by the GPUParticleSystem to setup the update shader
  17140. * @param effect defines the update shader
  17141. */
  17142. applyToShader(effect: Effect): void;
  17143. /**
  17144. * Returns a string to use to update the GPU particles update shader
  17145. * @returns a string containing the defines string
  17146. */
  17147. getEffectDefines(): string;
  17148. /**
  17149. * Returns the string "SphereParticleEmitter"
  17150. * @returns a string containing the class name
  17151. */
  17152. getClassName(): string;
  17153. /**
  17154. * Serializes the particle system to a JSON object.
  17155. * @returns the JSON object
  17156. */
  17157. serialize(): any;
  17158. /**
  17159. * Parse properties from a JSON object
  17160. * @param serializationObject defines the JSON object
  17161. */
  17162. parse(serializationObject: any): void;
  17163. }
  17164. /**
  17165. * Particle emitter emitting particles from the inside of a sphere.
  17166. * It emits the particles randomly between two vectors.
  17167. */
  17168. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  17169. /**
  17170. * The min limit of the emission direction.
  17171. */
  17172. direction1: Vector3;
  17173. /**
  17174. * The max limit of the emission direction.
  17175. */
  17176. direction2: Vector3;
  17177. /**
  17178. * Creates a new instance SphereDirectedParticleEmitter
  17179. * @param radius the radius of the emission sphere (1 by default)
  17180. * @param direction1 the min limit of the emission direction (up vector by default)
  17181. * @param direction2 the max limit of the emission direction (up vector by default)
  17182. */
  17183. constructor(radius?: number,
  17184. /**
  17185. * The min limit of the emission direction.
  17186. */
  17187. direction1?: Vector3,
  17188. /**
  17189. * The max limit of the emission direction.
  17190. */
  17191. direction2?: Vector3);
  17192. /**
  17193. * Called by the particle System when the direction is computed for the created particle.
  17194. * @param worldMatrix is the world matrix of the particle system
  17195. * @param directionToUpdate is the direction vector to update with the result
  17196. * @param particle is the particle we are computed the direction for
  17197. */
  17198. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17199. /**
  17200. * Clones the current emitter and returns a copy of it
  17201. * @returns the new emitter
  17202. */
  17203. clone(): SphereDirectedParticleEmitter;
  17204. /**
  17205. * Called by the GPUParticleSystem to setup the update shader
  17206. * @param effect defines the update shader
  17207. */
  17208. applyToShader(effect: Effect): void;
  17209. /**
  17210. * Returns a string to use to update the GPU particles update shader
  17211. * @returns a string containing the defines string
  17212. */
  17213. getEffectDefines(): string;
  17214. /**
  17215. * Returns the string "SphereDirectedParticleEmitter"
  17216. * @returns a string containing the class name
  17217. */
  17218. getClassName(): string;
  17219. /**
  17220. * Serializes the particle system to a JSON object.
  17221. * @returns the JSON object
  17222. */
  17223. serialize(): any;
  17224. /**
  17225. * Parse properties from a JSON object
  17226. * @param serializationObject defines the JSON object
  17227. */
  17228. parse(serializationObject: any): void;
  17229. }
  17230. }
  17231. declare module BABYLON {
  17232. /**
  17233. * Particle emitter emitting particles from a custom list of positions.
  17234. */
  17235. export class CustomParticleEmitter implements IParticleEmitterType {
  17236. /**
  17237. * Gets or sets the position generator that will create the initial position of each particle.
  17238. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  17239. */
  17240. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  17241. /**
  17242. * Gets or sets the destination generator that will create the final destination of each particle.
  17243. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  17244. */
  17245. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  17246. /**
  17247. * Creates a new instance CustomParticleEmitter
  17248. */
  17249. constructor();
  17250. /**
  17251. * Called by the particle System when the direction is computed for the created particle.
  17252. * @param worldMatrix is the world matrix of the particle system
  17253. * @param directionToUpdate is the direction vector to update with the result
  17254. * @param particle is the particle we are computed the direction for
  17255. * @param isLocal defines if the direction should be set in local space
  17256. */
  17257. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  17258. /**
  17259. * Called by the particle System when the position is computed for the created particle.
  17260. * @param worldMatrix is the world matrix of the particle system
  17261. * @param positionToUpdate is the position vector to update with the result
  17262. * @param particle is the particle we are computed the position for
  17263. * @param isLocal defines if the position should be set in local space
  17264. */
  17265. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  17266. /**
  17267. * Clones the current emitter and returns a copy of it
  17268. * @returns the new emitter
  17269. */
  17270. clone(): CustomParticleEmitter;
  17271. /**
  17272. * Called by the GPUParticleSystem to setup the update shader
  17273. * @param effect defines the update shader
  17274. */
  17275. applyToShader(effect: Effect): void;
  17276. /**
  17277. * Returns a string to use to update the GPU particles update shader
  17278. * @returns a string containing the defines string
  17279. */
  17280. getEffectDefines(): string;
  17281. /**
  17282. * Returns the string "PointParticleEmitter"
  17283. * @returns a string containing the class name
  17284. */
  17285. getClassName(): string;
  17286. /**
  17287. * Serializes the particle system to a JSON object.
  17288. * @returns the JSON object
  17289. */
  17290. serialize(): any;
  17291. /**
  17292. * Parse properties from a JSON object
  17293. * @param serializationObject defines the JSON object
  17294. */
  17295. parse(serializationObject: any): void;
  17296. }
  17297. }
  17298. declare module BABYLON {
  17299. /**
  17300. * Particle emitter emitting particles from the inside of a box.
  17301. * It emits the particles randomly between 2 given directions.
  17302. */
  17303. export class MeshParticleEmitter implements IParticleEmitterType {
  17304. private _indices;
  17305. private _positions;
  17306. private _normals;
  17307. private _storedNormal;
  17308. private _mesh;
  17309. /**
  17310. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17311. */
  17312. direction1: Vector3;
  17313. /**
  17314. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17315. */
  17316. direction2: Vector3;
  17317. /**
  17318. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  17319. */
  17320. useMeshNormalsForDirection: boolean;
  17321. /** Defines the mesh to use as source */
  17322. get mesh(): Nullable<AbstractMesh>;
  17323. set mesh(value: Nullable<AbstractMesh>);
  17324. /**
  17325. * Creates a new instance MeshParticleEmitter
  17326. * @param mesh defines the mesh to use as source
  17327. */
  17328. constructor(mesh?: Nullable<AbstractMesh>);
  17329. /**
  17330. * Called by the particle System when the direction is computed for the created particle.
  17331. * @param worldMatrix is the world matrix of the particle system
  17332. * @param directionToUpdate is the direction vector to update with the result
  17333. * @param particle is the particle we are computed the direction for
  17334. * @param isLocal defines if the direction should be set in local space
  17335. */
  17336. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  17337. /**
  17338. * Called by the particle System when the position is computed for the created particle.
  17339. * @param worldMatrix is the world matrix of the particle system
  17340. * @param positionToUpdate is the position vector to update with the result
  17341. * @param particle is the particle we are computed the position for
  17342. * @param isLocal defines if the position should be set in local space
  17343. */
  17344. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  17345. /**
  17346. * Clones the current emitter and returns a copy of it
  17347. * @returns the new emitter
  17348. */
  17349. clone(): MeshParticleEmitter;
  17350. /**
  17351. * Called by the GPUParticleSystem to setup the update shader
  17352. * @param effect defines the update shader
  17353. */
  17354. applyToShader(effect: Effect): void;
  17355. /**
  17356. * Returns a string to use to update the GPU particles update shader
  17357. * @returns a string containing the defines string
  17358. */
  17359. getEffectDefines(): string;
  17360. /**
  17361. * Returns the string "BoxParticleEmitter"
  17362. * @returns a string containing the class name
  17363. */
  17364. getClassName(): string;
  17365. /**
  17366. * Serializes the particle system to a JSON object.
  17367. * @returns the JSON object
  17368. */
  17369. serialize(): any;
  17370. /**
  17371. * Parse properties from a JSON object
  17372. * @param serializationObject defines the JSON object
  17373. * @param scene defines the hosting scene
  17374. */
  17375. parse(serializationObject: any, scene: Nullable<Scene>): void;
  17376. }
  17377. }
  17378. declare module BABYLON {
  17379. /**
  17380. * Interface representing a particle system in Babylon.js.
  17381. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  17382. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  17383. */
  17384. export interface IParticleSystem {
  17385. /**
  17386. * List of animations used by the particle system.
  17387. */
  17388. animations: Animation[];
  17389. /**
  17390. * The id of the Particle system.
  17391. */
  17392. id: string;
  17393. /**
  17394. * The name of the Particle system.
  17395. */
  17396. name: string;
  17397. /**
  17398. * The emitter represents the Mesh or position we are attaching the particle system to.
  17399. */
  17400. emitter: Nullable<AbstractMesh | Vector3>;
  17401. /**
  17402. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17403. */
  17404. isBillboardBased: boolean;
  17405. /**
  17406. * The rendering group used by the Particle system to chose when to render.
  17407. */
  17408. renderingGroupId: number;
  17409. /**
  17410. * The layer mask we are rendering the particles through.
  17411. */
  17412. layerMask: number;
  17413. /**
  17414. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  17415. */
  17416. updateSpeed: number;
  17417. /**
  17418. * The amount of time the particle system is running (depends of the overall update speed).
  17419. */
  17420. targetStopDuration: number;
  17421. /**
  17422. * The texture used to render each particle. (this can be a spritesheet)
  17423. */
  17424. particleTexture: Nullable<BaseTexture>;
  17425. /**
  17426. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  17427. */
  17428. blendMode: number;
  17429. /**
  17430. * Minimum life time of emitting particles.
  17431. */
  17432. minLifeTime: number;
  17433. /**
  17434. * Maximum life time of emitting particles.
  17435. */
  17436. maxLifeTime: number;
  17437. /**
  17438. * Minimum Size of emitting particles.
  17439. */
  17440. minSize: number;
  17441. /**
  17442. * Maximum Size of emitting particles.
  17443. */
  17444. maxSize: number;
  17445. /**
  17446. * Minimum scale of emitting particles on X axis.
  17447. */
  17448. minScaleX: number;
  17449. /**
  17450. * Maximum scale of emitting particles on X axis.
  17451. */
  17452. maxScaleX: number;
  17453. /**
  17454. * Minimum scale of emitting particles on Y axis.
  17455. */
  17456. minScaleY: number;
  17457. /**
  17458. * Maximum scale of emitting particles on Y axis.
  17459. */
  17460. maxScaleY: number;
  17461. /**
  17462. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17463. */
  17464. color1: Color4;
  17465. /**
  17466. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17467. */
  17468. color2: Color4;
  17469. /**
  17470. * Color the particle will have at the end of its lifetime.
  17471. */
  17472. colorDead: Color4;
  17473. /**
  17474. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  17475. */
  17476. emitRate: number;
  17477. /**
  17478. * You can use gravity if you want to give an orientation to your particles.
  17479. */
  17480. gravity: Vector3;
  17481. /**
  17482. * Minimum power of emitting particles.
  17483. */
  17484. minEmitPower: number;
  17485. /**
  17486. * Maximum power of emitting particles.
  17487. */
  17488. maxEmitPower: number;
  17489. /**
  17490. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  17491. */
  17492. minAngularSpeed: number;
  17493. /**
  17494. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  17495. */
  17496. maxAngularSpeed: number;
  17497. /**
  17498. * Gets or sets the minimal initial rotation in radians.
  17499. */
  17500. minInitialRotation: number;
  17501. /**
  17502. * Gets or sets the maximal initial rotation in radians.
  17503. */
  17504. maxInitialRotation: number;
  17505. /**
  17506. * The particle emitter type defines the emitter used by the particle system.
  17507. * It can be for example box, sphere, or cone...
  17508. */
  17509. particleEmitterType: Nullable<IParticleEmitterType>;
  17510. /**
  17511. * Defines the delay in milliseconds before starting the system (0 by default)
  17512. */
  17513. startDelay: number;
  17514. /**
  17515. * 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
  17516. */
  17517. preWarmCycles: number;
  17518. /**
  17519. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  17520. */
  17521. preWarmStepOffset: number;
  17522. /**
  17523. * 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)
  17524. */
  17525. spriteCellChangeSpeed: number;
  17526. /**
  17527. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  17528. */
  17529. startSpriteCellID: number;
  17530. /**
  17531. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  17532. */
  17533. endSpriteCellID: number;
  17534. /**
  17535. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  17536. */
  17537. spriteCellWidth: number;
  17538. /**
  17539. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  17540. */
  17541. spriteCellHeight: number;
  17542. /**
  17543. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  17544. */
  17545. spriteRandomStartCell: boolean;
  17546. /**
  17547. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  17548. */
  17549. isAnimationSheetEnabled: boolean;
  17550. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17551. translationPivot: Vector2;
  17552. /**
  17553. * Gets or sets a texture used to add random noise to particle positions
  17554. */
  17555. noiseTexture: Nullable<BaseTexture>;
  17556. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  17557. noiseStrength: Vector3;
  17558. /**
  17559. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17560. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17561. */
  17562. billboardMode: number;
  17563. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17564. limitVelocityDamping: number;
  17565. /**
  17566. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  17567. */
  17568. beginAnimationOnStart: boolean;
  17569. /**
  17570. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  17571. */
  17572. beginAnimationFrom: number;
  17573. /**
  17574. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  17575. */
  17576. beginAnimationTo: number;
  17577. /**
  17578. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17579. */
  17580. beginAnimationLoop: boolean;
  17581. /**
  17582. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  17583. */
  17584. disposeOnStop: boolean;
  17585. /**
  17586. * If you want to launch only a few particles at once, that can be done, as well.
  17587. */
  17588. manualEmitCount: number;
  17589. /**
  17590. * Specifies if the particles are updated in emitter local space or world space
  17591. */
  17592. isLocal: boolean;
  17593. /** Snippet ID if the particle system was created from the snippet server */
  17594. snippetId: string;
  17595. /** Gets or sets a matrix to use to compute projection */
  17596. defaultProjectionMatrix: Matrix;
  17597. /**
  17598. * Gets the maximum number of particles active at the same time.
  17599. * @returns The max number of active particles.
  17600. */
  17601. getCapacity(): number;
  17602. /**
  17603. * Gets the number of particles active at the same time.
  17604. * @returns The number of active particles.
  17605. */
  17606. getActiveCount(): number;
  17607. /**
  17608. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17609. * @returns True if it has been started, otherwise false.
  17610. */
  17611. isStarted(): boolean;
  17612. /**
  17613. * Animates the particle system for this frame.
  17614. */
  17615. animate(): void;
  17616. /**
  17617. * Renders the particle system in its current state.
  17618. * @returns the current number of particles
  17619. */
  17620. render(): number;
  17621. /**
  17622. * Dispose the particle system and frees its associated resources.
  17623. * @param disposeTexture defines if the particle texture must be disposed as well (true by default)
  17624. */
  17625. dispose(disposeTexture?: boolean): void;
  17626. /**
  17627. * An event triggered when the system is disposed
  17628. */
  17629. onDisposeObservable: Observable<IParticleSystem>;
  17630. /**
  17631. * An event triggered when the system is stopped
  17632. */
  17633. onStoppedObservable: Observable<IParticleSystem>;
  17634. /**
  17635. * Clones the particle system.
  17636. * @param name The name of the cloned object
  17637. * @param newEmitter The new emitter to use
  17638. * @returns the cloned particle system
  17639. */
  17640. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  17641. /**
  17642. * Serializes the particle system to a JSON object
  17643. * @param serializeTexture defines if the texture must be serialized as well
  17644. * @returns the JSON object
  17645. */
  17646. serialize(serializeTexture: boolean): any;
  17647. /**
  17648. * Rebuild the particle system
  17649. */
  17650. rebuild(): void;
  17651. /** Force the system to rebuild all gradients that need to be resync */
  17652. forceRefreshGradients(): void;
  17653. /**
  17654. * Starts the particle system and begins to emit
  17655. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  17656. */
  17657. start(delay?: number): void;
  17658. /**
  17659. * Stops the particle system.
  17660. */
  17661. stop(): void;
  17662. /**
  17663. * Remove all active particles
  17664. */
  17665. reset(): void;
  17666. /**
  17667. * Gets a boolean indicating that the system is stopping
  17668. * @returns true if the system is currently stopping
  17669. */
  17670. isStopping(): boolean;
  17671. /**
  17672. * Is this system ready to be used/rendered
  17673. * @return true if the system is ready
  17674. */
  17675. isReady(): boolean;
  17676. /**
  17677. * Returns the string "ParticleSystem"
  17678. * @returns a string containing the class name
  17679. */
  17680. getClassName(): string;
  17681. /**
  17682. * Gets the custom effect used to render the particles
  17683. * @param blendMode Blend mode for which the effect should be retrieved
  17684. * @returns The effect
  17685. */
  17686. getCustomEffect(blendMode: number): Nullable<Effect>;
  17687. /**
  17688. * Sets the custom effect used to render the particles
  17689. * @param effect The effect to set
  17690. * @param blendMode Blend mode for which the effect should be set
  17691. */
  17692. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  17693. /**
  17694. * Fill the defines array according to the current settings of the particle system
  17695. * @param defines Array to be updated
  17696. * @param blendMode blend mode to take into account when updating the array
  17697. */
  17698. fillDefines(defines: Array<string>, blendMode: number): void;
  17699. /**
  17700. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  17701. * @param uniforms Uniforms array to fill
  17702. * @param attributes Attributes array to fill
  17703. * @param samplers Samplers array to fill
  17704. */
  17705. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  17706. /**
  17707. * Observable that will be called just before the particles are drawn
  17708. */
  17709. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  17710. /**
  17711. * Gets the name of the particle vertex shader
  17712. */
  17713. vertexShaderName: string;
  17714. /**
  17715. * Adds a new color gradient
  17716. * @param gradient defines the gradient to use (between 0 and 1)
  17717. * @param color1 defines the color to affect to the specified gradient
  17718. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17719. * @returns the current particle system
  17720. */
  17721. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17722. /**
  17723. * Remove a specific color gradient
  17724. * @param gradient defines the gradient to remove
  17725. * @returns the current particle system
  17726. */
  17727. removeColorGradient(gradient: number): IParticleSystem;
  17728. /**
  17729. * Adds a new size gradient
  17730. * @param gradient defines the gradient to use (between 0 and 1)
  17731. * @param factor defines the size factor to affect to the specified gradient
  17732. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17733. * @returns the current particle system
  17734. */
  17735. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17736. /**
  17737. * Remove a specific size gradient
  17738. * @param gradient defines the gradient to remove
  17739. * @returns the current particle system
  17740. */
  17741. removeSizeGradient(gradient: number): IParticleSystem;
  17742. /**
  17743. * Gets the current list of color gradients.
  17744. * You must use addColorGradient and removeColorGradient to update this list
  17745. * @returns the list of color gradients
  17746. */
  17747. getColorGradients(): Nullable<Array<ColorGradient>>;
  17748. /**
  17749. * Gets the current list of size gradients.
  17750. * You must use addSizeGradient and removeSizeGradient to update this list
  17751. * @returns the list of size gradients
  17752. */
  17753. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17754. /**
  17755. * Gets the current list of angular speed gradients.
  17756. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to update this list
  17757. * @returns the list of angular speed gradients
  17758. */
  17759. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17760. /**
  17761. * Adds a new angular speed gradient
  17762. * @param gradient defines the gradient to use (between 0 and 1)
  17763. * @param factor defines the angular speed to affect to the specified gradient
  17764. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17765. * @returns the current particle system
  17766. */
  17767. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17768. /**
  17769. * Remove a specific angular speed gradient
  17770. * @param gradient defines the gradient to remove
  17771. * @returns the current particle system
  17772. */
  17773. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17774. /**
  17775. * Gets the current list of velocity gradients.
  17776. * You must use addVelocityGradient and removeVelocityGradient to update this list
  17777. * @returns the list of velocity gradients
  17778. */
  17779. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17780. /**
  17781. * Adds a new velocity gradient
  17782. * @param gradient defines the gradient to use (between 0 and 1)
  17783. * @param factor defines the velocity to affect to the specified gradient
  17784. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17785. * @returns the current particle system
  17786. */
  17787. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17788. /**
  17789. * Remove a specific velocity gradient
  17790. * @param gradient defines the gradient to remove
  17791. * @returns the current particle system
  17792. */
  17793. removeVelocityGradient(gradient: number): IParticleSystem;
  17794. /**
  17795. * Gets the current list of limit velocity gradients.
  17796. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to update this list
  17797. * @returns the list of limit velocity gradients
  17798. */
  17799. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17800. /**
  17801. * Adds a new limit velocity gradient
  17802. * @param gradient defines the gradient to use (between 0 and 1)
  17803. * @param factor defines the limit velocity to affect to the specified gradient
  17804. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17805. * @returns the current particle system
  17806. */
  17807. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17808. /**
  17809. * Remove a specific limit velocity gradient
  17810. * @param gradient defines the gradient to remove
  17811. * @returns the current particle system
  17812. */
  17813. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17814. /**
  17815. * Adds a new drag gradient
  17816. * @param gradient defines the gradient to use (between 0 and 1)
  17817. * @param factor defines the drag to affect to the specified gradient
  17818. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17819. * @returns the current particle system
  17820. */
  17821. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17822. /**
  17823. * Remove a specific drag gradient
  17824. * @param gradient defines the gradient to remove
  17825. * @returns the current particle system
  17826. */
  17827. removeDragGradient(gradient: number): IParticleSystem;
  17828. /**
  17829. * Gets the current list of drag gradients.
  17830. * You must use addDragGradient and removeDragGradient to update this list
  17831. * @returns the list of drag gradients
  17832. */
  17833. getDragGradients(): Nullable<Array<FactorGradient>>;
  17834. /**
  17835. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17836. * @param gradient defines the gradient to use (between 0 and 1)
  17837. * @param factor defines the emit rate to affect to the specified gradient
  17838. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17839. * @returns the current particle system
  17840. */
  17841. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17842. /**
  17843. * Remove a specific emit rate gradient
  17844. * @param gradient defines the gradient to remove
  17845. * @returns the current particle system
  17846. */
  17847. removeEmitRateGradient(gradient: number): IParticleSystem;
  17848. /**
  17849. * Gets the current list of emit rate gradients.
  17850. * You must use addEmitRateGradient and removeEmitRateGradient to update this list
  17851. * @returns the list of emit rate gradients
  17852. */
  17853. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17854. /**
  17855. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17856. * @param gradient defines the gradient to use (between 0 and 1)
  17857. * @param factor defines the start size to affect to the specified gradient
  17858. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17859. * @returns the current particle system
  17860. */
  17861. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17862. /**
  17863. * Remove a specific start size gradient
  17864. * @param gradient defines the gradient to remove
  17865. * @returns the current particle system
  17866. */
  17867. removeStartSizeGradient(gradient: number): IParticleSystem;
  17868. /**
  17869. * Gets the current list of start size gradients.
  17870. * You must use addStartSizeGradient and removeStartSizeGradient to update this list
  17871. * @returns the list of start size gradients
  17872. */
  17873. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17874. /**
  17875. * Adds a new life time gradient
  17876. * @param gradient defines the gradient to use (between 0 and 1)
  17877. * @param factor defines the life time factor to affect to the specified gradient
  17878. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17879. * @returns the current particle system
  17880. */
  17881. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17882. /**
  17883. * Remove a specific life time gradient
  17884. * @param gradient defines the gradient to remove
  17885. * @returns the current particle system
  17886. */
  17887. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17888. /**
  17889. * Gets the current list of life time gradients.
  17890. * You must use addLifeTimeGradient and removeLifeTimeGradient to update this list
  17891. * @returns the list of life time gradients
  17892. */
  17893. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17894. /**
  17895. * Gets the current list of color gradients.
  17896. * You must use addColorGradient and removeColorGradient to update this list
  17897. * @returns the list of color gradients
  17898. */
  17899. getColorGradients(): Nullable<Array<ColorGradient>>;
  17900. /**
  17901. * Adds a new ramp gradient used to remap particle colors
  17902. * @param gradient defines the gradient to use (between 0 and 1)
  17903. * @param color defines the color to affect to the specified gradient
  17904. * @returns the current particle system
  17905. */
  17906. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  17907. /**
  17908. * Gets the current list of ramp gradients.
  17909. * You must use addRampGradient and removeRampGradient to update this list
  17910. * @returns the list of ramp gradients
  17911. */
  17912. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17913. /** Gets or sets a boolean indicating that ramp gradients must be used
  17914. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17915. */
  17916. useRampGradients: boolean;
  17917. /**
  17918. * Adds a new color remap gradient
  17919. * @param gradient defines the gradient to use (between 0 and 1)
  17920. * @param min defines the color remap minimal range
  17921. * @param max defines the color remap maximal range
  17922. * @returns the current particle system
  17923. */
  17924. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17925. /**
  17926. * Gets the current list of color remap gradients.
  17927. * You must use addColorRemapGradient and removeColorRemapGradient to update this list
  17928. * @returns the list of color remap gradients
  17929. */
  17930. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17931. /**
  17932. * Adds a new alpha remap gradient
  17933. * @param gradient defines the gradient to use (between 0 and 1)
  17934. * @param min defines the alpha remap minimal range
  17935. * @param max defines the alpha remap maximal range
  17936. * @returns the current particle system
  17937. */
  17938. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17939. /**
  17940. * Gets the current list of alpha remap gradients.
  17941. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to update this list
  17942. * @returns the list of alpha remap gradients
  17943. */
  17944. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17945. /**
  17946. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17947. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17948. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17949. * @returns the emitter
  17950. */
  17951. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17952. /**
  17953. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17954. * @param radius The radius of the hemisphere to emit from
  17955. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17956. * @returns the emitter
  17957. */
  17958. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  17959. /**
  17960. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17961. * @param radius The radius of the sphere to emit from
  17962. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17963. * @returns the emitter
  17964. */
  17965. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  17966. /**
  17967. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17968. * @param radius The radius of the sphere to emit from
  17969. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17970. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17971. * @returns the emitter
  17972. */
  17973. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17974. /**
  17975. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17976. * @param radius The radius of the emission cylinder
  17977. * @param height The height of the emission cylinder
  17978. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17979. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17980. * @returns the emitter
  17981. */
  17982. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  17983. /**
  17984. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17985. * @param radius The radius of the cylinder to emit from
  17986. * @param height The height of the emission cylinder
  17987. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17988. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17989. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17990. * @returns the emitter
  17991. */
  17992. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17993. /**
  17994. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17995. * @param radius The radius of the cone to emit from
  17996. * @param angle The base angle of the cone
  17997. * @returns the emitter
  17998. */
  17999. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  18000. /**
  18001. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  18002. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18003. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18004. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18005. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18006. * @returns the emitter
  18007. */
  18008. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  18009. /**
  18010. * Get hosting scene
  18011. * @returns the scene
  18012. */
  18013. getScene(): Nullable<Scene>;
  18014. }
  18015. }
  18016. declare module BABYLON {
  18017. /**
  18018. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  18019. */
  18020. export class ColorSplitterBlock extends NodeMaterialBlock {
  18021. /**
  18022. * Create a new ColorSplitterBlock
  18023. * @param name defines the block name
  18024. */
  18025. constructor(name: string);
  18026. /**
  18027. * Gets the current class name
  18028. * @returns the class name
  18029. */
  18030. getClassName(): string;
  18031. /**
  18032. * Gets the rgba component (input)
  18033. */
  18034. get rgba(): NodeMaterialConnectionPoint;
  18035. /**
  18036. * Gets the rgb component (input)
  18037. */
  18038. get rgbIn(): NodeMaterialConnectionPoint;
  18039. /**
  18040. * Gets the rgb component (output)
  18041. */
  18042. get rgbOut(): NodeMaterialConnectionPoint;
  18043. /**
  18044. * Gets the r component (output)
  18045. */
  18046. get r(): NodeMaterialConnectionPoint;
  18047. /**
  18048. * Gets the g component (output)
  18049. */
  18050. get g(): NodeMaterialConnectionPoint;
  18051. /**
  18052. * Gets the b component (output)
  18053. */
  18054. get b(): NodeMaterialConnectionPoint;
  18055. /**
  18056. * Gets the a component (output)
  18057. */
  18058. get a(): NodeMaterialConnectionPoint;
  18059. protected _inputRename(name: string): string;
  18060. protected _outputRename(name: string): string;
  18061. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  18062. }
  18063. }
  18064. declare module BABYLON {
  18065. /**
  18066. * Operations supported by the Trigonometry block
  18067. */
  18068. export enum TrigonometryBlockOperations {
  18069. /** Cos */
  18070. Cos = 0,
  18071. /** Sin */
  18072. Sin = 1,
  18073. /** Abs */
  18074. Abs = 2,
  18075. /** Exp */
  18076. Exp = 3,
  18077. /** Exp2 */
  18078. Exp2 = 4,
  18079. /** Round */
  18080. Round = 5,
  18081. /** Floor */
  18082. Floor = 6,
  18083. /** Ceiling */
  18084. Ceiling = 7,
  18085. /** Square root */
  18086. Sqrt = 8,
  18087. /** Log */
  18088. Log = 9,
  18089. /** Tangent */
  18090. Tan = 10,
  18091. /** Arc tangent */
  18092. ArcTan = 11,
  18093. /** Arc cosinus */
  18094. ArcCos = 12,
  18095. /** Arc sinus */
  18096. ArcSin = 13,
  18097. /** Fraction */
  18098. Fract = 14,
  18099. /** Sign */
  18100. Sign = 15,
  18101. /** To radians (from degrees) */
  18102. Radians = 16,
  18103. /** To degrees (from radians) */
  18104. Degrees = 17
  18105. }
  18106. /**
  18107. * Block used to apply trigonometry operation to floats
  18108. */
  18109. export class TrigonometryBlock extends NodeMaterialBlock {
  18110. /**
  18111. * Gets or sets the operation applied by the block
  18112. */
  18113. operation: TrigonometryBlockOperations;
  18114. /**
  18115. * Creates a new TrigonometryBlock
  18116. * @param name defines the block name
  18117. */
  18118. constructor(name: string);
  18119. /**
  18120. * Gets the current class name
  18121. * @returns the class name
  18122. */
  18123. getClassName(): string;
  18124. /**
  18125. * Gets the input component
  18126. */
  18127. get input(): NodeMaterialConnectionPoint;
  18128. /**
  18129. * Gets the output component
  18130. */
  18131. get output(): NodeMaterialConnectionPoint;
  18132. protected _buildBlock(state: NodeMaterialBuildState): this;
  18133. serialize(): any;
  18134. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  18135. protected _dumpPropertiesCode(): string;
  18136. }
  18137. }
  18138. declare module BABYLON {
  18139. /**
  18140. * Interface used to configure the node material editor
  18141. */
  18142. export interface INodeMaterialEditorOptions {
  18143. /** Define the URl to load node editor script */
  18144. editorURL?: string;
  18145. }
  18146. /** @hidden */
  18147. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  18148. NORMAL: boolean;
  18149. TANGENT: boolean;
  18150. UV1: boolean;
  18151. /** BONES */
  18152. NUM_BONE_INFLUENCERS: number;
  18153. BonesPerMesh: number;
  18154. BONETEXTURE: boolean;
  18155. /** MORPH TARGETS */
  18156. MORPHTARGETS: boolean;
  18157. MORPHTARGETS_NORMAL: boolean;
  18158. MORPHTARGETS_TANGENT: boolean;
  18159. MORPHTARGETS_UV: boolean;
  18160. NUM_MORPH_INFLUENCERS: number;
  18161. MORPHTARGETS_TEXTURE: boolean;
  18162. /** IMAGE PROCESSING */
  18163. IMAGEPROCESSING: boolean;
  18164. VIGNETTE: boolean;
  18165. VIGNETTEBLENDMODEMULTIPLY: boolean;
  18166. VIGNETTEBLENDMODEOPAQUE: boolean;
  18167. TONEMAPPING: boolean;
  18168. TONEMAPPING_ACES: boolean;
  18169. CONTRAST: boolean;
  18170. EXPOSURE: boolean;
  18171. COLORCURVES: boolean;
  18172. COLORGRADING: boolean;
  18173. COLORGRADING3D: boolean;
  18174. SAMPLER3DGREENDEPTH: boolean;
  18175. SAMPLER3DBGRMAP: boolean;
  18176. IMAGEPROCESSINGPOSTPROCESS: boolean;
  18177. /** MISC. */
  18178. BUMPDIRECTUV: number;
  18179. constructor();
  18180. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  18181. }
  18182. /**
  18183. * Class used to configure NodeMaterial
  18184. */
  18185. export interface INodeMaterialOptions {
  18186. /**
  18187. * Defines if blocks should emit comments
  18188. */
  18189. emitComments: boolean;
  18190. }
  18191. /**
  18192. * Class used to create a node based material built by assembling shader blocks
  18193. */
  18194. export class NodeMaterial extends PushMaterial {
  18195. private static _BuildIdGenerator;
  18196. private _options;
  18197. private _vertexCompilationState;
  18198. private _fragmentCompilationState;
  18199. private _sharedData;
  18200. private _buildId;
  18201. private _buildWasSuccessful;
  18202. private _cachedWorldViewMatrix;
  18203. private _cachedWorldViewProjectionMatrix;
  18204. private _optimizers;
  18205. private _animationFrame;
  18206. /** Define the Url to load node editor script */
  18207. static EditorURL: string;
  18208. /** Define the Url to load snippets */
  18209. static SnippetUrl: string;
  18210. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  18211. static IgnoreTexturesAtLoadTime: boolean;
  18212. private BJSNODEMATERIALEDITOR;
  18213. /** Get the inspector from bundle or global */
  18214. private _getGlobalNodeMaterialEditor;
  18215. /**
  18216. * Snippet ID if the material was created from the snippet server
  18217. */
  18218. snippetId: string;
  18219. /**
  18220. * Gets or sets data used by visual editor
  18221. * @see https://nme.babylonjs.com
  18222. */
  18223. editorData: any;
  18224. /**
  18225. * 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)
  18226. */
  18227. ignoreAlpha: boolean;
  18228. /**
  18229. * Defines the maximum number of lights that can be used in the material
  18230. */
  18231. maxSimultaneousLights: number;
  18232. /**
  18233. * Observable raised when the material is built
  18234. */
  18235. onBuildObservable: Observable<NodeMaterial>;
  18236. /**
  18237. * Gets or sets the root nodes of the material vertex shader
  18238. */
  18239. _vertexOutputNodes: NodeMaterialBlock[];
  18240. /**
  18241. * Gets or sets the root nodes of the material fragment (pixel) shader
  18242. */
  18243. _fragmentOutputNodes: NodeMaterialBlock[];
  18244. /** Gets or sets options to control the node material overall behavior */
  18245. get options(): INodeMaterialOptions;
  18246. set options(options: INodeMaterialOptions);
  18247. /**
  18248. * Default configuration related to image processing available in the standard Material.
  18249. */
  18250. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  18251. /**
  18252. * Gets the image processing configuration used either in this material.
  18253. */
  18254. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  18255. /**
  18256. * Sets the Default image processing configuration used either in the this material.
  18257. *
  18258. * If sets to null, the scene one is in use.
  18259. */
  18260. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  18261. /**
  18262. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  18263. */
  18264. attachedBlocks: NodeMaterialBlock[];
  18265. /**
  18266. * Specifies the mode of the node material
  18267. * @hidden
  18268. */
  18269. _mode: NodeMaterialModes;
  18270. /**
  18271. * Gets the mode property
  18272. */
  18273. get mode(): NodeMaterialModes;
  18274. /**
  18275. * A free comment about the material
  18276. */
  18277. comment: string;
  18278. /**
  18279. * Create a new node based material
  18280. * @param name defines the material name
  18281. * @param scene defines the hosting scene
  18282. * @param options defines creation option
  18283. */
  18284. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  18285. /**
  18286. * Gets the current class name of the material e.g. "NodeMaterial"
  18287. * @returns the class name
  18288. */
  18289. getClassName(): string;
  18290. /**
  18291. * Keep track of the image processing observer to allow dispose and replace.
  18292. */
  18293. private _imageProcessingObserver;
  18294. /**
  18295. * Attaches a new image processing configuration to the Standard Material.
  18296. * @param configuration
  18297. */
  18298. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  18299. /**
  18300. * Get a block by its name
  18301. * @param name defines the name of the block to retrieve
  18302. * @returns the required block or null if not found
  18303. */
  18304. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  18305. /**
  18306. * Get a block by its name
  18307. * @param predicate defines the predicate used to find the good candidate
  18308. * @returns the required block or null if not found
  18309. */
  18310. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  18311. /**
  18312. * Get an input block by its name
  18313. * @param predicate defines the predicate used to find the good candidate
  18314. * @returns the required input block or null if not found
  18315. */
  18316. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  18317. /**
  18318. * Gets the list of input blocks attached to this material
  18319. * @returns an array of InputBlocks
  18320. */
  18321. getInputBlocks(): InputBlock[];
  18322. /**
  18323. * Adds a new optimizer to the list of optimizers
  18324. * @param optimizer defines the optimizers to add
  18325. * @returns the current material
  18326. */
  18327. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  18328. /**
  18329. * Remove an optimizer from the list of optimizers
  18330. * @param optimizer defines the optimizers to remove
  18331. * @returns the current material
  18332. */
  18333. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  18334. /**
  18335. * Add a new block to the list of output nodes
  18336. * @param node defines the node to add
  18337. * @returns the current material
  18338. */
  18339. addOutputNode(node: NodeMaterialBlock): this;
  18340. /**
  18341. * Remove a block from the list of root nodes
  18342. * @param node defines the node to remove
  18343. * @returns the current material
  18344. */
  18345. removeOutputNode(node: NodeMaterialBlock): this;
  18346. private _addVertexOutputNode;
  18347. private _removeVertexOutputNode;
  18348. private _addFragmentOutputNode;
  18349. private _removeFragmentOutputNode;
  18350. /**
  18351. * Specifies if the material will require alpha blending
  18352. * @returns a boolean specifying if alpha blending is needed
  18353. */
  18354. needAlphaBlending(): boolean;
  18355. /**
  18356. * Specifies if this material should be rendered in alpha test mode
  18357. * @returns a boolean specifying if an alpha test is needed.
  18358. */
  18359. needAlphaTesting(): boolean;
  18360. private _initializeBlock;
  18361. private _resetDualBlocks;
  18362. /**
  18363. * Remove a block from the current node material
  18364. * @param block defines the block to remove
  18365. */
  18366. removeBlock(block: NodeMaterialBlock): void;
  18367. /**
  18368. * Build the material and generates the inner effect
  18369. * @param verbose defines if the build should log activity
  18370. */
  18371. build(verbose?: boolean): void;
  18372. /**
  18373. * Runs an otpimization phase to try to improve the shader code
  18374. */
  18375. optimize(): void;
  18376. private _prepareDefinesForAttributes;
  18377. /**
  18378. * Create a post process from the material
  18379. * @param camera The camera to apply the render pass to.
  18380. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  18381. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  18382. * @param engine The engine which the post process will be applied. (default: current engine)
  18383. * @param reusable If the post process can be reused on the same frame. (default: false)
  18384. * @param textureType Type of textures used when performing the post process. (default: 0)
  18385. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  18386. * @returns the post process created
  18387. */
  18388. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  18389. /**
  18390. * Create the post process effect from the material
  18391. * @param postProcess The post process to create the effect for
  18392. */
  18393. createEffectForPostProcess(postProcess: PostProcess): void;
  18394. private _createEffectForPostProcess;
  18395. /**
  18396. * Create a new procedural texture based on this node material
  18397. * @param size defines the size of the texture
  18398. * @param scene defines the hosting scene
  18399. * @returns the new procedural texture attached to this node material
  18400. */
  18401. createProceduralTexture(size: number | {
  18402. width: number;
  18403. height: number;
  18404. layers?: number;
  18405. }, scene: Scene): Nullable<ProceduralTexture>;
  18406. private _createEffectForParticles;
  18407. private _checkInternals;
  18408. /**
  18409. * Create the effect to be used as the custom effect for a particle system
  18410. * @param particleSystem Particle system to create the effect for
  18411. * @param onCompiled defines a function to call when the effect creation is successful
  18412. * @param onError defines a function to call when the effect creation has failed
  18413. */
  18414. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18415. private _processDefines;
  18416. /**
  18417. * Get if the submesh is ready to be used and all its information available.
  18418. * Child classes can use it to update shaders
  18419. * @param mesh defines the mesh to check
  18420. * @param subMesh defines which submesh to check
  18421. * @param useInstances specifies that instances should be used
  18422. * @returns a boolean indicating that the submesh is ready or not
  18423. */
  18424. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  18425. /**
  18426. * Get a string representing the shaders built by the current node graph
  18427. */
  18428. get compiledShaders(): string;
  18429. /**
  18430. * Binds the world matrix to the material
  18431. * @param world defines the world transformation matrix
  18432. */
  18433. bindOnlyWorldMatrix(world: Matrix): void;
  18434. /**
  18435. * Binds the submesh to this material by preparing the effect and shader to draw
  18436. * @param world defines the world transformation matrix
  18437. * @param mesh defines the mesh containing the submesh
  18438. * @param subMesh defines the submesh to bind the material to
  18439. */
  18440. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  18441. /**
  18442. * Gets the active textures from the material
  18443. * @returns an array of textures
  18444. */
  18445. getActiveTextures(): BaseTexture[];
  18446. /**
  18447. * Gets the list of texture blocks
  18448. * @returns an array of texture blocks
  18449. */
  18450. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  18451. /**
  18452. * Specifies if the material uses a texture
  18453. * @param texture defines the texture to check against the material
  18454. * @returns a boolean specifying if the material uses the texture
  18455. */
  18456. hasTexture(texture: BaseTexture): boolean;
  18457. /**
  18458. * Disposes the material
  18459. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18460. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18461. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  18462. */
  18463. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  18464. /** Creates the node editor window. */
  18465. private _createNodeEditor;
  18466. /**
  18467. * Launch the node material editor
  18468. * @param config Define the configuration of the editor
  18469. * @return a promise fulfilled when the node editor is visible
  18470. */
  18471. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  18472. /**
  18473. * Clear the current material
  18474. */
  18475. clear(): void;
  18476. /**
  18477. * Clear the current material and set it to a default state
  18478. */
  18479. setToDefault(): void;
  18480. /**
  18481. * Clear the current material and set it to a default state for post process
  18482. */
  18483. setToDefaultPostProcess(): void;
  18484. /**
  18485. * Clear the current material and set it to a default state for procedural texture
  18486. */
  18487. setToDefaultProceduralTexture(): void;
  18488. /**
  18489. * Clear the current material and set it to a default state for particle
  18490. */
  18491. setToDefaultParticle(): void;
  18492. /**
  18493. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  18494. * @param url defines the url to load from
  18495. * @returns a promise that will fulfil when the material is fully loaded
  18496. */
  18497. loadAsync(url: string): Promise<void>;
  18498. private _gatherBlocks;
  18499. /**
  18500. * Generate a string containing the code declaration required to create an equivalent of this material
  18501. * @returns a string
  18502. */
  18503. generateCode(): string;
  18504. /**
  18505. * Serializes this material in a JSON representation
  18506. * @returns the serialized material object
  18507. */
  18508. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  18509. private _restoreConnections;
  18510. /**
  18511. * Clear the current graph and load a new one from a serialization object
  18512. * @param source defines the JSON representation of the material
  18513. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18514. * @param merge defines whether or not the source must be merged or replace the current content
  18515. */
  18516. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  18517. /**
  18518. * Makes a duplicate of the current material.
  18519. * @param name - name to use for the new material.
  18520. */
  18521. clone(name: string): NodeMaterial;
  18522. /**
  18523. * Creates a node material from parsed material data
  18524. * @param source defines the JSON representation of the material
  18525. * @param scene defines the hosting scene
  18526. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18527. * @returns a new node material
  18528. */
  18529. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  18530. /**
  18531. * Creates a node material from a snippet saved in a remote file
  18532. * @param name defines the name of the material to create
  18533. * @param url defines the url to load from
  18534. * @param scene defines the hosting scene
  18535. * @returns a promise that will resolve to the new node material
  18536. */
  18537. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  18538. /**
  18539. * Creates a node material from a snippet saved by the node material editor
  18540. * @param snippetId defines the snippet to load
  18541. * @param scene defines the hosting scene
  18542. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18543. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  18544. * @returns a promise that will resolve to the new node material
  18545. */
  18546. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  18547. /**
  18548. * Creates a new node material set to default basic configuration
  18549. * @param name defines the name of the material
  18550. * @param scene defines the hosting scene
  18551. * @returns a new NodeMaterial
  18552. */
  18553. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  18554. }
  18555. }
  18556. declare module BABYLON {
  18557. interface ThinEngine {
  18558. /**
  18559. * Unbind a list of render target textures from the webGL context
  18560. * This is used only when drawBuffer extension or webGL2 are active
  18561. * @param textures defines the render target textures to unbind
  18562. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  18563. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  18564. */
  18565. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  18566. /**
  18567. * Create a multi render target texture
  18568. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  18569. * @param size defines the size of the texture
  18570. * @param options defines the creation options
  18571. * @param initializeBuffers if set to true, the engine will make an initializing call of drawBuffers
  18572. * @returns the cube texture as an InternalTexture
  18573. */
  18574. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions, initializeBuffers?: boolean): InternalTexture[];
  18575. /**
  18576. * Update the sample count for a given multiple render target texture
  18577. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  18578. * @param textures defines the textures to update
  18579. * @param samples defines the sample count to set
  18580. * @param initializeBuffers if set to true, the engine will make an initializing call of drawBuffers
  18581. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  18582. */
  18583. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number, initializeBuffers?: boolean): number;
  18584. /**
  18585. * Select a subsets of attachments to draw to.
  18586. * @param attachments gl attachments
  18587. */
  18588. bindAttachments(attachments: number[]): void;
  18589. /**
  18590. * Creates a layout object to draw/clear on specific textures in a MRT
  18591. * @param textureStatus textureStatus[i] indicates if the i-th is active
  18592. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  18593. */
  18594. buildTextureLayout(textureStatus: boolean[]): number[];
  18595. /**
  18596. * Restores the webgl state to only draw on the main color attachment
  18597. * when the frame buffer associated is the canvas frame buffer
  18598. */
  18599. restoreSingleAttachment(): void;
  18600. /**
  18601. * Restores the webgl state to only draw on the main color attachment
  18602. * when the frame buffer associated is not the canvas frame buffer
  18603. */
  18604. restoreSingleAttachmentForRenderTarget(): void;
  18605. /**
  18606. * Clears a list of attachments
  18607. * @param attachments list of the attachments
  18608. * @param colorMain clear color for the main attachment (the first one)
  18609. * @param colorOthers clear color for the other attachments
  18610. * @param clearDepth true to clear the depth buffer. Used only for the first attachment
  18611. * @param clearStencil true to clear the stencil buffer. Used only for the first attachment
  18612. */
  18613. clearAttachments(attachments: number[], colorMain: Nullable<IColor4Like>, colorOthers: Nullable<IColor4Like>, clearDepth: boolean, clearStencil: boolean): void;
  18614. }
  18615. }
  18616. declare module BABYLON {
  18617. /**
  18618. * Creation options of the multi render target texture.
  18619. */
  18620. export interface IMultiRenderTargetOptions {
  18621. /**
  18622. * Define if the texture needs to create mip maps after render.
  18623. */
  18624. generateMipMaps?: boolean;
  18625. /**
  18626. * Define the types of all the draw buffers we want to create
  18627. */
  18628. types?: number[];
  18629. /**
  18630. * Define the sampling modes of all the draw buffers we want to create
  18631. */
  18632. samplingModes?: number[];
  18633. /**
  18634. * Define if a depth buffer is required
  18635. */
  18636. generateDepthBuffer?: boolean;
  18637. /**
  18638. * Define if a stencil buffer is required
  18639. */
  18640. generateStencilBuffer?: boolean;
  18641. /**
  18642. * Define if a depth texture is required instead of a depth buffer
  18643. */
  18644. generateDepthTexture?: boolean;
  18645. /**
  18646. * Define the number of desired draw buffers
  18647. */
  18648. textureCount?: number;
  18649. /**
  18650. * Define if aspect ratio should be adapted to the texture or stay the scene one
  18651. */
  18652. doNotChangeAspectRatio?: boolean;
  18653. /**
  18654. * Define the default type of the buffers we are creating
  18655. */
  18656. defaultType?: number;
  18657. /**
  18658. * Define the default type of the buffers we are creating
  18659. */
  18660. drawOnlyOnFirstAttachmentByDefault?: boolean;
  18661. }
  18662. /**
  18663. * A multi render target, like a render target provides the ability to render to a texture.
  18664. * Unlike the render target, it can render to several draw buffers in one draw.
  18665. * This is specially interesting in deferred rendering or for any effects requiring more than
  18666. * just one color from a single pass.
  18667. */
  18668. export class MultiRenderTarget extends RenderTargetTexture {
  18669. private _internalTextures;
  18670. private _textures;
  18671. private _multiRenderTargetOptions;
  18672. private _count;
  18673. private _drawOnlyOnFirstAttachmentByDefault;
  18674. /**
  18675. * Get if draw buffers are currently supported by the used hardware and browser.
  18676. */
  18677. get isSupported(): boolean;
  18678. /**
  18679. * Get the list of textures generated by the multi render target.
  18680. */
  18681. get textures(): Texture[];
  18682. /**
  18683. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  18684. */
  18685. get count(): number;
  18686. /**
  18687. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  18688. */
  18689. get depthTexture(): Texture;
  18690. /**
  18691. * Set the wrapping mode on U of all the textures we are rendering to.
  18692. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  18693. */
  18694. set wrapU(wrap: number);
  18695. /**
  18696. * Set the wrapping mode on V of all the textures we are rendering to.
  18697. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  18698. */
  18699. set wrapV(wrap: number);
  18700. /**
  18701. * Instantiate a new multi render target texture.
  18702. * A multi render target, like a render target provides the ability to render to a texture.
  18703. * Unlike the render target, it can render to several draw buffers in one draw.
  18704. * This is specially interesting in deferred rendering or for any effects requiring more than
  18705. * just one color from a single pass.
  18706. * @param name Define the name of the texture
  18707. * @param size Define the size of the buffers to render to
  18708. * @param count Define the number of target we are rendering into
  18709. * @param scene Define the scene the texture belongs to
  18710. * @param options Define the options used to create the multi render target
  18711. */
  18712. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  18713. private _initTypes;
  18714. /** @hidden */
  18715. _rebuild(forceFullRebuild?: boolean): void;
  18716. private _createInternalTextures;
  18717. private _createTextures;
  18718. /**
  18719. * Replaces a texture within the MRT.
  18720. * @param texture The new texture to insert in the MRT
  18721. * @param index The index of the texture to replace
  18722. */
  18723. replaceTexture(texture: Texture, index: number): void;
  18724. /**
  18725. * Define the number of samples used if MSAA is enabled.
  18726. */
  18727. get samples(): number;
  18728. set samples(value: number);
  18729. /**
  18730. * Resize all the textures in the multi render target.
  18731. * Be careful as it will recreate all the data in the new texture.
  18732. * @param size Define the new size
  18733. */
  18734. resize(size: any): void;
  18735. /**
  18736. * Changes the number of render targets in this MRT
  18737. * Be careful as it will recreate all the data in the new texture.
  18738. * @param count new texture count
  18739. * @param options Specifies texture types and sampling modes for new textures
  18740. */
  18741. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  18742. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  18743. /**
  18744. * Dispose the render targets and their associated resources
  18745. */
  18746. dispose(): void;
  18747. /**
  18748. * Release all the underlying texture used as draw buffers.
  18749. */
  18750. releaseInternalTextures(): void;
  18751. }
  18752. }
  18753. declare module BABYLON {
  18754. /** @hidden */
  18755. export var imageProcessingPixelShader: {
  18756. name: string;
  18757. shader: string;
  18758. };
  18759. }
  18760. declare module BABYLON {
  18761. /**
  18762. * ImageProcessingPostProcess
  18763. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  18764. */
  18765. export class ImageProcessingPostProcess extends PostProcess {
  18766. /**
  18767. * Default configuration related to image processing available in the PBR Material.
  18768. */
  18769. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  18770. /**
  18771. * Gets the image processing configuration used either in this material.
  18772. */
  18773. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  18774. /**
  18775. * Sets the Default image processing configuration used either in the this material.
  18776. *
  18777. * If sets to null, the scene one is in use.
  18778. */
  18779. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  18780. /**
  18781. * Keep track of the image processing observer to allow dispose and replace.
  18782. */
  18783. private _imageProcessingObserver;
  18784. /**
  18785. * Attaches a new image processing configuration to the PBR Material.
  18786. * @param configuration
  18787. */
  18788. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  18789. /**
  18790. * If the post process is supported.
  18791. */
  18792. get isSupported(): boolean;
  18793. /**
  18794. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  18795. */
  18796. get colorCurves(): Nullable<ColorCurves>;
  18797. /**
  18798. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  18799. */
  18800. set colorCurves(value: Nullable<ColorCurves>);
  18801. /**
  18802. * Gets whether the color curves effect is enabled.
  18803. */
  18804. get colorCurvesEnabled(): boolean;
  18805. /**
  18806. * Sets whether the color curves effect is enabled.
  18807. */
  18808. set colorCurvesEnabled(value: boolean);
  18809. /**
  18810. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  18811. */
  18812. get colorGradingTexture(): Nullable<BaseTexture>;
  18813. /**
  18814. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  18815. */
  18816. set colorGradingTexture(value: Nullable<BaseTexture>);
  18817. /**
  18818. * Gets whether the color grading effect is enabled.
  18819. */
  18820. get colorGradingEnabled(): boolean;
  18821. /**
  18822. * Gets whether the color grading effect is enabled.
  18823. */
  18824. set colorGradingEnabled(value: boolean);
  18825. /**
  18826. * Gets exposure used in the effect.
  18827. */
  18828. get exposure(): number;
  18829. /**
  18830. * Sets exposure used in the effect.
  18831. */
  18832. set exposure(value: number);
  18833. /**
  18834. * Gets whether tonemapping is enabled or not.
  18835. */
  18836. get toneMappingEnabled(): boolean;
  18837. /**
  18838. * Sets whether tonemapping is enabled or not
  18839. */
  18840. set toneMappingEnabled(value: boolean);
  18841. /**
  18842. * Gets the type of tone mapping effect.
  18843. */
  18844. get toneMappingType(): number;
  18845. /**
  18846. * Sets the type of tone mapping effect.
  18847. */
  18848. set toneMappingType(value: number);
  18849. /**
  18850. * Gets contrast used in the effect.
  18851. */
  18852. get contrast(): number;
  18853. /**
  18854. * Sets contrast used in the effect.
  18855. */
  18856. set contrast(value: number);
  18857. /**
  18858. * Gets Vignette stretch size.
  18859. */
  18860. get vignetteStretch(): number;
  18861. /**
  18862. * Sets Vignette stretch size.
  18863. */
  18864. set vignetteStretch(value: number);
  18865. /**
  18866. * Gets Vignette centre X Offset.
  18867. */
  18868. get vignetteCentreX(): number;
  18869. /**
  18870. * Sets Vignette centre X Offset.
  18871. */
  18872. set vignetteCentreX(value: number);
  18873. /**
  18874. * Gets Vignette centre Y Offset.
  18875. */
  18876. get vignetteCentreY(): number;
  18877. /**
  18878. * Sets Vignette centre Y Offset.
  18879. */
  18880. set vignetteCentreY(value: number);
  18881. /**
  18882. * Gets Vignette weight or intensity of the vignette effect.
  18883. */
  18884. get vignetteWeight(): number;
  18885. /**
  18886. * Sets Vignette weight or intensity of the vignette effect.
  18887. */
  18888. set vignetteWeight(value: number);
  18889. /**
  18890. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  18891. * if vignetteEnabled is set to true.
  18892. */
  18893. get vignetteColor(): Color4;
  18894. /**
  18895. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  18896. * if vignetteEnabled is set to true.
  18897. */
  18898. set vignetteColor(value: Color4);
  18899. /**
  18900. * Gets Camera field of view used by the Vignette effect.
  18901. */
  18902. get vignetteCameraFov(): number;
  18903. /**
  18904. * Sets Camera field of view used by the Vignette effect.
  18905. */
  18906. set vignetteCameraFov(value: number);
  18907. /**
  18908. * Gets the vignette blend mode allowing different kind of effect.
  18909. */
  18910. get vignetteBlendMode(): number;
  18911. /**
  18912. * Sets the vignette blend mode allowing different kind of effect.
  18913. */
  18914. set vignetteBlendMode(value: number);
  18915. /**
  18916. * Gets whether the vignette effect is enabled.
  18917. */
  18918. get vignetteEnabled(): boolean;
  18919. /**
  18920. * Sets whether the vignette effect is enabled.
  18921. */
  18922. set vignetteEnabled(value: boolean);
  18923. private _fromLinearSpace;
  18924. /**
  18925. * Gets whether the input of the processing is in Gamma or Linear Space.
  18926. */
  18927. get fromLinearSpace(): boolean;
  18928. /**
  18929. * Sets whether the input of the processing is in Gamma or Linear Space.
  18930. */
  18931. set fromLinearSpace(value: boolean);
  18932. /**
  18933. * Defines cache preventing GC.
  18934. */
  18935. private _defines;
  18936. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  18937. /**
  18938. * "ImageProcessingPostProcess"
  18939. * @returns "ImageProcessingPostProcess"
  18940. */
  18941. getClassName(): string;
  18942. /**
  18943. * @hidden
  18944. */
  18945. _updateParameters(): void;
  18946. dispose(camera?: Camera): void;
  18947. }
  18948. }
  18949. declare module BABYLON {
  18950. /**
  18951. * A multi render target designed to render the prepass.
  18952. * Prepass is a scene component used to render information in multiple textures
  18953. * alongside with the scene materials rendering.
  18954. * Note : This is an internal class, and you should NOT need to instanciate this.
  18955. * Only the `PrePassRenderer` should instanciate this class.
  18956. * It is more likely that you need a regular `MultiRenderTarget`
  18957. * @hidden
  18958. */
  18959. export class PrePassRenderTarget extends MultiRenderTarget {
  18960. /**
  18961. * @hidden
  18962. */
  18963. _beforeCompositionPostProcesses: PostProcess[];
  18964. /**
  18965. * Image processing post process for composition
  18966. */
  18967. imageProcessingPostProcess: ImageProcessingPostProcess;
  18968. /**
  18969. * @hidden
  18970. */
  18971. _engine: Engine;
  18972. /**
  18973. * @hidden
  18974. */
  18975. _scene: Scene;
  18976. /**
  18977. * @hidden
  18978. */
  18979. _outputPostProcess: Nullable<PostProcess>;
  18980. /**
  18981. * @hidden
  18982. */
  18983. _internalTextureDirty: boolean;
  18984. /**
  18985. * Is this render target enabled for prepass rendering
  18986. */
  18987. enabled: boolean;
  18988. /**
  18989. * Render target associated with this prePassRenderTarget
  18990. * If this is `null`, it means this prePassRenderTarget is associated with the scene
  18991. */
  18992. renderTargetTexture: Nullable<RenderTargetTexture>;
  18993. constructor(name: string, renderTargetTexture: Nullable<RenderTargetTexture>, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions | undefined);
  18994. /**
  18995. * Creates a composition effect for this RT
  18996. * @hidden
  18997. */
  18998. _createCompositionEffect(): void;
  18999. /**
  19000. * Checks that the size of this RT is still adapted to the desired render size.
  19001. * @hidden
  19002. */
  19003. _checkSize(): void;
  19004. /**
  19005. * Changes the number of render targets in this MRT
  19006. * Be careful as it will recreate all the data in the new texture.
  19007. * @param count new texture count
  19008. * @param options Specifies texture types and sampling modes for new textures
  19009. */
  19010. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  19011. /**
  19012. * Resets the post processes chains applied to this RT.
  19013. * @hidden
  19014. */
  19015. _resetPostProcessChain(): void;
  19016. /**
  19017. * Diposes this render target
  19018. */
  19019. dispose(): void;
  19020. }
  19021. }
  19022. declare module BABYLON {
  19023. /**
  19024. * Interface for defining prepass effects in the prepass post-process pipeline
  19025. */
  19026. export interface PrePassEffectConfiguration {
  19027. /**
  19028. * Name of the effect
  19029. */
  19030. name: string;
  19031. /**
  19032. * Post process to attach for this effect
  19033. */
  19034. postProcess?: PostProcess;
  19035. /**
  19036. * Textures required in the MRT
  19037. */
  19038. texturesRequired: number[];
  19039. /**
  19040. * Is the effect enabled
  19041. */
  19042. enabled: boolean;
  19043. /**
  19044. * Does the output of this prepass need to go through imageprocessing
  19045. */
  19046. needsImageProcessing?: boolean;
  19047. /**
  19048. * Disposes the effect configuration
  19049. */
  19050. dispose?: () => void;
  19051. /**
  19052. * Creates the associated post process
  19053. */
  19054. createPostProcess?: () => PostProcess;
  19055. }
  19056. }
  19057. declare module BABYLON {
  19058. /**
  19059. * Options to be used when creating a FresnelParameters.
  19060. */
  19061. export type IFresnelParametersCreationOptions = {
  19062. /**
  19063. * Define the color used on edges (grazing angle)
  19064. */
  19065. leftColor?: Color3;
  19066. /**
  19067. * Define the color used on center
  19068. */
  19069. rightColor?: Color3;
  19070. /**
  19071. * Define bias applied to computed fresnel term
  19072. */
  19073. bias?: number;
  19074. /**
  19075. * Defined the power exponent applied to fresnel term
  19076. */
  19077. power?: number;
  19078. /**
  19079. * Define if the fresnel effect is enable or not.
  19080. */
  19081. isEnabled?: boolean;
  19082. };
  19083. /**
  19084. * Serialized format for FresnelParameters.
  19085. */
  19086. export type IFresnelParametersSerialized = {
  19087. /**
  19088. * Define the color used on edges (grazing angle) [as an array]
  19089. */
  19090. leftColor: number[];
  19091. /**
  19092. * Define the color used on center [as an array]
  19093. */
  19094. rightColor: number[];
  19095. /**
  19096. * Define bias applied to computed fresnel term
  19097. */
  19098. bias: number;
  19099. /**
  19100. * Defined the power exponent applied to fresnel term
  19101. */
  19102. power?: number;
  19103. /**
  19104. * Define if the fresnel effect is enable or not.
  19105. */
  19106. isEnabled: boolean;
  19107. };
  19108. /**
  19109. * This represents all the required information to add a fresnel effect on a material:
  19110. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19111. */
  19112. export class FresnelParameters {
  19113. private _isEnabled;
  19114. /**
  19115. * Define if the fresnel effect is enable or not.
  19116. */
  19117. get isEnabled(): boolean;
  19118. set isEnabled(value: boolean);
  19119. /**
  19120. * Define the color used on edges (grazing angle)
  19121. */
  19122. leftColor: Color3;
  19123. /**
  19124. * Define the color used on center
  19125. */
  19126. rightColor: Color3;
  19127. /**
  19128. * Define bias applied to computed fresnel term
  19129. */
  19130. bias: number;
  19131. /**
  19132. * Defined the power exponent applied to fresnel term
  19133. */
  19134. power: number;
  19135. /**
  19136. * Creates a new FresnelParameters object.
  19137. *
  19138. * @param options provide your own settings to optionally to override defaults
  19139. */
  19140. constructor(options?: IFresnelParametersCreationOptions);
  19141. /**
  19142. * Clones the current fresnel and its values
  19143. * @returns a clone fresnel configuration
  19144. */
  19145. clone(): FresnelParameters;
  19146. /**
  19147. * Determines equality between FresnelParameters objects
  19148. * @param otherFresnelParameters defines the second operand
  19149. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  19150. */
  19151. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  19152. /**
  19153. * Serializes the current fresnel parameters to a JSON representation.
  19154. * @return the JSON serialization
  19155. */
  19156. serialize(): IFresnelParametersSerialized;
  19157. /**
  19158. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  19159. * @param parsedFresnelParameters Define the JSON representation
  19160. * @returns the parsed parameters
  19161. */
  19162. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  19163. }
  19164. }
  19165. declare module BABYLON {
  19166. /**
  19167. * This groups all the flags used to control the materials channel.
  19168. */
  19169. export class MaterialFlags {
  19170. private static _DiffuseTextureEnabled;
  19171. /**
  19172. * Are diffuse textures enabled in the application.
  19173. */
  19174. static get DiffuseTextureEnabled(): boolean;
  19175. static set DiffuseTextureEnabled(value: boolean);
  19176. private static _DetailTextureEnabled;
  19177. /**
  19178. * Are detail textures enabled in the application.
  19179. */
  19180. static get DetailTextureEnabled(): boolean;
  19181. static set DetailTextureEnabled(value: boolean);
  19182. private static _AmbientTextureEnabled;
  19183. /**
  19184. * Are ambient textures enabled in the application.
  19185. */
  19186. static get AmbientTextureEnabled(): boolean;
  19187. static set AmbientTextureEnabled(value: boolean);
  19188. private static _OpacityTextureEnabled;
  19189. /**
  19190. * Are opacity textures enabled in the application.
  19191. */
  19192. static get OpacityTextureEnabled(): boolean;
  19193. static set OpacityTextureEnabled(value: boolean);
  19194. private static _ReflectionTextureEnabled;
  19195. /**
  19196. * Are reflection textures enabled in the application.
  19197. */
  19198. static get ReflectionTextureEnabled(): boolean;
  19199. static set ReflectionTextureEnabled(value: boolean);
  19200. private static _EmissiveTextureEnabled;
  19201. /**
  19202. * Are emissive textures enabled in the application.
  19203. */
  19204. static get EmissiveTextureEnabled(): boolean;
  19205. static set EmissiveTextureEnabled(value: boolean);
  19206. private static _SpecularTextureEnabled;
  19207. /**
  19208. * Are specular textures enabled in the application.
  19209. */
  19210. static get SpecularTextureEnabled(): boolean;
  19211. static set SpecularTextureEnabled(value: boolean);
  19212. private static _BumpTextureEnabled;
  19213. /**
  19214. * Are bump textures enabled in the application.
  19215. */
  19216. static get BumpTextureEnabled(): boolean;
  19217. static set BumpTextureEnabled(value: boolean);
  19218. private static _LightmapTextureEnabled;
  19219. /**
  19220. * Are lightmap textures enabled in the application.
  19221. */
  19222. static get LightmapTextureEnabled(): boolean;
  19223. static set LightmapTextureEnabled(value: boolean);
  19224. private static _RefractionTextureEnabled;
  19225. /**
  19226. * Are refraction textures enabled in the application.
  19227. */
  19228. static get RefractionTextureEnabled(): boolean;
  19229. static set RefractionTextureEnabled(value: boolean);
  19230. private static _ColorGradingTextureEnabled;
  19231. /**
  19232. * Are color grading textures enabled in the application.
  19233. */
  19234. static get ColorGradingTextureEnabled(): boolean;
  19235. static set ColorGradingTextureEnabled(value: boolean);
  19236. private static _FresnelEnabled;
  19237. /**
  19238. * Are fresnels enabled in the application.
  19239. */
  19240. static get FresnelEnabled(): boolean;
  19241. static set FresnelEnabled(value: boolean);
  19242. private static _ClearCoatTextureEnabled;
  19243. /**
  19244. * Are clear coat textures enabled in the application.
  19245. */
  19246. static get ClearCoatTextureEnabled(): boolean;
  19247. static set ClearCoatTextureEnabled(value: boolean);
  19248. private static _ClearCoatBumpTextureEnabled;
  19249. /**
  19250. * Are clear coat bump textures enabled in the application.
  19251. */
  19252. static get ClearCoatBumpTextureEnabled(): boolean;
  19253. static set ClearCoatBumpTextureEnabled(value: boolean);
  19254. private static _ClearCoatTintTextureEnabled;
  19255. /**
  19256. * Are clear coat tint textures enabled in the application.
  19257. */
  19258. static get ClearCoatTintTextureEnabled(): boolean;
  19259. static set ClearCoatTintTextureEnabled(value: boolean);
  19260. private static _SheenTextureEnabled;
  19261. /**
  19262. * Are sheen textures enabled in the application.
  19263. */
  19264. static get SheenTextureEnabled(): boolean;
  19265. static set SheenTextureEnabled(value: boolean);
  19266. private static _AnisotropicTextureEnabled;
  19267. /**
  19268. * Are anisotropic textures enabled in the application.
  19269. */
  19270. static get AnisotropicTextureEnabled(): boolean;
  19271. static set AnisotropicTextureEnabled(value: boolean);
  19272. private static _ThicknessTextureEnabled;
  19273. /**
  19274. * Are thickness textures enabled in the application.
  19275. */
  19276. static get ThicknessTextureEnabled(): boolean;
  19277. static set ThicknessTextureEnabled(value: boolean);
  19278. }
  19279. }
  19280. declare module BABYLON {
  19281. /** @hidden */
  19282. export var defaultFragmentDeclaration: {
  19283. name: string;
  19284. shader: string;
  19285. };
  19286. }
  19287. declare module BABYLON {
  19288. /** @hidden */
  19289. export var sceneUboDeclaration: {
  19290. name: string;
  19291. shader: string;
  19292. };
  19293. }
  19294. declare module BABYLON {
  19295. /** @hidden */
  19296. export var meshUboDeclaration: {
  19297. name: string;
  19298. shader: string;
  19299. };
  19300. }
  19301. declare module BABYLON {
  19302. /** @hidden */
  19303. export var defaultUboDeclaration: {
  19304. name: string;
  19305. shader: string;
  19306. };
  19307. }
  19308. declare module BABYLON {
  19309. /** @hidden */
  19310. export var prePassDeclaration: {
  19311. name: string;
  19312. shader: string;
  19313. };
  19314. }
  19315. declare module BABYLON {
  19316. /** @hidden */
  19317. export var lightFragmentDeclaration: {
  19318. name: string;
  19319. shader: string;
  19320. };
  19321. }
  19322. declare module BABYLON {
  19323. /** @hidden */
  19324. export var lightUboDeclaration: {
  19325. name: string;
  19326. shader: string;
  19327. };
  19328. }
  19329. declare module BABYLON {
  19330. /** @hidden */
  19331. export var lightsFragmentFunctions: {
  19332. name: string;
  19333. shader: string;
  19334. };
  19335. }
  19336. declare module BABYLON {
  19337. /** @hidden */
  19338. export var shadowsFragmentFunctions: {
  19339. name: string;
  19340. shader: string;
  19341. };
  19342. }
  19343. declare module BABYLON {
  19344. /** @hidden */
  19345. export var fresnelFunction: {
  19346. name: string;
  19347. shader: string;
  19348. };
  19349. }
  19350. declare module BABYLON {
  19351. /** @hidden */
  19352. export var bumpFragmentMainFunctions: {
  19353. name: string;
  19354. shader: string;
  19355. };
  19356. }
  19357. declare module BABYLON {
  19358. /** @hidden */
  19359. export var bumpFragmentFunctions: {
  19360. name: string;
  19361. shader: string;
  19362. };
  19363. }
  19364. declare module BABYLON {
  19365. /** @hidden */
  19366. export var logDepthDeclaration: {
  19367. name: string;
  19368. shader: string;
  19369. };
  19370. }
  19371. declare module BABYLON {
  19372. /** @hidden */
  19373. export var fogFragmentDeclaration: {
  19374. name: string;
  19375. shader: string;
  19376. };
  19377. }
  19378. declare module BABYLON {
  19379. /** @hidden */
  19380. export var bumpFragment: {
  19381. name: string;
  19382. shader: string;
  19383. };
  19384. }
  19385. declare module BABYLON {
  19386. /** @hidden */
  19387. export var depthPrePass: {
  19388. name: string;
  19389. shader: string;
  19390. };
  19391. }
  19392. declare module BABYLON {
  19393. /** @hidden */
  19394. export var lightFragment: {
  19395. name: string;
  19396. shader: string;
  19397. };
  19398. }
  19399. declare module BABYLON {
  19400. /** @hidden */
  19401. export var logDepthFragment: {
  19402. name: string;
  19403. shader: string;
  19404. };
  19405. }
  19406. declare module BABYLON {
  19407. /** @hidden */
  19408. export var fogFragment: {
  19409. name: string;
  19410. shader: string;
  19411. };
  19412. }
  19413. declare module BABYLON {
  19414. /** @hidden */
  19415. export var defaultPixelShader: {
  19416. name: string;
  19417. shader: string;
  19418. };
  19419. }
  19420. declare module BABYLON {
  19421. /** @hidden */
  19422. export var defaultVertexDeclaration: {
  19423. name: string;
  19424. shader: string;
  19425. };
  19426. }
  19427. declare module BABYLON {
  19428. /** @hidden */
  19429. export var bonesDeclaration: {
  19430. name: string;
  19431. shader: string;
  19432. };
  19433. }
  19434. declare module BABYLON {
  19435. /** @hidden */
  19436. export var prePassVertexDeclaration: {
  19437. name: string;
  19438. shader: string;
  19439. };
  19440. }
  19441. declare module BABYLON {
  19442. /** @hidden */
  19443. export var bumpVertexDeclaration: {
  19444. name: string;
  19445. shader: string;
  19446. };
  19447. }
  19448. declare module BABYLON {
  19449. /** @hidden */
  19450. export var fogVertexDeclaration: {
  19451. name: string;
  19452. shader: string;
  19453. };
  19454. }
  19455. declare module BABYLON {
  19456. /** @hidden */
  19457. export var lightVxFragmentDeclaration: {
  19458. name: string;
  19459. shader: string;
  19460. };
  19461. }
  19462. declare module BABYLON {
  19463. /** @hidden */
  19464. export var lightVxUboDeclaration: {
  19465. name: string;
  19466. shader: string;
  19467. };
  19468. }
  19469. declare module BABYLON {
  19470. /** @hidden */
  19471. export var morphTargetsVertexGlobalDeclaration: {
  19472. name: string;
  19473. shader: string;
  19474. };
  19475. }
  19476. declare module BABYLON {
  19477. /** @hidden */
  19478. export var morphTargetsVertexDeclaration: {
  19479. name: string;
  19480. shader: string;
  19481. };
  19482. }
  19483. declare module BABYLON {
  19484. /** @hidden */
  19485. export var morphTargetsVertexGlobal: {
  19486. name: string;
  19487. shader: string;
  19488. };
  19489. }
  19490. declare module BABYLON {
  19491. /** @hidden */
  19492. export var morphTargetsVertex: {
  19493. name: string;
  19494. shader: string;
  19495. };
  19496. }
  19497. declare module BABYLON {
  19498. /** @hidden */
  19499. export var instancesVertex: {
  19500. name: string;
  19501. shader: string;
  19502. };
  19503. }
  19504. declare module BABYLON {
  19505. /** @hidden */
  19506. export var bonesVertex: {
  19507. name: string;
  19508. shader: string;
  19509. };
  19510. }
  19511. declare module BABYLON {
  19512. /** @hidden */
  19513. export var prePassVertex: {
  19514. name: string;
  19515. shader: string;
  19516. };
  19517. }
  19518. declare module BABYLON {
  19519. /** @hidden */
  19520. export var bumpVertex: {
  19521. name: string;
  19522. shader: string;
  19523. };
  19524. }
  19525. declare module BABYLON {
  19526. /** @hidden */
  19527. export var fogVertex: {
  19528. name: string;
  19529. shader: string;
  19530. };
  19531. }
  19532. declare module BABYLON {
  19533. /** @hidden */
  19534. export var shadowsVertex: {
  19535. name: string;
  19536. shader: string;
  19537. };
  19538. }
  19539. declare module BABYLON {
  19540. /** @hidden */
  19541. export var pointCloudVertex: {
  19542. name: string;
  19543. shader: string;
  19544. };
  19545. }
  19546. declare module BABYLON {
  19547. /** @hidden */
  19548. export var logDepthVertex: {
  19549. name: string;
  19550. shader: string;
  19551. };
  19552. }
  19553. declare module BABYLON {
  19554. /** @hidden */
  19555. export var defaultVertexShader: {
  19556. name: string;
  19557. shader: string;
  19558. };
  19559. }
  19560. declare module BABYLON {
  19561. /**
  19562. * @hidden
  19563. */
  19564. export interface IMaterialDetailMapDefines {
  19565. DETAIL: boolean;
  19566. DETAILDIRECTUV: number;
  19567. DETAIL_NORMALBLENDMETHOD: number;
  19568. /** @hidden */
  19569. _areTexturesDirty: boolean;
  19570. }
  19571. /**
  19572. * Define the code related to the detail map parameters of a material
  19573. *
  19574. * Inspired from:
  19575. * 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
  19576. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  19577. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  19578. */
  19579. export class DetailMapConfiguration {
  19580. private _texture;
  19581. /**
  19582. * The detail texture of the material.
  19583. */
  19584. texture: Nullable<BaseTexture>;
  19585. /**
  19586. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  19587. * Bigger values mean stronger blending
  19588. */
  19589. diffuseBlendLevel: number;
  19590. /**
  19591. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  19592. * Bigger values mean stronger blending. Only used with PBR materials
  19593. */
  19594. roughnessBlendLevel: number;
  19595. /**
  19596. * Defines how strong the bump effect from the detail map is
  19597. * Bigger values mean stronger effect
  19598. */
  19599. bumpLevel: number;
  19600. private _normalBlendMethod;
  19601. /**
  19602. * The method used to blend the bump and detail normals together
  19603. */
  19604. normalBlendMethod: number;
  19605. private _isEnabled;
  19606. /**
  19607. * Enable or disable the detail map on this material
  19608. */
  19609. isEnabled: boolean;
  19610. /** @hidden */
  19611. private _internalMarkAllSubMeshesAsTexturesDirty;
  19612. /** @hidden */
  19613. _markAllSubMeshesAsTexturesDirty(): void;
  19614. /**
  19615. * Instantiate a new detail map
  19616. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  19617. */
  19618. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  19619. /**
  19620. * Gets whether the submesh is ready to be used or not.
  19621. * @param defines the list of "defines" to update.
  19622. * @param scene defines the scene the material belongs to.
  19623. * @returns - boolean indicating that the submesh is ready or not.
  19624. */
  19625. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  19626. /**
  19627. * Update the defines for detail map usage
  19628. * @param defines the list of "defines" to update.
  19629. * @param scene defines the scene the material belongs to.
  19630. */
  19631. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  19632. /**
  19633. * Binds the material data.
  19634. * @param uniformBuffer defines the Uniform buffer to fill in.
  19635. * @param scene defines the scene the material belongs to.
  19636. * @param isFrozen defines whether the material is frozen or not.
  19637. */
  19638. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  19639. /**
  19640. * Checks to see if a texture is used in the material.
  19641. * @param texture - Base texture to use.
  19642. * @returns - Boolean specifying if a texture is used in the material.
  19643. */
  19644. hasTexture(texture: BaseTexture): boolean;
  19645. /**
  19646. * Returns an array of the actively used textures.
  19647. * @param activeTextures Array of BaseTextures
  19648. */
  19649. getActiveTextures(activeTextures: BaseTexture[]): void;
  19650. /**
  19651. * Returns the animatable textures.
  19652. * @param animatables Array of animatable textures.
  19653. */
  19654. getAnimatables(animatables: IAnimatable[]): void;
  19655. /**
  19656. * Disposes the resources of the material.
  19657. * @param forceDisposeTextures - Forces the disposal of all textures.
  19658. */
  19659. dispose(forceDisposeTextures?: boolean): void;
  19660. /**
  19661. * Get the current class name useful for serialization or dynamic coding.
  19662. * @returns "DetailMap"
  19663. */
  19664. getClassName(): string;
  19665. /**
  19666. * Add the required uniforms to the current list.
  19667. * @param uniforms defines the current uniform list.
  19668. */
  19669. static AddUniforms(uniforms: string[]): void;
  19670. /**
  19671. * Add the required samplers to the current list.
  19672. * @param samplers defines the current sampler list.
  19673. */
  19674. static AddSamplers(samplers: string[]): void;
  19675. /**
  19676. * Add the required uniforms to the current buffer.
  19677. * @param uniformBuffer defines the current uniform buffer.
  19678. */
  19679. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  19680. /**
  19681. * Makes a duplicate of the current instance into another one.
  19682. * @param detailMap define the instance where to copy the info
  19683. */
  19684. copyTo(detailMap: DetailMapConfiguration): void;
  19685. /**
  19686. * Serializes this detail map instance
  19687. * @returns - An object with the serialized instance.
  19688. */
  19689. serialize(): any;
  19690. /**
  19691. * Parses a detail map setting from a serialized object.
  19692. * @param source - Serialized object.
  19693. * @param scene Defines the scene we are parsing for
  19694. * @param rootUrl Defines the rootUrl to load from
  19695. */
  19696. parse(source: any, scene: Scene, rootUrl: string): void;
  19697. }
  19698. }
  19699. declare module BABYLON {
  19700. /** @hidden */
  19701. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  19702. MAINUV1: boolean;
  19703. MAINUV2: boolean;
  19704. DIFFUSE: boolean;
  19705. DIFFUSEDIRECTUV: number;
  19706. DETAIL: boolean;
  19707. DETAILDIRECTUV: number;
  19708. DETAIL_NORMALBLENDMETHOD: number;
  19709. AMBIENT: boolean;
  19710. AMBIENTDIRECTUV: number;
  19711. OPACITY: boolean;
  19712. OPACITYDIRECTUV: number;
  19713. OPACITYRGB: boolean;
  19714. REFLECTION: boolean;
  19715. EMISSIVE: boolean;
  19716. EMISSIVEDIRECTUV: number;
  19717. SPECULAR: boolean;
  19718. SPECULARDIRECTUV: number;
  19719. BUMP: boolean;
  19720. BUMPDIRECTUV: number;
  19721. PARALLAX: boolean;
  19722. PARALLAXOCCLUSION: boolean;
  19723. SPECULAROVERALPHA: boolean;
  19724. CLIPPLANE: boolean;
  19725. CLIPPLANE2: boolean;
  19726. CLIPPLANE3: boolean;
  19727. CLIPPLANE4: boolean;
  19728. CLIPPLANE5: boolean;
  19729. CLIPPLANE6: boolean;
  19730. ALPHATEST: boolean;
  19731. DEPTHPREPASS: boolean;
  19732. ALPHAFROMDIFFUSE: boolean;
  19733. POINTSIZE: boolean;
  19734. FOG: boolean;
  19735. SPECULARTERM: boolean;
  19736. DIFFUSEFRESNEL: boolean;
  19737. OPACITYFRESNEL: boolean;
  19738. REFLECTIONFRESNEL: boolean;
  19739. REFRACTIONFRESNEL: boolean;
  19740. EMISSIVEFRESNEL: boolean;
  19741. FRESNEL: boolean;
  19742. NORMAL: boolean;
  19743. UV1: boolean;
  19744. UV2: boolean;
  19745. VERTEXCOLOR: boolean;
  19746. VERTEXALPHA: boolean;
  19747. NUM_BONE_INFLUENCERS: number;
  19748. BonesPerMesh: number;
  19749. BONETEXTURE: boolean;
  19750. BONES_VELOCITY_ENABLED: boolean;
  19751. INSTANCES: boolean;
  19752. THIN_INSTANCES: boolean;
  19753. GLOSSINESS: boolean;
  19754. ROUGHNESS: boolean;
  19755. EMISSIVEASILLUMINATION: boolean;
  19756. LINKEMISSIVEWITHDIFFUSE: boolean;
  19757. REFLECTIONFRESNELFROMSPECULAR: boolean;
  19758. LIGHTMAP: boolean;
  19759. LIGHTMAPDIRECTUV: number;
  19760. OBJECTSPACE_NORMALMAP: boolean;
  19761. USELIGHTMAPASSHADOWMAP: boolean;
  19762. REFLECTIONMAP_3D: boolean;
  19763. REFLECTIONMAP_SPHERICAL: boolean;
  19764. REFLECTIONMAP_PLANAR: boolean;
  19765. REFLECTIONMAP_CUBIC: boolean;
  19766. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  19767. REFLECTIONMAP_PROJECTION: boolean;
  19768. REFLECTIONMAP_SKYBOX: boolean;
  19769. REFLECTIONMAP_EXPLICIT: boolean;
  19770. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  19771. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  19772. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  19773. REFLECTIONMAP_OPPOSITEZ: boolean;
  19774. INVERTCUBICMAP: boolean;
  19775. LOGARITHMICDEPTH: boolean;
  19776. REFRACTION: boolean;
  19777. REFRACTIONMAP_3D: boolean;
  19778. REFLECTIONOVERALPHA: boolean;
  19779. TWOSIDEDLIGHTING: boolean;
  19780. SHADOWFLOAT: boolean;
  19781. MORPHTARGETS: boolean;
  19782. MORPHTARGETS_NORMAL: boolean;
  19783. MORPHTARGETS_TANGENT: boolean;
  19784. MORPHTARGETS_UV: boolean;
  19785. NUM_MORPH_INFLUENCERS: number;
  19786. MORPHTARGETS_TEXTURE: boolean;
  19787. NONUNIFORMSCALING: boolean;
  19788. PREMULTIPLYALPHA: boolean;
  19789. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  19790. ALPHABLEND: boolean;
  19791. PREPASS: boolean;
  19792. PREPASS_IRRADIANCE: boolean;
  19793. PREPASS_IRRADIANCE_INDEX: number;
  19794. PREPASS_ALBEDO: boolean;
  19795. PREPASS_ALBEDO_INDEX: number;
  19796. PREPASS_DEPTH: boolean;
  19797. PREPASS_DEPTH_INDEX: number;
  19798. PREPASS_NORMAL: boolean;
  19799. PREPASS_NORMAL_INDEX: number;
  19800. PREPASS_POSITION: boolean;
  19801. PREPASS_POSITION_INDEX: number;
  19802. PREPASS_VELOCITY: boolean;
  19803. PREPASS_VELOCITY_INDEX: number;
  19804. PREPASS_REFLECTIVITY: boolean;
  19805. PREPASS_REFLECTIVITY_INDEX: number;
  19806. SCENE_MRT_COUNT: number;
  19807. RGBDLIGHTMAP: boolean;
  19808. RGBDREFLECTION: boolean;
  19809. RGBDREFRACTION: boolean;
  19810. IMAGEPROCESSING: boolean;
  19811. VIGNETTE: boolean;
  19812. VIGNETTEBLENDMODEMULTIPLY: boolean;
  19813. VIGNETTEBLENDMODEOPAQUE: boolean;
  19814. TONEMAPPING: boolean;
  19815. TONEMAPPING_ACES: boolean;
  19816. CONTRAST: boolean;
  19817. COLORCURVES: boolean;
  19818. COLORGRADING: boolean;
  19819. COLORGRADING3D: boolean;
  19820. SAMPLER3DGREENDEPTH: boolean;
  19821. SAMPLER3DBGRMAP: boolean;
  19822. IMAGEPROCESSINGPOSTPROCESS: boolean;
  19823. MULTIVIEW: boolean;
  19824. /**
  19825. * If the reflection texture on this material is in linear color space
  19826. * @hidden
  19827. */
  19828. IS_REFLECTION_LINEAR: boolean;
  19829. /**
  19830. * If the refraction texture on this material is in linear color space
  19831. * @hidden
  19832. */
  19833. IS_REFRACTION_LINEAR: boolean;
  19834. EXPOSURE: boolean;
  19835. constructor();
  19836. setReflectionMode(modeToEnable: string): void;
  19837. }
  19838. /**
  19839. * This is the default material used in Babylon. It is the best trade off between quality
  19840. * and performances.
  19841. * @see https://doc.babylonjs.com/babylon101/materials
  19842. */
  19843. export class StandardMaterial extends PushMaterial {
  19844. private _diffuseTexture;
  19845. /**
  19846. * The basic texture of the material as viewed under a light.
  19847. */
  19848. diffuseTexture: Nullable<BaseTexture>;
  19849. private _ambientTexture;
  19850. /**
  19851. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  19852. */
  19853. ambientTexture: Nullable<BaseTexture>;
  19854. private _opacityTexture;
  19855. /**
  19856. * Define the transparency of the material from a texture.
  19857. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  19858. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  19859. */
  19860. opacityTexture: Nullable<BaseTexture>;
  19861. private _reflectionTexture;
  19862. /**
  19863. * Define the texture used to display the reflection.
  19864. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19865. */
  19866. reflectionTexture: Nullable<BaseTexture>;
  19867. private _emissiveTexture;
  19868. /**
  19869. * Define texture of the material as if self lit.
  19870. * This will be mixed in the final result even in the absence of light.
  19871. */
  19872. emissiveTexture: Nullable<BaseTexture>;
  19873. private _specularTexture;
  19874. /**
  19875. * Define how the color and intensity of the highlight given by the light in the material.
  19876. */
  19877. specularTexture: Nullable<BaseTexture>;
  19878. private _bumpTexture;
  19879. /**
  19880. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  19881. * 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.
  19882. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  19883. */
  19884. bumpTexture: Nullable<BaseTexture>;
  19885. private _lightmapTexture;
  19886. /**
  19887. * Complex lighting can be computationally expensive to compute at runtime.
  19888. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  19889. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  19890. */
  19891. lightmapTexture: Nullable<BaseTexture>;
  19892. private _refractionTexture;
  19893. /**
  19894. * Define the texture used to display the refraction.
  19895. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19896. */
  19897. refractionTexture: Nullable<BaseTexture>;
  19898. /**
  19899. * The color of the material lit by the environmental background lighting.
  19900. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  19901. */
  19902. ambientColor: Color3;
  19903. /**
  19904. * The basic color of the material as viewed under a light.
  19905. */
  19906. diffuseColor: Color3;
  19907. /**
  19908. * Define how the color and intensity of the highlight given by the light in the material.
  19909. */
  19910. specularColor: Color3;
  19911. /**
  19912. * Define the color of the material as if self lit.
  19913. * This will be mixed in the final result even in the absence of light.
  19914. */
  19915. emissiveColor: Color3;
  19916. /**
  19917. * Defines how sharp are the highlights in the material.
  19918. * The bigger the value the sharper giving a more glossy feeling to the result.
  19919. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  19920. */
  19921. specularPower: number;
  19922. private _useAlphaFromDiffuseTexture;
  19923. /**
  19924. * Does the transparency come from the diffuse texture alpha channel.
  19925. */
  19926. useAlphaFromDiffuseTexture: boolean;
  19927. private _useEmissiveAsIllumination;
  19928. /**
  19929. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  19930. */
  19931. useEmissiveAsIllumination: boolean;
  19932. private _linkEmissiveWithDiffuse;
  19933. /**
  19934. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  19935. * the emissive level when the final color is close to one.
  19936. */
  19937. linkEmissiveWithDiffuse: boolean;
  19938. private _useSpecularOverAlpha;
  19939. /**
  19940. * Specifies that the material will keep the specular highlights over a transparent surface (only the most luminous ones).
  19941. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  19942. */
  19943. useSpecularOverAlpha: boolean;
  19944. private _useReflectionOverAlpha;
  19945. /**
  19946. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  19947. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  19948. */
  19949. useReflectionOverAlpha: boolean;
  19950. private _disableLighting;
  19951. /**
  19952. * Does lights from the scene impacts this material.
  19953. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  19954. */
  19955. disableLighting: boolean;
  19956. private _useObjectSpaceNormalMap;
  19957. /**
  19958. * Allows using an object space normal map (instead of tangent space).
  19959. */
  19960. useObjectSpaceNormalMap: boolean;
  19961. private _useParallax;
  19962. /**
  19963. * Is parallax enabled or not.
  19964. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  19965. */
  19966. useParallax: boolean;
  19967. private _useParallaxOcclusion;
  19968. /**
  19969. * Is parallax occlusion enabled or not.
  19970. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  19971. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  19972. */
  19973. useParallaxOcclusion: boolean;
  19974. /**
  19975. * 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.
  19976. */
  19977. parallaxScaleBias: number;
  19978. private _roughness;
  19979. /**
  19980. * Helps to define how blurry the reflections should appears in the material.
  19981. */
  19982. roughness: number;
  19983. /**
  19984. * In case of refraction, define the value of the index of refraction.
  19985. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19986. */
  19987. indexOfRefraction: number;
  19988. /**
  19989. * Invert the refraction texture alongside the y axis.
  19990. * It can be useful with procedural textures or probe for instance.
  19991. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19992. */
  19993. invertRefractionY: boolean;
  19994. /**
  19995. * Defines the alpha limits in alpha test mode.
  19996. */
  19997. alphaCutOff: number;
  19998. private _useLightmapAsShadowmap;
  19999. /**
  20000. * In case of light mapping, define whether the map contains light or shadow informations.
  20001. */
  20002. useLightmapAsShadowmap: boolean;
  20003. private _diffuseFresnelParameters;
  20004. /**
  20005. * Define the diffuse fresnel parameters of the material.
  20006. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  20007. */
  20008. diffuseFresnelParameters: FresnelParameters;
  20009. private _opacityFresnelParameters;
  20010. /**
  20011. * Define the opacity fresnel parameters of the material.
  20012. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  20013. */
  20014. opacityFresnelParameters: FresnelParameters;
  20015. private _reflectionFresnelParameters;
  20016. /**
  20017. * Define the reflection fresnel parameters of the material.
  20018. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  20019. */
  20020. reflectionFresnelParameters: FresnelParameters;
  20021. private _refractionFresnelParameters;
  20022. /**
  20023. * Define the refraction fresnel parameters of the material.
  20024. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  20025. */
  20026. refractionFresnelParameters: FresnelParameters;
  20027. private _emissiveFresnelParameters;
  20028. /**
  20029. * Define the emissive fresnel parameters of the material.
  20030. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  20031. */
  20032. emissiveFresnelParameters: FresnelParameters;
  20033. private _useReflectionFresnelFromSpecular;
  20034. /**
  20035. * If true automatically deducts the fresnels values from the material specularity.
  20036. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  20037. */
  20038. useReflectionFresnelFromSpecular: boolean;
  20039. private _useGlossinessFromSpecularMapAlpha;
  20040. /**
  20041. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  20042. */
  20043. useGlossinessFromSpecularMapAlpha: boolean;
  20044. private _maxSimultaneousLights;
  20045. /**
  20046. * Defines the maximum number of lights that can be used in the material
  20047. */
  20048. maxSimultaneousLights: number;
  20049. private _invertNormalMapX;
  20050. /**
  20051. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  20052. */
  20053. invertNormalMapX: boolean;
  20054. private _invertNormalMapY;
  20055. /**
  20056. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  20057. */
  20058. invertNormalMapY: boolean;
  20059. private _twoSidedLighting;
  20060. /**
  20061. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  20062. */
  20063. twoSidedLighting: boolean;
  20064. /**
  20065. * Default configuration related to image processing available in the standard Material.
  20066. */
  20067. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  20068. /**
  20069. * Gets the image processing configuration used either in this material.
  20070. */
  20071. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  20072. /**
  20073. * Sets the Default image processing configuration used either in the this material.
  20074. *
  20075. * If sets to null, the scene one is in use.
  20076. */
  20077. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  20078. /**
  20079. * Keep track of the image processing observer to allow dispose and replace.
  20080. */
  20081. private _imageProcessingObserver;
  20082. /**
  20083. * Attaches a new image processing configuration to the Standard Material.
  20084. * @param configuration
  20085. */
  20086. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  20087. /**
  20088. * Defines additional PrePass parameters for the material.
  20089. */
  20090. readonly prePassConfiguration: PrePassConfiguration;
  20091. /**
  20092. * Can this material render to prepass
  20093. */
  20094. get isPrePassCapable(): boolean;
  20095. /**
  20096. * Gets whether the color curves effect is enabled.
  20097. */
  20098. get cameraColorCurvesEnabled(): boolean;
  20099. /**
  20100. * Sets whether the color curves effect is enabled.
  20101. */
  20102. set cameraColorCurvesEnabled(value: boolean);
  20103. /**
  20104. * Gets whether the color grading effect is enabled.
  20105. */
  20106. get cameraColorGradingEnabled(): boolean;
  20107. /**
  20108. * Gets whether the color grading effect is enabled.
  20109. */
  20110. set cameraColorGradingEnabled(value: boolean);
  20111. /**
  20112. * Gets whether tonemapping is enabled or not.
  20113. */
  20114. get cameraToneMappingEnabled(): boolean;
  20115. /**
  20116. * Sets whether tonemapping is enabled or not
  20117. */
  20118. set cameraToneMappingEnabled(value: boolean);
  20119. /**
  20120. * The camera exposure used on this material.
  20121. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  20122. * This corresponds to a photographic exposure.
  20123. */
  20124. get cameraExposure(): number;
  20125. /**
  20126. * The camera exposure used on this material.
  20127. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  20128. * This corresponds to a photographic exposure.
  20129. */
  20130. set cameraExposure(value: number);
  20131. /**
  20132. * Gets The camera contrast used on this material.
  20133. */
  20134. get cameraContrast(): number;
  20135. /**
  20136. * Sets The camera contrast used on this material.
  20137. */
  20138. set cameraContrast(value: number);
  20139. /**
  20140. * Gets the Color Grading 2D Lookup Texture.
  20141. */
  20142. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  20143. /**
  20144. * Sets the Color Grading 2D Lookup Texture.
  20145. */
  20146. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  20147. /**
  20148. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  20149. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  20150. * 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;
  20151. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  20152. */
  20153. get cameraColorCurves(): Nullable<ColorCurves>;
  20154. /**
  20155. * The color grading curves provide additional color adjustment that is applied after any color grading transform (3D LUT).
  20156. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  20157. * 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;
  20158. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  20159. */
  20160. set cameraColorCurves(value: Nullable<ColorCurves>);
  20161. /**
  20162. * Can this material render to several textures at once
  20163. */
  20164. get canRenderToMRT(): boolean;
  20165. /**
  20166. * Defines the detail map parameters for the material.
  20167. */
  20168. readonly detailMap: DetailMapConfiguration;
  20169. protected _renderTargets: SmartArray<RenderTargetTexture>;
  20170. protected _worldViewProjectionMatrix: Matrix;
  20171. protected _globalAmbientColor: Color3;
  20172. protected _useLogarithmicDepth: boolean;
  20173. protected _rebuildInParallel: boolean;
  20174. /**
  20175. * Instantiates a new standard material.
  20176. * This is the default material used in Babylon. It is the best trade off between quality
  20177. * and performances.
  20178. * @see https://doc.babylonjs.com/babylon101/materials
  20179. * @param name Define the name of the material in the scene
  20180. * @param scene Define the scene the material belong to
  20181. */
  20182. constructor(name: string, scene: Scene);
  20183. /**
  20184. * Gets a boolean indicating that current material needs to register RTT
  20185. */
  20186. get hasRenderTargetTextures(): boolean;
  20187. /**
  20188. * Gets the current class name of the material e.g. "StandardMaterial"
  20189. * Mainly use in serialization.
  20190. * @returns the class name
  20191. */
  20192. getClassName(): string;
  20193. /**
  20194. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  20195. * You can try switching to logarithmic depth.
  20196. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  20197. */
  20198. get useLogarithmicDepth(): boolean;
  20199. set useLogarithmicDepth(value: boolean);
  20200. /**
  20201. * Specifies if the material will require alpha blending
  20202. * @returns a boolean specifying if alpha blending is needed
  20203. */
  20204. needAlphaBlending(): boolean;
  20205. /**
  20206. * Specifies if this material should be rendered in alpha test mode
  20207. * @returns a boolean specifying if an alpha test is needed.
  20208. */
  20209. needAlphaTesting(): boolean;
  20210. /**
  20211. * Specifies whether or not the alpha value of the diffuse texture should be used for alpha blending.
  20212. */
  20213. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  20214. /**
  20215. * Specifies whether or not there is a usable alpha channel for transparency.
  20216. */
  20217. protected _hasAlphaChannel(): boolean;
  20218. /**
  20219. * Get the texture used for alpha test purpose.
  20220. * @returns the diffuse texture in case of the standard material.
  20221. */
  20222. getAlphaTestTexture(): Nullable<BaseTexture>;
  20223. /**
  20224. * Get if the submesh is ready to be used and all its information available.
  20225. * Child classes can use it to update shaders
  20226. * @param mesh defines the mesh to check
  20227. * @param subMesh defines which submesh to check
  20228. * @param useInstances specifies that instances should be used
  20229. * @returns a boolean indicating that the submesh is ready or not
  20230. */
  20231. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  20232. /**
  20233. * Builds the material UBO layouts.
  20234. * Used internally during the effect preparation.
  20235. */
  20236. buildUniformLayout(): void;
  20237. /**
  20238. * Unbinds the material from the mesh
  20239. */
  20240. unbind(): void;
  20241. /**
  20242. * Binds the submesh to this material by preparing the effect and shader to draw
  20243. * @param world defines the world transformation matrix
  20244. * @param mesh defines the mesh containing the submesh
  20245. * @param subMesh defines the submesh to bind the material to
  20246. */
  20247. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20248. /**
  20249. * Get the list of animatables in the material.
  20250. * @returns the list of animatables object used in the material
  20251. */
  20252. getAnimatables(): IAnimatable[];
  20253. /**
  20254. * Gets the active textures from the material
  20255. * @returns an array of textures
  20256. */
  20257. getActiveTextures(): BaseTexture[];
  20258. /**
  20259. * Specifies if the material uses a texture
  20260. * @param texture defines the texture to check against the material
  20261. * @returns a boolean specifying if the material uses the texture
  20262. */
  20263. hasTexture(texture: BaseTexture): boolean;
  20264. /**
  20265. * Disposes the material
  20266. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20267. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20268. */
  20269. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  20270. /**
  20271. * Makes a duplicate of the material, and gives it a new name
  20272. * @param name defines the new name for the duplicated material
  20273. * @returns the cloned material
  20274. */
  20275. clone(name: string): StandardMaterial;
  20276. /**
  20277. * Serializes this material in a JSON representation
  20278. * @returns the serialized material object
  20279. */
  20280. serialize(): any;
  20281. /**
  20282. * Creates a standard material from parsed material data
  20283. * @param source defines the JSON representation of the material
  20284. * @param scene defines the hosting scene
  20285. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  20286. * @returns a new standard material
  20287. */
  20288. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  20289. /**
  20290. * Are diffuse textures enabled in the application.
  20291. */
  20292. static get DiffuseTextureEnabled(): boolean;
  20293. static set DiffuseTextureEnabled(value: boolean);
  20294. /**
  20295. * Are detail textures enabled in the application.
  20296. */
  20297. static get DetailTextureEnabled(): boolean;
  20298. static set DetailTextureEnabled(value: boolean);
  20299. /**
  20300. * Are ambient textures enabled in the application.
  20301. */
  20302. static get AmbientTextureEnabled(): boolean;
  20303. static set AmbientTextureEnabled(value: boolean);
  20304. /**
  20305. * Are opacity textures enabled in the application.
  20306. */
  20307. static get OpacityTextureEnabled(): boolean;
  20308. static set OpacityTextureEnabled(value: boolean);
  20309. /**
  20310. * Are reflection textures enabled in the application.
  20311. */
  20312. static get ReflectionTextureEnabled(): boolean;
  20313. static set ReflectionTextureEnabled(value: boolean);
  20314. /**
  20315. * Are emissive textures enabled in the application.
  20316. */
  20317. static get EmissiveTextureEnabled(): boolean;
  20318. static set EmissiveTextureEnabled(value: boolean);
  20319. /**
  20320. * Are specular textures enabled in the application.
  20321. */
  20322. static get SpecularTextureEnabled(): boolean;
  20323. static set SpecularTextureEnabled(value: boolean);
  20324. /**
  20325. * Are bump textures enabled in the application.
  20326. */
  20327. static get BumpTextureEnabled(): boolean;
  20328. static set BumpTextureEnabled(value: boolean);
  20329. /**
  20330. * Are lightmap textures enabled in the application.
  20331. */
  20332. static get LightmapTextureEnabled(): boolean;
  20333. static set LightmapTextureEnabled(value: boolean);
  20334. /**
  20335. * Are refraction textures enabled in the application.
  20336. */
  20337. static get RefractionTextureEnabled(): boolean;
  20338. static set RefractionTextureEnabled(value: boolean);
  20339. /**
  20340. * Are color grading textures enabled in the application.
  20341. */
  20342. static get ColorGradingTextureEnabled(): boolean;
  20343. static set ColorGradingTextureEnabled(value: boolean);
  20344. /**
  20345. * Are fresnels enabled in the application.
  20346. */
  20347. static get FresnelEnabled(): boolean;
  20348. static set FresnelEnabled(value: boolean);
  20349. }
  20350. }
  20351. declare module BABYLON {
  20352. /** @hidden */
  20353. export var rgbdDecodePixelShader: {
  20354. name: string;
  20355. shader: string;
  20356. };
  20357. }
  20358. declare module BABYLON {
  20359. /** @hidden */
  20360. export var passPixelShader: {
  20361. name: string;
  20362. shader: string;
  20363. };
  20364. }
  20365. declare module BABYLON {
  20366. /** @hidden */
  20367. export var passCubePixelShader: {
  20368. name: string;
  20369. shader: string;
  20370. };
  20371. }
  20372. declare module BABYLON {
  20373. /**
  20374. * PassPostProcess which produces an output the same as it's input
  20375. */
  20376. export class PassPostProcess extends PostProcess {
  20377. /**
  20378. * Gets a string identifying the name of the class
  20379. * @returns "PassPostProcess" string
  20380. */
  20381. getClassName(): string;
  20382. /**
  20383. * Creates the PassPostProcess
  20384. * @param name The name of the effect.
  20385. * @param options The required width/height ratio to downsize to before computing the render pass.
  20386. * @param camera The camera to apply the render pass to.
  20387. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20388. * @param engine The engine which the post process will be applied. (default: current engine)
  20389. * @param reusable If the post process can be reused on the same frame. (default: false)
  20390. * @param textureType The type of texture to be used when performing the post processing.
  20391. * @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)
  20392. */
  20393. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  20394. /** @hidden */
  20395. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  20396. }
  20397. /**
  20398. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  20399. */
  20400. export class PassCubePostProcess extends PostProcess {
  20401. private _face;
  20402. /**
  20403. * Gets or sets the cube face to display.
  20404. * * 0 is +X
  20405. * * 1 is -X
  20406. * * 2 is +Y
  20407. * * 3 is -Y
  20408. * * 4 is +Z
  20409. * * 5 is -Z
  20410. */
  20411. get face(): number;
  20412. set face(value: number);
  20413. /**
  20414. * Gets a string identifying the name of the class
  20415. * @returns "PassCubePostProcess" string
  20416. */
  20417. getClassName(): string;
  20418. /**
  20419. * Creates the PassCubePostProcess
  20420. * @param name The name of the effect.
  20421. * @param options The required width/height ratio to downsize to before computing the render pass.
  20422. * @param camera The camera to apply the render pass to.
  20423. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20424. * @param engine The engine which the post process will be applied. (default: current engine)
  20425. * @param reusable If the post process can be reused on the same frame. (default: false)
  20426. * @param textureType The type of texture to be used when performing the post processing.
  20427. * @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)
  20428. */
  20429. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  20430. /** @hidden */
  20431. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  20432. }
  20433. }
  20434. declare module BABYLON {
  20435. /**
  20436. * Class used to host texture specific utilities
  20437. */
  20438. export class TextureTools {
  20439. /**
  20440. * Uses the GPU to create a copy texture rescaled at a given size
  20441. * @param texture Texture to copy from
  20442. * @param width defines the desired width
  20443. * @param height defines the desired height
  20444. * @param useBilinearMode defines if bilinear mode has to be used
  20445. * @return the generated texture
  20446. */
  20447. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  20448. /**
  20449. * Apply a post process to a texture
  20450. * @param postProcessName name of the fragment post process
  20451. * @param internalTexture the texture to encode
  20452. * @param scene the scene hosting the texture
  20453. * @param type type of the output texture. If not provided, use the one from internalTexture
  20454. * @param samplingMode sampling mode to use to sample the source texture. If not provided, use the one from internalTexture
  20455. * @param format format of the output texture. If not provided, use the one from internalTexture
  20456. * @return a promise with the internalTexture having its texture replaced by the result of the processing
  20457. */
  20458. static ApplyPostProcess(postProcessName: string, internalTexture: InternalTexture, scene: Scene, type?: number, samplingMode?: number, format?: number): Promise<InternalTexture>;
  20459. }
  20460. }
  20461. declare module BABYLON {
  20462. /**
  20463. * Class used to host RGBD texture specific utilities
  20464. */
  20465. export class RGBDTextureTools {
  20466. /**
  20467. * Expand the RGBD Texture from RGBD to Half Float if possible.
  20468. * @param texture the texture to expand.
  20469. */
  20470. static ExpandRGBDTexture(texture: Texture): void;
  20471. /**
  20472. * Encode the texture to RGBD if possible.
  20473. * @param internalTexture the texture to encode
  20474. * @param scene the scene hosting the texture
  20475. * @param outputTextureType type of the texture in which the encoding is performed
  20476. * @return a promise with the internalTexture having its texture replaced by the result of the processing
  20477. */
  20478. static EncodeTextureToRGBD(internalTexture: InternalTexture, scene: Scene, outputTextureType?: number): Promise<InternalTexture>;
  20479. }
  20480. }
  20481. declare module BABYLON {
  20482. /**
  20483. * Class used to host texture specific utilities
  20484. */
  20485. export class BRDFTextureTools {
  20486. /**
  20487. * Prevents texture cache collision
  20488. */
  20489. private static _instanceNumber;
  20490. /**
  20491. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  20492. * @param scene defines the hosting scene
  20493. * @returns the environment BRDF texture
  20494. */
  20495. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  20496. private static _environmentBRDFBase64Texture;
  20497. }
  20498. }
  20499. declare module BABYLON {
  20500. /**
  20501. * @hidden
  20502. */
  20503. export interface IMaterialClearCoatDefines {
  20504. CLEARCOAT: boolean;
  20505. CLEARCOAT_DEFAULTIOR: boolean;
  20506. CLEARCOAT_TEXTURE: boolean;
  20507. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  20508. CLEARCOAT_TEXTUREDIRECTUV: number;
  20509. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  20510. CLEARCOAT_BUMP: boolean;
  20511. CLEARCOAT_BUMPDIRECTUV: number;
  20512. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  20513. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  20514. CLEARCOAT_REMAP_F0: boolean;
  20515. CLEARCOAT_TINT: boolean;
  20516. CLEARCOAT_TINT_TEXTURE: boolean;
  20517. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  20518. /** @hidden */
  20519. _areTexturesDirty: boolean;
  20520. }
  20521. /**
  20522. * Define the code related to the clear coat parameters of the pbr material.
  20523. */
  20524. export class PBRClearCoatConfiguration {
  20525. /**
  20526. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  20527. * The default fits with a polyurethane material.
  20528. * @hidden
  20529. */
  20530. static readonly _DefaultIndexOfRefraction: number;
  20531. private _isEnabled;
  20532. /**
  20533. * Defines if the clear coat is enabled in the material.
  20534. */
  20535. isEnabled: boolean;
  20536. /**
  20537. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  20538. */
  20539. intensity: number;
  20540. /**
  20541. * Defines the clear coat layer roughness.
  20542. */
  20543. roughness: number;
  20544. private _indexOfRefraction;
  20545. /**
  20546. * Defines the index of refraction of the clear coat.
  20547. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  20548. * The default fits with a polyurethane material.
  20549. * Changing the default value is more performance intensive.
  20550. */
  20551. indexOfRefraction: number;
  20552. private _texture;
  20553. /**
  20554. * Stores the clear coat values in a texture (red channel is intensity and green channel is roughness)
  20555. * If useRoughnessFromMainTexture is false, the green channel of texture is not used and the green channel of textureRoughness is used instead
  20556. * if textureRoughness is not empty, else no texture roughness is used
  20557. */
  20558. texture: Nullable<BaseTexture>;
  20559. private _useRoughnessFromMainTexture;
  20560. /**
  20561. * Indicates that the green channel of the texture property will be used for roughness (default: true)
  20562. * If false, the green channel from textureRoughness is used for roughness
  20563. */
  20564. useRoughnessFromMainTexture: boolean;
  20565. private _textureRoughness;
  20566. /**
  20567. * Stores the clear coat roughness in a texture (green channel)
  20568. * Not used if useRoughnessFromMainTexture is true
  20569. */
  20570. textureRoughness: Nullable<BaseTexture>;
  20571. private _remapF0OnInterfaceChange;
  20572. /**
  20573. * Defines if the F0 value should be remapped to account for the interface change in the material.
  20574. */
  20575. remapF0OnInterfaceChange: boolean;
  20576. private _bumpTexture;
  20577. /**
  20578. * Define the clear coat specific bump texture.
  20579. */
  20580. bumpTexture: Nullable<BaseTexture>;
  20581. private _isTintEnabled;
  20582. /**
  20583. * Defines if the clear coat tint is enabled in the material.
  20584. */
  20585. isTintEnabled: boolean;
  20586. /**
  20587. * Defines the clear coat tint of the material.
  20588. * This is only use if tint is enabled
  20589. */
  20590. tintColor: Color3;
  20591. /**
  20592. * Defines the distance at which the tint color should be found in the
  20593. * clear coat media.
  20594. * This is only use if tint is enabled
  20595. */
  20596. tintColorAtDistance: number;
  20597. /**
  20598. * Defines the clear coat layer thickness.
  20599. * This is only use if tint is enabled
  20600. */
  20601. tintThickness: number;
  20602. private _tintTexture;
  20603. /**
  20604. * Stores the clear tint values in a texture.
  20605. * rgb is tint
  20606. * a is a thickness factor
  20607. */
  20608. tintTexture: Nullable<BaseTexture>;
  20609. /** @hidden */
  20610. private _internalMarkAllSubMeshesAsTexturesDirty;
  20611. /** @hidden */
  20612. _markAllSubMeshesAsTexturesDirty(): void;
  20613. /**
  20614. * Instantiate a new instance of clear coat configuration.
  20615. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20616. */
  20617. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  20618. /**
  20619. * Gets whether the submesh is ready to be used or not.
  20620. * @param defines the list of "defines" to update.
  20621. * @param scene defines the scene the material belongs to.
  20622. * @param engine defines the engine the material belongs to.
  20623. * @param disableBumpMap defines whether the material disables bump or not.
  20624. * @returns - boolean indicating that the submesh is ready or not.
  20625. */
  20626. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  20627. /**
  20628. * Checks to see if a texture is used in the material.
  20629. * @param defines the list of "defines" to update.
  20630. * @param scene defines the scene to the material belongs to.
  20631. */
  20632. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  20633. /**
  20634. * Binds the material data.
  20635. * @param uniformBuffer defines the Uniform buffer to fill in.
  20636. * @param scene defines the scene the material belongs to.
  20637. * @param engine defines the engine the material belongs to.
  20638. * @param disableBumpMap defines whether the material disables bump or not.
  20639. * @param isFrozen defines whether the material is frozen or not.
  20640. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  20641. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  20642. * @param subMesh the submesh to bind data for
  20643. */
  20644. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean, subMesh?: SubMesh): void;
  20645. /**
  20646. * Checks to see if a texture is used in the material.
  20647. * @param texture - Base texture to use.
  20648. * @returns - Boolean specifying if a texture is used in the material.
  20649. */
  20650. hasTexture(texture: BaseTexture): boolean;
  20651. /**
  20652. * Returns an array of the actively used textures.
  20653. * @param activeTextures Array of BaseTextures
  20654. */
  20655. getActiveTextures(activeTextures: BaseTexture[]): void;
  20656. /**
  20657. * Returns the animatable textures.
  20658. * @param animatables Array of animatable textures.
  20659. */
  20660. getAnimatables(animatables: IAnimatable[]): void;
  20661. /**
  20662. * Disposes the resources of the material.
  20663. * @param forceDisposeTextures - Forces the disposal of all textures.
  20664. */
  20665. dispose(forceDisposeTextures?: boolean): void;
  20666. /**
  20667. * Get the current class name of the texture useful for serialization or dynamic coding.
  20668. * @returns "PBRClearCoatConfiguration"
  20669. */
  20670. getClassName(): string;
  20671. /**
  20672. * Add fallbacks to the effect fallbacks list.
  20673. * @param defines defines the Base texture to use.
  20674. * @param fallbacks defines the current fallback list.
  20675. * @param currentRank defines the current fallback rank.
  20676. * @returns the new fallback rank.
  20677. */
  20678. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20679. /**
  20680. * Add the required uniforms to the current list.
  20681. * @param uniforms defines the current uniform list.
  20682. */
  20683. static AddUniforms(uniforms: string[]): void;
  20684. /**
  20685. * Add the required samplers to the current list.
  20686. * @param samplers defines the current sampler list.
  20687. */
  20688. static AddSamplers(samplers: string[]): void;
  20689. /**
  20690. * Add the required uniforms to the current buffer.
  20691. * @param uniformBuffer defines the current uniform buffer.
  20692. */
  20693. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20694. /**
  20695. * Makes a duplicate of the current configuration into another one.
  20696. * @param clearCoatConfiguration define the config where to copy the info
  20697. */
  20698. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  20699. /**
  20700. * Serializes this clear coat configuration.
  20701. * @returns - An object with the serialized config.
  20702. */
  20703. serialize(): any;
  20704. /**
  20705. * Parses a anisotropy Configuration from a serialized object.
  20706. * @param source - Serialized object.
  20707. * @param scene Defines the scene we are parsing for
  20708. * @param rootUrl Defines the rootUrl to load from
  20709. */
  20710. parse(source: any, scene: Scene, rootUrl: string): void;
  20711. }
  20712. }
  20713. declare module BABYLON {
  20714. /**
  20715. * @hidden
  20716. */
  20717. export interface IMaterialAnisotropicDefines {
  20718. ANISOTROPIC: boolean;
  20719. ANISOTROPIC_TEXTURE: boolean;
  20720. ANISOTROPIC_TEXTUREDIRECTUV: number;
  20721. MAINUV1: boolean;
  20722. _areTexturesDirty: boolean;
  20723. _needUVs: boolean;
  20724. }
  20725. /**
  20726. * Define the code related to the anisotropic parameters of the pbr material.
  20727. */
  20728. export class PBRAnisotropicConfiguration {
  20729. private _isEnabled;
  20730. /**
  20731. * Defines if the anisotropy is enabled in the material.
  20732. */
  20733. isEnabled: boolean;
  20734. /**
  20735. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  20736. */
  20737. intensity: number;
  20738. /**
  20739. * Defines if the effect is along the tangents, bitangents or in between.
  20740. * By default, the effect is "stretching" the highlights along the tangents.
  20741. */
  20742. direction: Vector2;
  20743. private _texture;
  20744. /**
  20745. * Stores the anisotropy values in a texture.
  20746. * rg is direction (like normal from -1 to 1)
  20747. * b is a intensity
  20748. */
  20749. texture: Nullable<BaseTexture>;
  20750. /** @hidden */
  20751. private _internalMarkAllSubMeshesAsTexturesDirty;
  20752. /** @hidden */
  20753. _markAllSubMeshesAsTexturesDirty(): void;
  20754. /**
  20755. * Instantiate a new instance of anisotropy configuration.
  20756. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20757. */
  20758. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  20759. /**
  20760. * Specifies that the submesh is ready to be used.
  20761. * @param defines the list of "defines" to update.
  20762. * @param scene defines the scene the material belongs to.
  20763. * @returns - boolean indicating that the submesh is ready or not.
  20764. */
  20765. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  20766. /**
  20767. * Checks to see if a texture is used in the material.
  20768. * @param defines the list of "defines" to update.
  20769. * @param mesh the mesh we are preparing the defines for.
  20770. * @param scene defines the scene the material belongs to.
  20771. */
  20772. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  20773. /**
  20774. * Binds the material data.
  20775. * @param uniformBuffer defines the Uniform buffer to fill in.
  20776. * @param scene defines the scene the material belongs to.
  20777. * @param isFrozen defines whether the material is frozen or not.
  20778. */
  20779. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  20780. /**
  20781. * Checks to see if a texture is used in the material.
  20782. * @param texture - Base texture to use.
  20783. * @returns - Boolean specifying if a texture is used in the material.
  20784. */
  20785. hasTexture(texture: BaseTexture): boolean;
  20786. /**
  20787. * Returns an array of the actively used textures.
  20788. * @param activeTextures Array of BaseTextures
  20789. */
  20790. getActiveTextures(activeTextures: BaseTexture[]): void;
  20791. /**
  20792. * Returns the animatable textures.
  20793. * @param animatables Array of animatable textures.
  20794. */
  20795. getAnimatables(animatables: IAnimatable[]): void;
  20796. /**
  20797. * Disposes the resources of the material.
  20798. * @param forceDisposeTextures - Forces the disposal of all textures.
  20799. */
  20800. dispose(forceDisposeTextures?: boolean): void;
  20801. /**
  20802. * Get the current class name of the texture useful for serialization or dynamic coding.
  20803. * @returns "PBRAnisotropicConfiguration"
  20804. */
  20805. getClassName(): string;
  20806. /**
  20807. * Add fallbacks to the effect fallbacks list.
  20808. * @param defines defines the Base texture to use.
  20809. * @param fallbacks defines the current fallback list.
  20810. * @param currentRank defines the current fallback rank.
  20811. * @returns the new fallback rank.
  20812. */
  20813. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20814. /**
  20815. * Add the required uniforms to the current list.
  20816. * @param uniforms defines the current uniform list.
  20817. */
  20818. static AddUniforms(uniforms: string[]): void;
  20819. /**
  20820. * Add the required uniforms to the current buffer.
  20821. * @param uniformBuffer defines the current uniform buffer.
  20822. */
  20823. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20824. /**
  20825. * Add the required samplers to the current list.
  20826. * @param samplers defines the current sampler list.
  20827. */
  20828. static AddSamplers(samplers: string[]): void;
  20829. /**
  20830. * Makes a duplicate of the current configuration into another one.
  20831. * @param anisotropicConfiguration define the config where to copy the info
  20832. */
  20833. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  20834. /**
  20835. * Serializes this anisotropy configuration.
  20836. * @returns - An object with the serialized config.
  20837. */
  20838. serialize(): any;
  20839. /**
  20840. * Parses a anisotropy Configuration from a serialized object.
  20841. * @param source - Serialized object.
  20842. * @param scene Defines the scene we are parsing for
  20843. * @param rootUrl Defines the rootUrl to load from
  20844. */
  20845. parse(source: any, scene: Scene, rootUrl: string): void;
  20846. }
  20847. }
  20848. declare module BABYLON {
  20849. /**
  20850. * @hidden
  20851. */
  20852. export interface IMaterialBRDFDefines {
  20853. BRDF_V_HEIGHT_CORRELATED: boolean;
  20854. MS_BRDF_ENERGY_CONSERVATION: boolean;
  20855. SPHERICAL_HARMONICS: boolean;
  20856. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  20857. /** @hidden */
  20858. _areMiscDirty: boolean;
  20859. }
  20860. /**
  20861. * Define the code related to the BRDF parameters of the pbr material.
  20862. */
  20863. export class PBRBRDFConfiguration {
  20864. /**
  20865. * Default value used for the energy conservation.
  20866. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  20867. */
  20868. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  20869. /**
  20870. * Default value used for the Smith Visibility Height Correlated mode.
  20871. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  20872. */
  20873. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  20874. /**
  20875. * Default value used for the IBL diffuse part.
  20876. * This can help switching back to the polynomials mode globally which is a tiny bit
  20877. * less GPU intensive at the drawback of a lower quality.
  20878. */
  20879. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  20880. /**
  20881. * Default value used for activating energy conservation for the specular workflow.
  20882. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  20883. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  20884. */
  20885. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  20886. private _useEnergyConservation;
  20887. /**
  20888. * Defines if the material uses energy conservation.
  20889. */
  20890. useEnergyConservation: boolean;
  20891. private _useSmithVisibilityHeightCorrelated;
  20892. /**
  20893. * LEGACY Mode set to false
  20894. * Defines if the material uses height smith correlated visibility term.
  20895. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  20896. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  20897. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  20898. * Not relying on height correlated will also disable energy conservation.
  20899. */
  20900. useSmithVisibilityHeightCorrelated: boolean;
  20901. private _useSphericalHarmonics;
  20902. /**
  20903. * LEGACY Mode set to false
  20904. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  20905. * diffuse part of the IBL.
  20906. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  20907. * to the ground truth.
  20908. */
  20909. useSphericalHarmonics: boolean;
  20910. private _useSpecularGlossinessInputEnergyConservation;
  20911. /**
  20912. * Defines if the material uses energy conservation, when the specular workflow is active.
  20913. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  20914. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  20915. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  20916. */
  20917. useSpecularGlossinessInputEnergyConservation: boolean;
  20918. /** @hidden */
  20919. private _internalMarkAllSubMeshesAsMiscDirty;
  20920. /** @hidden */
  20921. _markAllSubMeshesAsMiscDirty(): void;
  20922. /**
  20923. * Instantiate a new instance of clear coat configuration.
  20924. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  20925. */
  20926. constructor(markAllSubMeshesAsMiscDirty: () => void);
  20927. /**
  20928. * Checks to see if a texture is used in the material.
  20929. * @param defines the list of "defines" to update.
  20930. */
  20931. prepareDefines(defines: IMaterialBRDFDefines): void;
  20932. /**
  20933. * Get the current class name of the texture useful for serialization or dynamic coding.
  20934. * @returns "PBRClearCoatConfiguration"
  20935. */
  20936. getClassName(): string;
  20937. /**
  20938. * Makes a duplicate of the current configuration into another one.
  20939. * @param brdfConfiguration define the config where to copy the info
  20940. */
  20941. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  20942. /**
  20943. * Serializes this BRDF configuration.
  20944. * @returns - An object with the serialized config.
  20945. */
  20946. serialize(): any;
  20947. /**
  20948. * Parses a anisotropy Configuration from a serialized object.
  20949. * @param source - Serialized object.
  20950. * @param scene Defines the scene we are parsing for
  20951. * @param rootUrl Defines the rootUrl to load from
  20952. */
  20953. parse(source: any, scene: Scene, rootUrl: string): void;
  20954. }
  20955. }
  20956. declare module BABYLON {
  20957. /**
  20958. * @hidden
  20959. */
  20960. export interface IMaterialSheenDefines {
  20961. SHEEN: boolean;
  20962. SHEEN_TEXTURE: boolean;
  20963. SHEEN_TEXTURE_ROUGHNESS: boolean;
  20964. SHEEN_TEXTUREDIRECTUV: number;
  20965. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  20966. SHEEN_LINKWITHALBEDO: boolean;
  20967. SHEEN_ROUGHNESS: boolean;
  20968. SHEEN_ALBEDOSCALING: boolean;
  20969. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  20970. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  20971. /** @hidden */
  20972. _areTexturesDirty: boolean;
  20973. }
  20974. /**
  20975. * Define the code related to the Sheen parameters of the pbr material.
  20976. */
  20977. export class PBRSheenConfiguration {
  20978. private _isEnabled;
  20979. /**
  20980. * Defines if the material uses sheen.
  20981. */
  20982. isEnabled: boolean;
  20983. private _linkSheenWithAlbedo;
  20984. /**
  20985. * Defines if the sheen is linked to the sheen color.
  20986. */
  20987. linkSheenWithAlbedo: boolean;
  20988. /**
  20989. * Defines the sheen intensity.
  20990. */
  20991. intensity: number;
  20992. /**
  20993. * Defines the sheen color.
  20994. */
  20995. color: Color3;
  20996. private _texture;
  20997. /**
  20998. * Stores the sheen tint values in a texture.
  20999. * rgb is tint
  21000. * 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)
  21001. * If the roughness property has been defined and useRoughnessFromTexture is false then the alpha channel is not used to modulate roughness
  21002. */
  21003. texture: Nullable<BaseTexture>;
  21004. private _useRoughnessFromMainTexture;
  21005. /**
  21006. * Indicates that the alpha channel of the texture property will be used for roughness.
  21007. * Has no effect if the roughness (and texture!) property is not defined
  21008. */
  21009. useRoughnessFromMainTexture: boolean;
  21010. private _roughness;
  21011. /**
  21012. * Defines the sheen roughness.
  21013. * It is not taken into account if linkSheenWithAlbedo is true.
  21014. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  21015. */
  21016. roughness: Nullable<number>;
  21017. private _textureRoughness;
  21018. /**
  21019. * Stores the sheen roughness in a texture.
  21020. * alpha channel is the roughness. This texture won't be used if the texture property is not empty and useRoughnessFromTexture is true
  21021. */
  21022. textureRoughness: Nullable<BaseTexture>;
  21023. private _albedoScaling;
  21024. /**
  21025. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  21026. * It allows the strength of the sheen effect to not depend on the base color of the material,
  21027. * making it easier to setup and tweak the effect
  21028. */
  21029. albedoScaling: boolean;
  21030. /** @hidden */
  21031. private _internalMarkAllSubMeshesAsTexturesDirty;
  21032. /** @hidden */
  21033. _markAllSubMeshesAsTexturesDirty(): void;
  21034. /**
  21035. * Instantiate a new instance of clear coat configuration.
  21036. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  21037. */
  21038. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  21039. /**
  21040. * Specifies that the submesh is ready to be used.
  21041. * @param defines the list of "defines" to update.
  21042. * @param scene defines the scene the material belongs to.
  21043. * @returns - boolean indicating that the submesh is ready or not.
  21044. */
  21045. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  21046. /**
  21047. * Checks to see if a texture is used in the material.
  21048. * @param defines the list of "defines" to update.
  21049. * @param scene defines the scene the material belongs to.
  21050. */
  21051. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  21052. /**
  21053. * Binds the material data.
  21054. * @param uniformBuffer defines the Uniform buffer to fill in.
  21055. * @param scene defines the scene the material belongs to.
  21056. * @param isFrozen defines whether the material is frozen or not.
  21057. * @param subMesh the submesh to bind data for
  21058. */
  21059. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean, subMesh?: SubMesh): void;
  21060. /**
  21061. * Checks to see if a texture is used in the material.
  21062. * @param texture - Base texture to use.
  21063. * @returns - Boolean specifying if a texture is used in the material.
  21064. */
  21065. hasTexture(texture: BaseTexture): boolean;
  21066. /**
  21067. * Returns an array of the actively used textures.
  21068. * @param activeTextures Array of BaseTextures
  21069. */
  21070. getActiveTextures(activeTextures: BaseTexture[]): void;
  21071. /**
  21072. * Returns the animatable textures.
  21073. * @param animatables Array of animatable textures.
  21074. */
  21075. getAnimatables(animatables: IAnimatable[]): void;
  21076. /**
  21077. * Disposes the resources of the material.
  21078. * @param forceDisposeTextures - Forces the disposal of all textures.
  21079. */
  21080. dispose(forceDisposeTextures?: boolean): void;
  21081. /**
  21082. * Get the current class name of the texture useful for serialization or dynamic coding.
  21083. * @returns "PBRSheenConfiguration"
  21084. */
  21085. getClassName(): string;
  21086. /**
  21087. * Add fallbacks to the effect fallbacks list.
  21088. * @param defines defines the Base texture to use.
  21089. * @param fallbacks defines the current fallback list.
  21090. * @param currentRank defines the current fallback rank.
  21091. * @returns the new fallback rank.
  21092. */
  21093. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  21094. /**
  21095. * Add the required uniforms to the current list.
  21096. * @param uniforms defines the current uniform list.
  21097. */
  21098. static AddUniforms(uniforms: string[]): void;
  21099. /**
  21100. * Add the required uniforms to the current buffer.
  21101. * @param uniformBuffer defines the current uniform buffer.
  21102. */
  21103. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  21104. /**
  21105. * Add the required samplers to the current list.
  21106. * @param samplers defines the current sampler list.
  21107. */
  21108. static AddSamplers(samplers: string[]): void;
  21109. /**
  21110. * Makes a duplicate of the current configuration into another one.
  21111. * @param sheenConfiguration define the config where to copy the info
  21112. */
  21113. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  21114. /**
  21115. * Serializes this BRDF configuration.
  21116. * @returns - An object with the serialized config.
  21117. */
  21118. serialize(): any;
  21119. /**
  21120. * Parses a anisotropy Configuration from a serialized object.
  21121. * @param source - Serialized object.
  21122. * @param scene Defines the scene we are parsing for
  21123. * @param rootUrl Defines the rootUrl to load from
  21124. */
  21125. parse(source: any, scene: Scene, rootUrl: string): void;
  21126. }
  21127. }
  21128. declare module BABYLON {
  21129. /**
  21130. * @hidden
  21131. */
  21132. export interface IMaterialSubSurfaceDefines {
  21133. SUBSURFACE: boolean;
  21134. SS_REFRACTION: boolean;
  21135. SS_TRANSLUCENCY: boolean;
  21136. SS_SCATTERING: boolean;
  21137. SS_THICKNESSANDMASK_TEXTURE: boolean;
  21138. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  21139. SS_REFRACTIONMAP_3D: boolean;
  21140. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  21141. SS_LODINREFRACTIONALPHA: boolean;
  21142. SS_GAMMAREFRACTION: boolean;
  21143. SS_RGBDREFRACTION: boolean;
  21144. SS_LINEARSPECULARREFRACTION: boolean;
  21145. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  21146. SS_ALBEDOFORREFRACTIONTINT: boolean;
  21147. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  21148. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  21149. /** @hidden */
  21150. _areTexturesDirty: boolean;
  21151. }
  21152. /**
  21153. * Define the code related to the sub surface parameters of the pbr material.
  21154. */
  21155. export class PBRSubSurfaceConfiguration {
  21156. private _isRefractionEnabled;
  21157. /**
  21158. * Defines if the refraction is enabled in the material.
  21159. */
  21160. isRefractionEnabled: boolean;
  21161. private _isTranslucencyEnabled;
  21162. /**
  21163. * Defines if the translucency is enabled in the material.
  21164. */
  21165. isTranslucencyEnabled: boolean;
  21166. private _isScatteringEnabled;
  21167. /**
  21168. * Defines if the sub surface scattering is enabled in the material.
  21169. */
  21170. isScatteringEnabled: boolean;
  21171. private _scatteringDiffusionProfileIndex;
  21172. /**
  21173. * Diffusion profile for subsurface scattering.
  21174. * Useful for better scattering in the skins or foliages.
  21175. */
  21176. get scatteringDiffusionProfile(): Nullable<Color3>;
  21177. set scatteringDiffusionProfile(c: Nullable<Color3>);
  21178. /**
  21179. * Defines the refraction intensity of the material.
  21180. * The refraction when enabled replaces the Diffuse part of the material.
  21181. * The intensity helps transitioning between diffuse and refraction.
  21182. */
  21183. refractionIntensity: number;
  21184. /**
  21185. * Defines the translucency intensity of the material.
  21186. * When translucency has been enabled, this defines how much of the "translucency"
  21187. * is added to the diffuse part of the material.
  21188. */
  21189. translucencyIntensity: number;
  21190. /**
  21191. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  21192. */
  21193. useAlbedoToTintRefraction: boolean;
  21194. private _thicknessTexture;
  21195. /**
  21196. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  21197. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  21198. * 0 would mean minimumThickness
  21199. * 1 would mean maximumThickness
  21200. * The other channels might be use as a mask to vary the different effects intensity.
  21201. */
  21202. thicknessTexture: Nullable<BaseTexture>;
  21203. private _refractionTexture;
  21204. /**
  21205. * Defines the texture to use for refraction.
  21206. */
  21207. refractionTexture: Nullable<BaseTexture>;
  21208. private _indexOfRefraction;
  21209. /**
  21210. * Index of refraction of the material base layer.
  21211. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  21212. *
  21213. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  21214. *
  21215. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  21216. */
  21217. indexOfRefraction: number;
  21218. private _volumeIndexOfRefraction;
  21219. /**
  21220. * Index of refraction of the material's volume.
  21221. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  21222. *
  21223. * This ONLY impacts refraction. If not provided or given a non-valid value,
  21224. * the volume will use the same IOR as the surface.
  21225. */
  21226. get volumeIndexOfRefraction(): number;
  21227. set volumeIndexOfRefraction(value: number);
  21228. private _invertRefractionY;
  21229. /**
  21230. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21231. */
  21232. invertRefractionY: boolean;
  21233. private _linkRefractionWithTransparency;
  21234. /**
  21235. * This parameters will make the material used its opacity to control how much it is refracting against not.
  21236. * Materials half opaque for instance using refraction could benefit from this control.
  21237. */
  21238. linkRefractionWithTransparency: boolean;
  21239. /**
  21240. * Defines the minimum thickness stored in the thickness map.
  21241. * If no thickness map is defined, this value will be used to simulate thickness.
  21242. */
  21243. minimumThickness: number;
  21244. /**
  21245. * Defines the maximum thickness stored in the thickness map.
  21246. */
  21247. maximumThickness: number;
  21248. /**
  21249. * Defines the volume tint of the material.
  21250. * This is used for both translucency and scattering.
  21251. */
  21252. tintColor: Color3;
  21253. /**
  21254. * Defines the distance at which the tint color should be found in the media.
  21255. * This is used for refraction only.
  21256. */
  21257. tintColorAtDistance: number;
  21258. /**
  21259. * Defines how far each channel transmit through the media.
  21260. * It is defined as a color to simplify it selection.
  21261. */
  21262. diffusionDistance: Color3;
  21263. private _useMaskFromThicknessTexture;
  21264. /**
  21265. * Stores the intensity of the different subsurface effects in the thickness texture.
  21266. * * the green channel is the translucency intensity.
  21267. * * the blue channel is the scattering intensity.
  21268. * * the alpha channel is the refraction intensity.
  21269. */
  21270. useMaskFromThicknessTexture: boolean;
  21271. private _scene;
  21272. private _useMaskFromThicknessTextureGltf;
  21273. /**
  21274. * Stores the intensity of the different subsurface effects in the thickness texture. This variation
  21275. * matches the channel-packing that is used by glTF.
  21276. * * the red channel is the transmission/translucency intensity.
  21277. * * the green channel is the thickness.
  21278. */
  21279. useMaskFromThicknessTextureGltf: boolean;
  21280. /** @hidden */
  21281. private _internalMarkAllSubMeshesAsTexturesDirty;
  21282. private _internalMarkScenePrePassDirty;
  21283. /** @hidden */
  21284. _markAllSubMeshesAsTexturesDirty(): void;
  21285. /** @hidden */
  21286. _markScenePrePassDirty(): void;
  21287. /**
  21288. * Instantiate a new instance of sub surface configuration.
  21289. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  21290. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  21291. * @param scene The scene
  21292. */
  21293. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  21294. /**
  21295. * Gets whether the submesh is ready to be used or not.
  21296. * @param defines the list of "defines" to update.
  21297. * @param scene defines the scene the material belongs to.
  21298. * @returns - boolean indicating that the submesh is ready or not.
  21299. */
  21300. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  21301. /**
  21302. * Checks to see if a texture is used in the material.
  21303. * @param defines the list of "defines" to update.
  21304. * @param scene defines the scene to the material belongs to.
  21305. */
  21306. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  21307. /**
  21308. * Binds the material data.
  21309. * @param uniformBuffer defines the Uniform buffer to fill in.
  21310. * @param scene defines the scene the material belongs to.
  21311. * @param engine defines the engine the material belongs to.
  21312. * @param isFrozen defines whether the material is frozen or not.
  21313. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  21314. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  21315. */
  21316. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  21317. /**
  21318. * Unbinds the material from the mesh.
  21319. * @param activeEffect defines the effect that should be unbound from.
  21320. * @returns true if unbound, otherwise false
  21321. */
  21322. unbind(activeEffect: Effect): boolean;
  21323. /**
  21324. * Returns the texture used for refraction or null if none is used.
  21325. * @param scene defines the scene the material belongs to.
  21326. * @returns - Refraction texture if present. If no refraction texture and refraction
  21327. * is linked with transparency, returns environment texture. Otherwise, returns null.
  21328. */
  21329. private _getRefractionTexture;
  21330. /**
  21331. * Returns true if alpha blending should be disabled.
  21332. */
  21333. get disableAlphaBlending(): boolean;
  21334. /**
  21335. * Fills the list of render target textures.
  21336. * @param renderTargets the list of render targets to update
  21337. */
  21338. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  21339. /**
  21340. * Checks to see if a texture is used in the material.
  21341. * @param texture - Base texture to use.
  21342. * @returns - Boolean specifying if a texture is used in the material.
  21343. */
  21344. hasTexture(texture: BaseTexture): boolean;
  21345. /**
  21346. * Gets a boolean indicating that current material needs to register RTT
  21347. * @returns true if this uses a render target otherwise false.
  21348. */
  21349. hasRenderTargetTextures(): boolean;
  21350. /**
  21351. * Returns an array of the actively used textures.
  21352. * @param activeTextures Array of BaseTextures
  21353. */
  21354. getActiveTextures(activeTextures: BaseTexture[]): void;
  21355. /**
  21356. * Returns the animatable textures.
  21357. * @param animatables Array of animatable textures.
  21358. */
  21359. getAnimatables(animatables: IAnimatable[]): void;
  21360. /**
  21361. * Disposes the resources of the material.
  21362. * @param forceDisposeTextures - Forces the disposal of all textures.
  21363. */
  21364. dispose(forceDisposeTextures?: boolean): void;
  21365. /**
  21366. * Get the current class name of the texture useful for serialization or dynamic coding.
  21367. * @returns "PBRSubSurfaceConfiguration"
  21368. */
  21369. getClassName(): string;
  21370. /**
  21371. * Add fallbacks to the effect fallbacks list.
  21372. * @param defines defines the Base texture to use.
  21373. * @param fallbacks defines the current fallback list.
  21374. * @param currentRank defines the current fallback rank.
  21375. * @returns the new fallback rank.
  21376. */
  21377. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  21378. /**
  21379. * Add the required uniforms to the current list.
  21380. * @param uniforms defines the current uniform list.
  21381. */
  21382. static AddUniforms(uniforms: string[]): void;
  21383. /**
  21384. * Add the required samplers to the current list.
  21385. * @param samplers defines the current sampler list.
  21386. */
  21387. static AddSamplers(samplers: string[]): void;
  21388. /**
  21389. * Add the required uniforms to the current buffer.
  21390. * @param uniformBuffer defines the current uniform buffer.
  21391. */
  21392. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  21393. /**
  21394. * Makes a duplicate of the current configuration into another one.
  21395. * @param configuration define the config where to copy the info
  21396. */
  21397. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  21398. /**
  21399. * Serializes this Sub Surface configuration.
  21400. * @returns - An object with the serialized config.
  21401. */
  21402. serialize(): any;
  21403. /**
  21404. * Parses a anisotropy Configuration from a serialized object.
  21405. * @param source - Serialized object.
  21406. * @param scene Defines the scene we are parsing for
  21407. * @param rootUrl Defines the rootUrl to load from
  21408. */
  21409. parse(source: any, scene: Scene, rootUrl: string): void;
  21410. }
  21411. }
  21412. declare module BABYLON {
  21413. /**
  21414. * Class representing spherical harmonics coefficients to the 3rd degree
  21415. */
  21416. export class SphericalHarmonics {
  21417. /**
  21418. * Defines whether or not the harmonics have been prescaled for rendering.
  21419. */
  21420. preScaled: boolean;
  21421. /**
  21422. * The l0,0 coefficients of the spherical harmonics
  21423. */
  21424. l00: Vector3;
  21425. /**
  21426. * The l1,-1 coefficients of the spherical harmonics
  21427. */
  21428. l1_1: Vector3;
  21429. /**
  21430. * The l1,0 coefficients of the spherical harmonics
  21431. */
  21432. l10: Vector3;
  21433. /**
  21434. * The l1,1 coefficients of the spherical harmonics
  21435. */
  21436. l11: Vector3;
  21437. /**
  21438. * The l2,-2 coefficients of the spherical harmonics
  21439. */
  21440. l2_2: Vector3;
  21441. /**
  21442. * The l2,-1 coefficients of the spherical harmonics
  21443. */
  21444. l2_1: Vector3;
  21445. /**
  21446. * The l2,0 coefficients of the spherical harmonics
  21447. */
  21448. l20: Vector3;
  21449. /**
  21450. * The l2,1 coefficients of the spherical harmonics
  21451. */
  21452. l21: Vector3;
  21453. /**
  21454. * The l2,2 coefficients of the spherical harmonics
  21455. */
  21456. l22: Vector3;
  21457. /**
  21458. * Adds a light to the spherical harmonics
  21459. * @param direction the direction of the light
  21460. * @param color the color of the light
  21461. * @param deltaSolidAngle the delta solid angle of the light
  21462. */
  21463. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  21464. /**
  21465. * Scales the spherical harmonics by the given amount
  21466. * @param scale the amount to scale
  21467. */
  21468. scaleInPlace(scale: number): void;
  21469. /**
  21470. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  21471. *
  21472. * ```
  21473. * E_lm = A_l * L_lm
  21474. * ```
  21475. *
  21476. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  21477. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  21478. * the scaling factors are given in equation 9.
  21479. */
  21480. convertIncidentRadianceToIrradiance(): void;
  21481. /**
  21482. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  21483. *
  21484. * ```
  21485. * L = (1/pi) * E * rho
  21486. * ```
  21487. *
  21488. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  21489. */
  21490. convertIrradianceToLambertianRadiance(): void;
  21491. /**
  21492. * Integrates the reconstruction coefficients directly in to the SH preventing further
  21493. * required operations at run time.
  21494. *
  21495. * This is simply done by scaling back the SH with Ylm constants parameter.
  21496. * The trigonometric part being applied by the shader at run time.
  21497. */
  21498. preScaleForRendering(): void;
  21499. /**
  21500. * Constructs a spherical harmonics from an array.
  21501. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  21502. * @returns the spherical harmonics
  21503. */
  21504. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  21505. /**
  21506. * Gets the spherical harmonics from polynomial
  21507. * @param polynomial the spherical polynomial
  21508. * @returns the spherical harmonics
  21509. */
  21510. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  21511. }
  21512. /**
  21513. * Class representing spherical polynomial coefficients to the 3rd degree
  21514. */
  21515. export class SphericalPolynomial {
  21516. private _harmonics;
  21517. /**
  21518. * The spherical harmonics used to create the polynomials.
  21519. */
  21520. get preScaledHarmonics(): SphericalHarmonics;
  21521. /**
  21522. * The x coefficients of the spherical polynomial
  21523. */
  21524. x: Vector3;
  21525. /**
  21526. * The y coefficients of the spherical polynomial
  21527. */
  21528. y: Vector3;
  21529. /**
  21530. * The z coefficients of the spherical polynomial
  21531. */
  21532. z: Vector3;
  21533. /**
  21534. * The xx coefficients of the spherical polynomial
  21535. */
  21536. xx: Vector3;
  21537. /**
  21538. * The yy coefficients of the spherical polynomial
  21539. */
  21540. yy: Vector3;
  21541. /**
  21542. * The zz coefficients of the spherical polynomial
  21543. */
  21544. zz: Vector3;
  21545. /**
  21546. * The xy coefficients of the spherical polynomial
  21547. */
  21548. xy: Vector3;
  21549. /**
  21550. * The yz coefficients of the spherical polynomial
  21551. */
  21552. yz: Vector3;
  21553. /**
  21554. * The zx coefficients of the spherical polynomial
  21555. */
  21556. zx: Vector3;
  21557. /**
  21558. * Adds an ambient color to the spherical polynomial
  21559. * @param color the color to add
  21560. */
  21561. addAmbient(color: Color3): void;
  21562. /**
  21563. * Scales the spherical polynomial by the given amount
  21564. * @param scale the amount to scale
  21565. */
  21566. scaleInPlace(scale: number): void;
  21567. /**
  21568. * Gets the spherical polynomial from harmonics
  21569. * @param harmonics the spherical harmonics
  21570. * @returns the spherical polynomial
  21571. */
  21572. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  21573. /**
  21574. * Constructs a spherical polynomial from an array.
  21575. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  21576. * @returns the spherical polynomial
  21577. */
  21578. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  21579. }
  21580. }
  21581. declare module BABYLON {
  21582. /**
  21583. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  21584. */
  21585. export interface CubeMapInfo {
  21586. /**
  21587. * The pixel array for the front face.
  21588. * This is stored in format, left to right, up to down format.
  21589. */
  21590. front: Nullable<ArrayBufferView>;
  21591. /**
  21592. * The pixel array for the back face.
  21593. * This is stored in format, left to right, up to down format.
  21594. */
  21595. back: Nullable<ArrayBufferView>;
  21596. /**
  21597. * The pixel array for the left face.
  21598. * This is stored in format, left to right, up to down format.
  21599. */
  21600. left: Nullable<ArrayBufferView>;
  21601. /**
  21602. * The pixel array for the right face.
  21603. * This is stored in format, left to right, up to down format.
  21604. */
  21605. right: Nullable<ArrayBufferView>;
  21606. /**
  21607. * The pixel array for the up face.
  21608. * This is stored in format, left to right, up to down format.
  21609. */
  21610. up: Nullable<ArrayBufferView>;
  21611. /**
  21612. * The pixel array for the down face.
  21613. * This is stored in format, left to right, up to down format.
  21614. */
  21615. down: Nullable<ArrayBufferView>;
  21616. /**
  21617. * The size of the cubemap stored.
  21618. *
  21619. * Each faces will be size * size pixels.
  21620. */
  21621. size: number;
  21622. /**
  21623. * The format of the texture.
  21624. *
  21625. * RGBA, RGB.
  21626. */
  21627. format: number;
  21628. /**
  21629. * The type of the texture data.
  21630. *
  21631. * UNSIGNED_INT, FLOAT.
  21632. */
  21633. type: number;
  21634. /**
  21635. * Specifies whether the texture is in gamma space.
  21636. */
  21637. gammaSpace: boolean;
  21638. }
  21639. /**
  21640. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  21641. */
  21642. export class PanoramaToCubeMapTools {
  21643. private static FACE_LEFT;
  21644. private static FACE_RIGHT;
  21645. private static FACE_FRONT;
  21646. private static FACE_BACK;
  21647. private static FACE_DOWN;
  21648. private static FACE_UP;
  21649. /**
  21650. * Converts a panorama stored in RGB right to left up to down format into a cubemap (6 faces).
  21651. *
  21652. * @param float32Array The source data.
  21653. * @param inputWidth The width of the input panorama.
  21654. * @param inputHeight The height of the input panorama.
  21655. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  21656. * @return The cubemap data
  21657. */
  21658. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  21659. private static CreateCubemapTexture;
  21660. private static CalcProjectionSpherical;
  21661. }
  21662. }
  21663. declare module BABYLON {
  21664. /**
  21665. * Helper class dealing with the extraction of spherical polynomial dataArray
  21666. * from a cube map.
  21667. */
  21668. export class CubeMapToSphericalPolynomialTools {
  21669. private static FileFaces;
  21670. /**
  21671. * Converts a texture to the according Spherical Polynomial data.
  21672. * This extracts the first 3 orders only as they are the only one used in the lighting.
  21673. *
  21674. * @param texture The texture to extract the information from.
  21675. * @return The Spherical Polynomial data.
  21676. */
  21677. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<Promise<SphericalPolynomial>>;
  21678. /**
  21679. * Converts a cubemap to the according Spherical Polynomial data.
  21680. * This extracts the first 3 orders only as they are the only one used in the lighting.
  21681. *
  21682. * @param cubeInfo The Cube map to extract the information from.
  21683. * @return The Spherical Polynomial data.
  21684. */
  21685. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  21686. }
  21687. }
  21688. declare module BABYLON {
  21689. interface BaseTexture {
  21690. /**
  21691. * Get the polynomial representation of the texture data.
  21692. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  21693. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  21694. */
  21695. sphericalPolynomial: Nullable<SphericalPolynomial>;
  21696. }
  21697. }
  21698. declare module BABYLON {
  21699. /** @hidden */
  21700. export var pbrFragmentDeclaration: {
  21701. name: string;
  21702. shader: string;
  21703. };
  21704. }
  21705. declare module BABYLON {
  21706. /** @hidden */
  21707. export var pbrUboDeclaration: {
  21708. name: string;
  21709. shader: string;
  21710. };
  21711. }
  21712. declare module BABYLON {
  21713. /** @hidden */
  21714. export var pbrFragmentExtraDeclaration: {
  21715. name: string;
  21716. shader: string;
  21717. };
  21718. }
  21719. declare module BABYLON {
  21720. /** @hidden */
  21721. export var pbrFragmentSamplersDeclaration: {
  21722. name: string;
  21723. shader: string;
  21724. };
  21725. }
  21726. declare module BABYLON {
  21727. /** @hidden */
  21728. export var subSurfaceScatteringFunctions: {
  21729. name: string;
  21730. shader: string;
  21731. };
  21732. }
  21733. declare module BABYLON {
  21734. /** @hidden */
  21735. export var importanceSampling: {
  21736. name: string;
  21737. shader: string;
  21738. };
  21739. }
  21740. declare module BABYLON {
  21741. /** @hidden */
  21742. export var pbrHelperFunctions: {
  21743. name: string;
  21744. shader: string;
  21745. };
  21746. }
  21747. declare module BABYLON {
  21748. /** @hidden */
  21749. export var harmonicsFunctions: {
  21750. name: string;
  21751. shader: string;
  21752. };
  21753. }
  21754. declare module BABYLON {
  21755. /** @hidden */
  21756. export var pbrDirectLightingSetupFunctions: {
  21757. name: string;
  21758. shader: string;
  21759. };
  21760. }
  21761. declare module BABYLON {
  21762. /** @hidden */
  21763. export var pbrDirectLightingFalloffFunctions: {
  21764. name: string;
  21765. shader: string;
  21766. };
  21767. }
  21768. declare module BABYLON {
  21769. /** @hidden */
  21770. export var pbrBRDFFunctions: {
  21771. name: string;
  21772. shader: string;
  21773. };
  21774. }
  21775. declare module BABYLON {
  21776. /** @hidden */
  21777. export var hdrFilteringFunctions: {
  21778. name: string;
  21779. shader: string;
  21780. };
  21781. }
  21782. declare module BABYLON {
  21783. /** @hidden */
  21784. export var pbrDirectLightingFunctions: {
  21785. name: string;
  21786. shader: string;
  21787. };
  21788. }
  21789. declare module BABYLON {
  21790. /** @hidden */
  21791. export var pbrIBLFunctions: {
  21792. name: string;
  21793. shader: string;
  21794. };
  21795. }
  21796. declare module BABYLON {
  21797. /** @hidden */
  21798. export var pbrBlockAlbedoOpacity: {
  21799. name: string;
  21800. shader: string;
  21801. };
  21802. }
  21803. declare module BABYLON {
  21804. /** @hidden */
  21805. export var pbrBlockReflectivity: {
  21806. name: string;
  21807. shader: string;
  21808. };
  21809. }
  21810. declare module BABYLON {
  21811. /** @hidden */
  21812. export var pbrBlockAmbientOcclusion: {
  21813. name: string;
  21814. shader: string;
  21815. };
  21816. }
  21817. declare module BABYLON {
  21818. /** @hidden */
  21819. export var pbrBlockAlphaFresnel: {
  21820. name: string;
  21821. shader: string;
  21822. };
  21823. }
  21824. declare module BABYLON {
  21825. /** @hidden */
  21826. export var pbrBlockAnisotropic: {
  21827. name: string;
  21828. shader: string;
  21829. };
  21830. }
  21831. declare module BABYLON {
  21832. /** @hidden */
  21833. export var pbrBlockReflection: {
  21834. name: string;
  21835. shader: string;
  21836. };
  21837. }
  21838. declare module BABYLON {
  21839. /** @hidden */
  21840. export var pbrBlockSheen: {
  21841. name: string;
  21842. shader: string;
  21843. };
  21844. }
  21845. declare module BABYLON {
  21846. /** @hidden */
  21847. export var pbrBlockClearcoat: {
  21848. name: string;
  21849. shader: string;
  21850. };
  21851. }
  21852. declare module BABYLON {
  21853. /** @hidden */
  21854. export var pbrBlockSubSurface: {
  21855. name: string;
  21856. shader: string;
  21857. };
  21858. }
  21859. declare module BABYLON {
  21860. /** @hidden */
  21861. export var pbrBlockNormalGeometric: {
  21862. name: string;
  21863. shader: string;
  21864. };
  21865. }
  21866. declare module BABYLON {
  21867. /** @hidden */
  21868. export var pbrBlockNormalFinal: {
  21869. name: string;
  21870. shader: string;
  21871. };
  21872. }
  21873. declare module BABYLON {
  21874. /** @hidden */
  21875. export var pbrBlockLightmapInit: {
  21876. name: string;
  21877. shader: string;
  21878. };
  21879. }
  21880. declare module BABYLON {
  21881. /** @hidden */
  21882. export var pbrBlockGeometryInfo: {
  21883. name: string;
  21884. shader: string;
  21885. };
  21886. }
  21887. declare module BABYLON {
  21888. /** @hidden */
  21889. export var pbrBlockReflectance0: {
  21890. name: string;
  21891. shader: string;
  21892. };
  21893. }
  21894. declare module BABYLON {
  21895. /** @hidden */
  21896. export var pbrBlockReflectance: {
  21897. name: string;
  21898. shader: string;
  21899. };
  21900. }
  21901. declare module BABYLON {
  21902. /** @hidden */
  21903. export var pbrBlockDirectLighting: {
  21904. name: string;
  21905. shader: string;
  21906. };
  21907. }
  21908. declare module BABYLON {
  21909. /** @hidden */
  21910. export var pbrBlockFinalLitComponents: {
  21911. name: string;
  21912. shader: string;
  21913. };
  21914. }
  21915. declare module BABYLON {
  21916. /** @hidden */
  21917. export var pbrBlockFinalUnlitComponents: {
  21918. name: string;
  21919. shader: string;
  21920. };
  21921. }
  21922. declare module BABYLON {
  21923. /** @hidden */
  21924. export var pbrBlockFinalColorComposition: {
  21925. name: string;
  21926. shader: string;
  21927. };
  21928. }
  21929. declare module BABYLON {
  21930. /** @hidden */
  21931. export var pbrBlockImageProcessing: {
  21932. name: string;
  21933. shader: string;
  21934. };
  21935. }
  21936. declare module BABYLON {
  21937. /** @hidden */
  21938. export var pbrDebug: {
  21939. name: string;
  21940. shader: string;
  21941. };
  21942. }
  21943. declare module BABYLON {
  21944. /** @hidden */
  21945. export var pbrPixelShader: {
  21946. name: string;
  21947. shader: string;
  21948. };
  21949. }
  21950. declare module BABYLON {
  21951. /** @hidden */
  21952. export var pbrVertexDeclaration: {
  21953. name: string;
  21954. shader: string;
  21955. };
  21956. }
  21957. declare module BABYLON {
  21958. /** @hidden */
  21959. export var pbrVertexShader: {
  21960. name: string;
  21961. shader: string;
  21962. };
  21963. }
  21964. declare module BABYLON {
  21965. /**
  21966. * Manages the defines for the PBR Material.
  21967. * @hidden
  21968. */
  21969. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  21970. PBR: boolean;
  21971. NUM_SAMPLES: string;
  21972. REALTIME_FILTERING: boolean;
  21973. MAINUV1: boolean;
  21974. MAINUV2: boolean;
  21975. UV1: boolean;
  21976. UV2: boolean;
  21977. ALBEDO: boolean;
  21978. GAMMAALBEDO: boolean;
  21979. ALBEDODIRECTUV: number;
  21980. VERTEXCOLOR: boolean;
  21981. DETAIL: boolean;
  21982. DETAILDIRECTUV: number;
  21983. DETAIL_NORMALBLENDMETHOD: number;
  21984. AMBIENT: boolean;
  21985. AMBIENTDIRECTUV: number;
  21986. AMBIENTINGRAYSCALE: boolean;
  21987. OPACITY: boolean;
  21988. VERTEXALPHA: boolean;
  21989. OPACITYDIRECTUV: number;
  21990. OPACITYRGB: boolean;
  21991. ALPHATEST: boolean;
  21992. DEPTHPREPASS: boolean;
  21993. ALPHABLEND: boolean;
  21994. ALPHAFROMALBEDO: boolean;
  21995. ALPHATESTVALUE: string;
  21996. SPECULAROVERALPHA: boolean;
  21997. RADIANCEOVERALPHA: boolean;
  21998. ALPHAFRESNEL: boolean;
  21999. LINEARALPHAFRESNEL: boolean;
  22000. PREMULTIPLYALPHA: boolean;
  22001. EMISSIVE: boolean;
  22002. EMISSIVEDIRECTUV: number;
  22003. REFLECTIVITY: boolean;
  22004. REFLECTIVITYDIRECTUV: number;
  22005. SPECULARTERM: boolean;
  22006. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  22007. MICROSURFACEAUTOMATIC: boolean;
  22008. LODBASEDMICROSFURACE: boolean;
  22009. MICROSURFACEMAP: boolean;
  22010. MICROSURFACEMAPDIRECTUV: number;
  22011. METALLICWORKFLOW: boolean;
  22012. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  22013. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  22014. METALLNESSSTOREINMETALMAPBLUE: boolean;
  22015. AOSTOREINMETALMAPRED: boolean;
  22016. METALLIC_REFLECTANCE: boolean;
  22017. METALLIC_REFLECTANCEDIRECTUV: number;
  22018. ENVIRONMENTBRDF: boolean;
  22019. ENVIRONMENTBRDF_RGBD: boolean;
  22020. NORMAL: boolean;
  22021. TANGENT: boolean;
  22022. BUMP: boolean;
  22023. BUMPDIRECTUV: number;
  22024. OBJECTSPACE_NORMALMAP: boolean;
  22025. PARALLAX: boolean;
  22026. PARALLAXOCCLUSION: boolean;
  22027. NORMALXYSCALE: boolean;
  22028. LIGHTMAP: boolean;
  22029. LIGHTMAPDIRECTUV: number;
  22030. USELIGHTMAPASSHADOWMAP: boolean;
  22031. GAMMALIGHTMAP: boolean;
  22032. RGBDLIGHTMAP: boolean;
  22033. REFLECTION: boolean;
  22034. REFLECTIONMAP_3D: boolean;
  22035. REFLECTIONMAP_SPHERICAL: boolean;
  22036. REFLECTIONMAP_PLANAR: boolean;
  22037. REFLECTIONMAP_CUBIC: boolean;
  22038. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  22039. REFLECTIONMAP_PROJECTION: boolean;
  22040. REFLECTIONMAP_SKYBOX: boolean;
  22041. REFLECTIONMAP_EXPLICIT: boolean;
  22042. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  22043. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  22044. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  22045. INVERTCUBICMAP: boolean;
  22046. USESPHERICALFROMREFLECTIONMAP: boolean;
  22047. USEIRRADIANCEMAP: boolean;
  22048. SPHERICAL_HARMONICS: boolean;
  22049. USESPHERICALINVERTEX: boolean;
  22050. REFLECTIONMAP_OPPOSITEZ: boolean;
  22051. LODINREFLECTIONALPHA: boolean;
  22052. GAMMAREFLECTION: boolean;
  22053. RGBDREFLECTION: boolean;
  22054. LINEARSPECULARREFLECTION: boolean;
  22055. RADIANCEOCCLUSION: boolean;
  22056. HORIZONOCCLUSION: boolean;
  22057. INSTANCES: boolean;
  22058. THIN_INSTANCES: boolean;
  22059. PREPASS: boolean;
  22060. PREPASS_IRRADIANCE: boolean;
  22061. PREPASS_IRRADIANCE_INDEX: number;
  22062. PREPASS_ALBEDO: boolean;
  22063. PREPASS_ALBEDO_INDEX: number;
  22064. PREPASS_DEPTH: boolean;
  22065. PREPASS_DEPTH_INDEX: number;
  22066. PREPASS_NORMAL: boolean;
  22067. PREPASS_NORMAL_INDEX: number;
  22068. PREPASS_POSITION: boolean;
  22069. PREPASS_POSITION_INDEX: number;
  22070. PREPASS_VELOCITY: boolean;
  22071. PREPASS_VELOCITY_INDEX: number;
  22072. PREPASS_REFLECTIVITY: boolean;
  22073. PREPASS_REFLECTIVITY_INDEX: number;
  22074. SCENE_MRT_COUNT: number;
  22075. NUM_BONE_INFLUENCERS: number;
  22076. BonesPerMesh: number;
  22077. BONETEXTURE: boolean;
  22078. BONES_VELOCITY_ENABLED: boolean;
  22079. NONUNIFORMSCALING: boolean;
  22080. MORPHTARGETS: boolean;
  22081. MORPHTARGETS_NORMAL: boolean;
  22082. MORPHTARGETS_TANGENT: boolean;
  22083. MORPHTARGETS_UV: boolean;
  22084. NUM_MORPH_INFLUENCERS: number;
  22085. MORPHTARGETS_TEXTURE: boolean;
  22086. IMAGEPROCESSING: boolean;
  22087. VIGNETTE: boolean;
  22088. VIGNETTEBLENDMODEMULTIPLY: boolean;
  22089. VIGNETTEBLENDMODEOPAQUE: boolean;
  22090. TONEMAPPING: boolean;
  22091. TONEMAPPING_ACES: boolean;
  22092. CONTRAST: boolean;
  22093. COLORCURVES: boolean;
  22094. COLORGRADING: boolean;
  22095. COLORGRADING3D: boolean;
  22096. SAMPLER3DGREENDEPTH: boolean;
  22097. SAMPLER3DBGRMAP: boolean;
  22098. IMAGEPROCESSINGPOSTPROCESS: boolean;
  22099. EXPOSURE: boolean;
  22100. MULTIVIEW: boolean;
  22101. USEPHYSICALLIGHTFALLOFF: boolean;
  22102. USEGLTFLIGHTFALLOFF: boolean;
  22103. TWOSIDEDLIGHTING: boolean;
  22104. SHADOWFLOAT: boolean;
  22105. CLIPPLANE: boolean;
  22106. CLIPPLANE2: boolean;
  22107. CLIPPLANE3: boolean;
  22108. CLIPPLANE4: boolean;
  22109. CLIPPLANE5: boolean;
  22110. CLIPPLANE6: boolean;
  22111. POINTSIZE: boolean;
  22112. FOG: boolean;
  22113. LOGARITHMICDEPTH: boolean;
  22114. FORCENORMALFORWARD: boolean;
  22115. SPECULARAA: boolean;
  22116. CLEARCOAT: boolean;
  22117. CLEARCOAT_DEFAULTIOR: boolean;
  22118. CLEARCOAT_TEXTURE: boolean;
  22119. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  22120. CLEARCOAT_TEXTUREDIRECTUV: number;
  22121. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  22122. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  22123. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  22124. CLEARCOAT_BUMP: boolean;
  22125. CLEARCOAT_BUMPDIRECTUV: number;
  22126. CLEARCOAT_REMAP_F0: boolean;
  22127. CLEARCOAT_TINT: boolean;
  22128. CLEARCOAT_TINT_TEXTURE: boolean;
  22129. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  22130. ANISOTROPIC: boolean;
  22131. ANISOTROPIC_TEXTURE: boolean;
  22132. ANISOTROPIC_TEXTUREDIRECTUV: number;
  22133. BRDF_V_HEIGHT_CORRELATED: boolean;
  22134. MS_BRDF_ENERGY_CONSERVATION: boolean;
  22135. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  22136. SHEEN: boolean;
  22137. SHEEN_TEXTURE: boolean;
  22138. SHEEN_TEXTURE_ROUGHNESS: boolean;
  22139. SHEEN_TEXTUREDIRECTUV: number;
  22140. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  22141. SHEEN_LINKWITHALBEDO: boolean;
  22142. SHEEN_ROUGHNESS: boolean;
  22143. SHEEN_ALBEDOSCALING: boolean;
  22144. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  22145. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  22146. SUBSURFACE: boolean;
  22147. SS_REFRACTION: boolean;
  22148. SS_TRANSLUCENCY: boolean;
  22149. SS_SCATTERING: boolean;
  22150. SS_THICKNESSANDMASK_TEXTURE: boolean;
  22151. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  22152. SS_REFRACTIONMAP_3D: boolean;
  22153. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  22154. SS_LODINREFRACTIONALPHA: boolean;
  22155. SS_GAMMAREFRACTION: boolean;
  22156. SS_RGBDREFRACTION: boolean;
  22157. SS_LINEARSPECULARREFRACTION: boolean;
  22158. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  22159. SS_ALBEDOFORREFRACTIONTINT: boolean;
  22160. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  22161. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  22162. UNLIT: boolean;
  22163. DEBUGMODE: number;
  22164. /**
  22165. * Initializes the PBR Material defines.
  22166. */
  22167. constructor();
  22168. /**
  22169. * Resets the PBR Material defines.
  22170. */
  22171. reset(): void;
  22172. }
  22173. /**
  22174. * The Physically based material base class of BJS.
  22175. *
  22176. * This offers the main features of a standard PBR material.
  22177. * For more information, please refer to the documentation :
  22178. * https://doc.babylonjs.com/how_to/physically_based_rendering
  22179. */
  22180. export abstract class PBRBaseMaterial extends PushMaterial {
  22181. /**
  22182. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  22183. */
  22184. static readonly PBRMATERIAL_OPAQUE: number;
  22185. /**
  22186. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  22187. */
  22188. static readonly PBRMATERIAL_ALPHATEST: number;
  22189. /**
  22190. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  22191. */
  22192. static readonly PBRMATERIAL_ALPHABLEND: number;
  22193. /**
  22194. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  22195. * They are also discarded below the alpha cutoff threshold to improve performances.
  22196. */
  22197. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  22198. /**
  22199. * Defines the default value of how much AO map is occluding the analytical lights
  22200. * (point spot...).
  22201. */
  22202. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  22203. /**
  22204. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  22205. */
  22206. static readonly LIGHTFALLOFF_PHYSICAL: number;
  22207. /**
  22208. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  22209. * to enhance interoperability with other engines.
  22210. */
  22211. static readonly LIGHTFALLOFF_GLTF: number;
  22212. /**
  22213. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  22214. * to enhance interoperability with other materials.
  22215. */
  22216. static readonly LIGHTFALLOFF_STANDARD: number;
  22217. /**
  22218. * Intensity of the direct lights e.g. the four lights available in your scene.
  22219. * This impacts both the direct diffuse and specular highlights.
  22220. */
  22221. protected _directIntensity: number;
  22222. /**
  22223. * Intensity of the emissive part of the material.
  22224. * This helps controlling the emissive effect without modifying the emissive color.
  22225. */
  22226. protected _emissiveIntensity: number;
  22227. /**
  22228. * Intensity of the environment e.g. how much the environment will light the object
  22229. * either through harmonics for rough material or through the reflection for shiny ones.
  22230. */
  22231. protected _environmentIntensity: number;
  22232. /**
  22233. * This is a special control allowing the reduction of the specular highlights coming from the
  22234. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  22235. */
  22236. protected _specularIntensity: number;
  22237. /**
  22238. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  22239. */
  22240. private _lightingInfos;
  22241. /**
  22242. * Debug Control allowing disabling the bump map on this material.
  22243. */
  22244. protected _disableBumpMap: boolean;
  22245. /**
  22246. * AKA Diffuse Texture in standard nomenclature.
  22247. */
  22248. protected _albedoTexture: Nullable<BaseTexture>;
  22249. /**
  22250. * AKA Occlusion Texture in other nomenclature.
  22251. */
  22252. protected _ambientTexture: Nullable<BaseTexture>;
  22253. /**
  22254. * AKA Occlusion Texture Intensity in other nomenclature.
  22255. */
  22256. protected _ambientTextureStrength: number;
  22257. /**
  22258. * Defines how much the AO map is occluding the analytical lights (point spot...).
  22259. * 1 means it completely occludes it
  22260. * 0 mean it has no impact
  22261. */
  22262. protected _ambientTextureImpactOnAnalyticalLights: number;
  22263. /**
  22264. * Stores the alpha values in a texture.
  22265. */
  22266. protected _opacityTexture: Nullable<BaseTexture>;
  22267. /**
  22268. * Stores the reflection values in a texture.
  22269. */
  22270. protected _reflectionTexture: Nullable<BaseTexture>;
  22271. /**
  22272. * Stores the emissive values in a texture.
  22273. */
  22274. protected _emissiveTexture: Nullable<BaseTexture>;
  22275. /**
  22276. * AKA Specular texture in other nomenclature.
  22277. */
  22278. protected _reflectivityTexture: Nullable<BaseTexture>;
  22279. /**
  22280. * Used to switch from specular/glossiness to metallic/roughness workflow.
  22281. */
  22282. protected _metallicTexture: Nullable<BaseTexture>;
  22283. /**
  22284. * Specifies the metallic scalar of the metallic/roughness workflow.
  22285. * Can also be used to scale the metalness values of the metallic texture.
  22286. */
  22287. protected _metallic: Nullable<number>;
  22288. /**
  22289. * Specifies the roughness scalar of the metallic/roughness workflow.
  22290. * Can also be used to scale the roughness values of the metallic texture.
  22291. */
  22292. protected _roughness: Nullable<number>;
  22293. /**
  22294. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  22295. * By default the indexOfrefraction is used to compute F0;
  22296. *
  22297. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  22298. *
  22299. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  22300. * F90 = metallicReflectanceColor;
  22301. */
  22302. protected _metallicF0Factor: number;
  22303. /**
  22304. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  22305. * By default the F90 is always 1;
  22306. *
  22307. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  22308. *
  22309. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  22310. * F90 = metallicReflectanceColor;
  22311. */
  22312. protected _metallicReflectanceColor: Color3;
  22313. /**
  22314. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  22315. * This is multiply against the scalar values defined in the material.
  22316. */
  22317. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  22318. /**
  22319. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  22320. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  22321. */
  22322. protected _microSurfaceTexture: Nullable<BaseTexture>;
  22323. /**
  22324. * Stores surface normal data used to displace a mesh in a texture.
  22325. */
  22326. protected _bumpTexture: Nullable<BaseTexture>;
  22327. /**
  22328. * Stores the pre-calculated light information of a mesh in a texture.
  22329. */
  22330. protected _lightmapTexture: Nullable<BaseTexture>;
  22331. /**
  22332. * The color of a material in ambient lighting.
  22333. */
  22334. protected _ambientColor: Color3;
  22335. /**
  22336. * AKA Diffuse Color in other nomenclature.
  22337. */
  22338. protected _albedoColor: Color3;
  22339. /**
  22340. * AKA Specular Color in other nomenclature.
  22341. */
  22342. protected _reflectivityColor: Color3;
  22343. /**
  22344. * The color applied when light is reflected from a material.
  22345. */
  22346. protected _reflectionColor: Color3;
  22347. /**
  22348. * The color applied when light is emitted from a material.
  22349. */
  22350. protected _emissiveColor: Color3;
  22351. /**
  22352. * AKA Glossiness in other nomenclature.
  22353. */
  22354. protected _microSurface: number;
  22355. /**
  22356. * Specifies that the material will use the light map as a show map.
  22357. */
  22358. protected _useLightmapAsShadowmap: boolean;
  22359. /**
  22360. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  22361. * makes the reflect vector face the model (under horizon).
  22362. */
  22363. protected _useHorizonOcclusion: boolean;
  22364. /**
  22365. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  22366. * too much the area relying on ambient texture to define their ambient occlusion.
  22367. */
  22368. protected _useRadianceOcclusion: boolean;
  22369. /**
  22370. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  22371. */
  22372. protected _useAlphaFromAlbedoTexture: boolean;
  22373. /**
  22374. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  22375. * A car glass is a good example of that. When sun reflects on it you can not see what is behind.
  22376. */
  22377. protected _useSpecularOverAlpha: boolean;
  22378. /**
  22379. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  22380. */
  22381. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  22382. /**
  22383. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  22384. */
  22385. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  22386. /**
  22387. * Specifies if the metallic texture contains the roughness information in its green channel.
  22388. */
  22389. protected _useRoughnessFromMetallicTextureGreen: boolean;
  22390. /**
  22391. * Specifies if the metallic texture contains the metallness information in its blue channel.
  22392. */
  22393. protected _useMetallnessFromMetallicTextureBlue: boolean;
  22394. /**
  22395. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  22396. */
  22397. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  22398. /**
  22399. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  22400. */
  22401. protected _useAmbientInGrayScale: boolean;
  22402. /**
  22403. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  22404. * The material will try to infer what glossiness each pixel should be.
  22405. */
  22406. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  22407. /**
  22408. * Defines the falloff type used in this material.
  22409. * It by default is Physical.
  22410. */
  22411. protected _lightFalloff: number;
  22412. /**
  22413. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  22414. * A car glass is a good example of that. When the street lights reflects on it you can not see what is behind.
  22415. */
  22416. protected _useRadianceOverAlpha: boolean;
  22417. /**
  22418. * Allows using an object space normal map (instead of tangent space).
  22419. */
  22420. protected _useObjectSpaceNormalMap: boolean;
  22421. /**
  22422. * Allows using the bump map in parallax mode.
  22423. */
  22424. protected _useParallax: boolean;
  22425. /**
  22426. * Allows using the bump map in parallax occlusion mode.
  22427. */
  22428. protected _useParallaxOcclusion: boolean;
  22429. /**
  22430. * Controls the scale bias of the parallax mode.
  22431. */
  22432. protected _parallaxScaleBias: number;
  22433. /**
  22434. * If sets to true, disables all the lights affecting the material.
  22435. */
  22436. protected _disableLighting: boolean;
  22437. /**
  22438. * Number of Simultaneous lights allowed on the material.
  22439. */
  22440. protected _maxSimultaneousLights: number;
  22441. /**
  22442. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  22443. */
  22444. protected _invertNormalMapX: boolean;
  22445. /**
  22446. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  22447. */
  22448. protected _invertNormalMapY: boolean;
  22449. /**
  22450. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  22451. */
  22452. protected _twoSidedLighting: boolean;
  22453. /**
  22454. * Defines the alpha limits in alpha test mode.
  22455. */
  22456. protected _alphaCutOff: number;
  22457. /**
  22458. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  22459. */
  22460. protected _forceAlphaTest: boolean;
  22461. /**
  22462. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22463. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  22464. */
  22465. protected _useAlphaFresnel: boolean;
  22466. /**
  22467. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22468. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  22469. */
  22470. protected _useLinearAlphaFresnel: boolean;
  22471. /**
  22472. * Specifies the environment BRDF texture used to compute the scale and offset roughness values
  22473. * from cos theta and roughness:
  22474. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  22475. */
  22476. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  22477. /**
  22478. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  22479. */
  22480. protected _forceIrradianceInFragment: boolean;
  22481. private _realTimeFiltering;
  22482. /**
  22483. * Enables realtime filtering on the texture.
  22484. */
  22485. get realTimeFiltering(): boolean;
  22486. set realTimeFiltering(b: boolean);
  22487. private _realTimeFilteringQuality;
  22488. /**
  22489. * Quality switch for realtime filtering
  22490. */
  22491. get realTimeFilteringQuality(): number;
  22492. set realTimeFilteringQuality(n: number);
  22493. /**
  22494. * Can this material render to several textures at once
  22495. */
  22496. get canRenderToMRT(): boolean;
  22497. /**
  22498. * Force normal to face away from face.
  22499. */
  22500. protected _forceNormalForward: boolean;
  22501. /**
  22502. * Enables specular anti aliasing in the PBR shader.
  22503. * It will both interacts on the Geometry for analytical and IBL lighting.
  22504. * It also prefilter the roughness map based on the bump values.
  22505. */
  22506. protected _enableSpecularAntiAliasing: boolean;
  22507. /**
  22508. * Default configuration related to image processing available in the PBR Material.
  22509. */
  22510. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22511. /**
  22512. * Keep track of the image processing observer to allow dispose and replace.
  22513. */
  22514. private _imageProcessingObserver;
  22515. /**
  22516. * Attaches a new image processing configuration to the PBR Material.
  22517. * @param configuration
  22518. */
  22519. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22520. /**
  22521. * Stores the available render targets.
  22522. */
  22523. private _renderTargets;
  22524. /**
  22525. * Sets the global ambient color for the material used in lighting calculations.
  22526. */
  22527. private _globalAmbientColor;
  22528. /**
  22529. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  22530. */
  22531. private _useLogarithmicDepth;
  22532. /**
  22533. * If set to true, no lighting calculations will be applied.
  22534. */
  22535. private _unlit;
  22536. private _debugMode;
  22537. /**
  22538. * @hidden
  22539. * This is reserved for the inspector.
  22540. * Defines the material debug mode.
  22541. * It helps seeing only some components of the material while troubleshooting.
  22542. */
  22543. debugMode: number;
  22544. /**
  22545. * @hidden
  22546. * This is reserved for the inspector.
  22547. * Specify from where on screen the debug mode should start.
  22548. * The value goes from -1 (full screen) to 1 (not visible)
  22549. * It helps with side by side comparison against the final render
  22550. * This defaults to -1
  22551. */
  22552. private debugLimit;
  22553. /**
  22554. * @hidden
  22555. * This is reserved for the inspector.
  22556. * As the default viewing range might not be enough (if the ambient is really small for instance)
  22557. * You can use the factor to better multiply the final value.
  22558. */
  22559. private debugFactor;
  22560. /**
  22561. * Defines the clear coat layer parameters for the material.
  22562. */
  22563. readonly clearCoat: PBRClearCoatConfiguration;
  22564. /**
  22565. * Defines the anisotropic parameters for the material.
  22566. */
  22567. readonly anisotropy: PBRAnisotropicConfiguration;
  22568. /**
  22569. * Defines the BRDF parameters for the material.
  22570. */
  22571. readonly brdf: PBRBRDFConfiguration;
  22572. /**
  22573. * Defines the Sheen parameters for the material.
  22574. */
  22575. readonly sheen: PBRSheenConfiguration;
  22576. /**
  22577. * Defines the SubSurface parameters for the material.
  22578. */
  22579. readonly subSurface: PBRSubSurfaceConfiguration;
  22580. /**
  22581. * Defines additional PrePass parameters for the material.
  22582. */
  22583. readonly prePassConfiguration: PrePassConfiguration;
  22584. /**
  22585. * Defines the detail map parameters for the material.
  22586. */
  22587. readonly detailMap: DetailMapConfiguration;
  22588. protected _rebuildInParallel: boolean;
  22589. /**
  22590. * Instantiates a new PBRMaterial instance.
  22591. *
  22592. * @param name The material name
  22593. * @param scene The scene the material will be use in.
  22594. */
  22595. constructor(name: string, scene: Scene);
  22596. /**
  22597. * Gets a boolean indicating that current material needs to register RTT
  22598. */
  22599. get hasRenderTargetTextures(): boolean;
  22600. /**
  22601. * Can this material render to prepass
  22602. */
  22603. get isPrePassCapable(): boolean;
  22604. /**
  22605. * Gets the name of the material class.
  22606. */
  22607. getClassName(): string;
  22608. /**
  22609. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  22610. */
  22611. get useLogarithmicDepth(): boolean;
  22612. /**
  22613. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  22614. */
  22615. set useLogarithmicDepth(value: boolean);
  22616. /**
  22617. * Returns true if alpha blending should be disabled.
  22618. */
  22619. protected get _disableAlphaBlending(): boolean;
  22620. /**
  22621. * Specifies whether or not this material should be rendered in alpha blend mode.
  22622. */
  22623. needAlphaBlending(): boolean;
  22624. /**
  22625. * Specifies whether or not this material should be rendered in alpha test mode.
  22626. */
  22627. needAlphaTesting(): boolean;
  22628. /**
  22629. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  22630. */
  22631. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  22632. /**
  22633. * Specifies whether or not there is a usable alpha channel for transparency.
  22634. */
  22635. protected _hasAlphaChannel(): boolean;
  22636. /**
  22637. * Gets the texture used for the alpha test.
  22638. */
  22639. getAlphaTestTexture(): Nullable<BaseTexture>;
  22640. /**
  22641. * Specifies that the submesh is ready to be used.
  22642. * @param mesh - BJS mesh.
  22643. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  22644. * @param useInstances - Specifies that instances should be used.
  22645. * @returns - boolean indicating that the submesh is ready or not.
  22646. */
  22647. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22648. /**
  22649. * Specifies if the material uses metallic roughness workflow.
  22650. * @returns boolean specifying if the material uses metallic roughness workflow.
  22651. */
  22652. isMetallicWorkflow(): boolean;
  22653. private _prepareEffect;
  22654. private _prepareDefines;
  22655. /**
  22656. * Force shader compilation
  22657. */
  22658. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  22659. /**
  22660. * Initializes the uniform buffer layout for the shader.
  22661. */
  22662. buildUniformLayout(): void;
  22663. /**
  22664. * Unbinds the material from the mesh
  22665. */
  22666. unbind(): void;
  22667. /**
  22668. * Binds the submesh data.
  22669. * @param world - The world matrix.
  22670. * @param mesh - The BJS mesh.
  22671. * @param subMesh - A submesh of the BJS mesh.
  22672. */
  22673. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22674. /**
  22675. * Returns the animatable textures.
  22676. * @returns - Array of animatable textures.
  22677. */
  22678. getAnimatables(): IAnimatable[];
  22679. /**
  22680. * Returns the texture used for reflections.
  22681. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  22682. */
  22683. private _getReflectionTexture;
  22684. /**
  22685. * Returns an array of the actively used textures.
  22686. * @returns - Array of BaseTextures
  22687. */
  22688. getActiveTextures(): BaseTexture[];
  22689. /**
  22690. * Checks to see if a texture is used in the material.
  22691. * @param texture - Base texture to use.
  22692. * @returns - Boolean specifying if a texture is used in the material.
  22693. */
  22694. hasTexture(texture: BaseTexture): boolean;
  22695. /**
  22696. * Sets the required values to the prepass renderer.
  22697. * @param prePassRenderer defines the prepass renderer to setup
  22698. */
  22699. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  22700. /**
  22701. * Disposes the resources of the material.
  22702. * @param forceDisposeEffect - Forces the disposal of effects.
  22703. * @param forceDisposeTextures - Forces the disposal of all textures.
  22704. */
  22705. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  22706. }
  22707. }
  22708. declare module BABYLON {
  22709. /**
  22710. * The Physically based material of BJS.
  22711. *
  22712. * This offers the main features of a standard PBR material.
  22713. * For more information, please refer to the documentation :
  22714. * https://doc.babylonjs.com/how_to/physically_based_rendering
  22715. */
  22716. export class PBRMaterial extends PBRBaseMaterial {
  22717. /**
  22718. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  22719. */
  22720. static readonly PBRMATERIAL_OPAQUE: number;
  22721. /**
  22722. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  22723. */
  22724. static readonly PBRMATERIAL_ALPHATEST: number;
  22725. /**
  22726. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  22727. */
  22728. static readonly PBRMATERIAL_ALPHABLEND: number;
  22729. /**
  22730. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  22731. * They are also discarded below the alpha cutoff threshold to improve performances.
  22732. */
  22733. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  22734. /**
  22735. * Defines the default value of how much AO map is occluding the analytical lights
  22736. * (point spot...).
  22737. */
  22738. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  22739. /**
  22740. * Intensity of the direct lights e.g. the four lights available in your scene.
  22741. * This impacts both the direct diffuse and specular highlights.
  22742. */
  22743. directIntensity: number;
  22744. /**
  22745. * Intensity of the emissive part of the material.
  22746. * This helps controlling the emissive effect without modifying the emissive color.
  22747. */
  22748. emissiveIntensity: number;
  22749. /**
  22750. * Intensity of the environment e.g. how much the environment will light the object
  22751. * either through harmonics for rough material or through the reflection for shiny ones.
  22752. */
  22753. environmentIntensity: number;
  22754. /**
  22755. * This is a special control allowing the reduction of the specular highlights coming from the
  22756. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  22757. */
  22758. specularIntensity: number;
  22759. /**
  22760. * Debug Control allowing disabling the bump map on this material.
  22761. */
  22762. disableBumpMap: boolean;
  22763. /**
  22764. * AKA Diffuse Texture in standard nomenclature.
  22765. */
  22766. albedoTexture: BaseTexture;
  22767. /**
  22768. * AKA Occlusion Texture in other nomenclature.
  22769. */
  22770. ambientTexture: BaseTexture;
  22771. /**
  22772. * AKA Occlusion Texture Intensity in other nomenclature.
  22773. */
  22774. ambientTextureStrength: number;
  22775. /**
  22776. * Defines how much the AO map is occluding the analytical lights (point spot...).
  22777. * 1 means it completely occludes it
  22778. * 0 mean it has no impact
  22779. */
  22780. ambientTextureImpactOnAnalyticalLights: number;
  22781. /**
  22782. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  22783. */
  22784. opacityTexture: BaseTexture;
  22785. /**
  22786. * Stores the reflection values in a texture.
  22787. */
  22788. reflectionTexture: Nullable<BaseTexture>;
  22789. /**
  22790. * Stores the emissive values in a texture.
  22791. */
  22792. emissiveTexture: BaseTexture;
  22793. /**
  22794. * AKA Specular texture in other nomenclature.
  22795. */
  22796. reflectivityTexture: BaseTexture;
  22797. /**
  22798. * Used to switch from specular/glossiness to metallic/roughness workflow.
  22799. */
  22800. metallicTexture: BaseTexture;
  22801. /**
  22802. * Specifies the metallic scalar of the metallic/roughness workflow.
  22803. * Can also be used to scale the metalness values of the metallic texture.
  22804. */
  22805. metallic: Nullable<number>;
  22806. /**
  22807. * Specifies the roughness scalar of the metallic/roughness workflow.
  22808. * Can also be used to scale the roughness values of the metallic texture.
  22809. */
  22810. roughness: Nullable<number>;
  22811. /**
  22812. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  22813. * By default the indexOfrefraction is used to compute F0;
  22814. *
  22815. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  22816. *
  22817. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  22818. * F90 = metallicReflectanceColor;
  22819. */
  22820. metallicF0Factor: number;
  22821. /**
  22822. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  22823. * By default the F90 is always 1;
  22824. *
  22825. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  22826. *
  22827. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  22828. * F90 = metallicReflectanceColor;
  22829. */
  22830. metallicReflectanceColor: Color3;
  22831. /**
  22832. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  22833. * This is multiply against the scalar values defined in the material.
  22834. */
  22835. metallicReflectanceTexture: Nullable<BaseTexture>;
  22836. /**
  22837. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  22838. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  22839. */
  22840. microSurfaceTexture: BaseTexture;
  22841. /**
  22842. * Stores surface normal data used to displace a mesh in a texture.
  22843. */
  22844. bumpTexture: BaseTexture;
  22845. /**
  22846. * Stores the pre-calculated light information of a mesh in a texture.
  22847. */
  22848. lightmapTexture: BaseTexture;
  22849. /**
  22850. * Stores the refracted light information in a texture.
  22851. */
  22852. get refractionTexture(): Nullable<BaseTexture>;
  22853. set refractionTexture(value: Nullable<BaseTexture>);
  22854. /**
  22855. * The color of a material in ambient lighting.
  22856. */
  22857. ambientColor: Color3;
  22858. /**
  22859. * AKA Diffuse Color in other nomenclature.
  22860. */
  22861. albedoColor: Color3;
  22862. /**
  22863. * AKA Specular Color in other nomenclature.
  22864. */
  22865. reflectivityColor: Color3;
  22866. /**
  22867. * The color reflected from the material.
  22868. */
  22869. reflectionColor: Color3;
  22870. /**
  22871. * The color emitted from the material.
  22872. */
  22873. emissiveColor: Color3;
  22874. /**
  22875. * AKA Glossiness in other nomenclature.
  22876. */
  22877. microSurface: number;
  22878. /**
  22879. * Index of refraction of the material base layer.
  22880. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  22881. *
  22882. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  22883. *
  22884. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  22885. */
  22886. get indexOfRefraction(): number;
  22887. set indexOfRefraction(value: number);
  22888. /**
  22889. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  22890. */
  22891. get invertRefractionY(): boolean;
  22892. set invertRefractionY(value: boolean);
  22893. /**
  22894. * This parameters will make the material used its opacity to control how much it is refracting against not.
  22895. * Materials half opaque for instance using refraction could benefit from this control.
  22896. */
  22897. get linkRefractionWithTransparency(): boolean;
  22898. set linkRefractionWithTransparency(value: boolean);
  22899. /**
  22900. * If true, the light map contains occlusion information instead of lighting info.
  22901. */
  22902. useLightmapAsShadowmap: boolean;
  22903. /**
  22904. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  22905. */
  22906. useAlphaFromAlbedoTexture: boolean;
  22907. /**
  22908. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  22909. */
  22910. forceAlphaTest: boolean;
  22911. /**
  22912. * Defines the alpha limits in alpha test mode.
  22913. */
  22914. alphaCutOff: number;
  22915. /**
  22916. * Specifies that the material will keep the specular highlights over a transparent surface (only the most luminous ones).
  22917. * A car glass is a good example of that. When sun reflects on it you can not see what is behind.
  22918. */
  22919. useSpecularOverAlpha: boolean;
  22920. /**
  22921. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  22922. */
  22923. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  22924. /**
  22925. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  22926. */
  22927. useRoughnessFromMetallicTextureAlpha: boolean;
  22928. /**
  22929. * Specifies if the metallic texture contains the roughness information in its green channel.
  22930. */
  22931. useRoughnessFromMetallicTextureGreen: boolean;
  22932. /**
  22933. * Specifies if the metallic texture contains the metallness information in its blue channel.
  22934. */
  22935. useMetallnessFromMetallicTextureBlue: boolean;
  22936. /**
  22937. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  22938. */
  22939. useAmbientOcclusionFromMetallicTextureRed: boolean;
  22940. /**
  22941. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  22942. */
  22943. useAmbientInGrayScale: boolean;
  22944. /**
  22945. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  22946. * The material will try to infer what glossiness each pixel should be.
  22947. */
  22948. useAutoMicroSurfaceFromReflectivityMap: boolean;
  22949. /**
  22950. * BJS is using an hardcoded light falloff based on a manually sets up range.
  22951. * In PBR, one way to represents the falloff is to use the inverse squared root algorithm.
  22952. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  22953. */
  22954. get usePhysicalLightFalloff(): boolean;
  22955. /**
  22956. * BJS is using an hardcoded light falloff based on a manually sets up range.
  22957. * In PBR, one way to represents the falloff is to use the inverse squared root algorithm.
  22958. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  22959. */
  22960. set usePhysicalLightFalloff(value: boolean);
  22961. /**
  22962. * In order to support the falloff compatibility with gltf, a special mode has been added
  22963. * to reproduce the gltf light falloff.
  22964. */
  22965. get useGLTFLightFalloff(): boolean;
  22966. /**
  22967. * In order to support the falloff compatibility with gltf, a special mode has been added
  22968. * to reproduce the gltf light falloff.
  22969. */
  22970. set useGLTFLightFalloff(value: boolean);
  22971. /**
  22972. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  22973. * A car glass is a good example of that. When the street lights reflects on it you can not see what is behind.
  22974. */
  22975. useRadianceOverAlpha: boolean;
  22976. /**
  22977. * Allows using an object space normal map (instead of tangent space).
  22978. */
  22979. useObjectSpaceNormalMap: boolean;
  22980. /**
  22981. * Allows using the bump map in parallax mode.
  22982. */
  22983. useParallax: boolean;
  22984. /**
  22985. * Allows using the bump map in parallax occlusion mode.
  22986. */
  22987. useParallaxOcclusion: boolean;
  22988. /**
  22989. * Controls the scale bias of the parallax mode.
  22990. */
  22991. parallaxScaleBias: number;
  22992. /**
  22993. * If sets to true, disables all the lights affecting the material.
  22994. */
  22995. disableLighting: boolean;
  22996. /**
  22997. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  22998. */
  22999. forceIrradianceInFragment: boolean;
  23000. /**
  23001. * Number of Simultaneous lights allowed on the material.
  23002. */
  23003. maxSimultaneousLights: number;
  23004. /**
  23005. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  23006. */
  23007. invertNormalMapX: boolean;
  23008. /**
  23009. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  23010. */
  23011. invertNormalMapY: boolean;
  23012. /**
  23013. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  23014. */
  23015. twoSidedLighting: boolean;
  23016. /**
  23017. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  23018. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  23019. */
  23020. useAlphaFresnel: boolean;
  23021. /**
  23022. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  23023. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  23024. */
  23025. useLinearAlphaFresnel: boolean;
  23026. /**
  23027. * Let user defines the brdf lookup texture used for IBL.
  23028. * A default 8bit version is embedded but you could point at :
  23029. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  23030. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  23031. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  23032. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  23033. */
  23034. environmentBRDFTexture: Nullable<BaseTexture>;
  23035. /**
  23036. * Force normal to face away from face.
  23037. */
  23038. forceNormalForward: boolean;
  23039. /**
  23040. * Enables specular anti aliasing in the PBR shader.
  23041. * It will both interacts on the Geometry for analytical and IBL lighting.
  23042. * It also prefilter the roughness map based on the bump values.
  23043. */
  23044. enableSpecularAntiAliasing: boolean;
  23045. /**
  23046. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  23047. * makes the reflect vector face the model (under horizon).
  23048. */
  23049. useHorizonOcclusion: boolean;
  23050. /**
  23051. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  23052. * too much the area relying on ambient texture to define their ambient occlusion.
  23053. */
  23054. useRadianceOcclusion: boolean;
  23055. /**
  23056. * If set to true, no lighting calculations will be applied.
  23057. */
  23058. unlit: boolean;
  23059. /**
  23060. * Gets the image processing configuration used either in this material.
  23061. */
  23062. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  23063. /**
  23064. * Sets the Default image processing configuration used either in the this material.
  23065. *
  23066. * If sets to null, the scene one is in use.
  23067. */
  23068. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  23069. /**
  23070. * Gets whether the color curves effect is enabled.
  23071. */
  23072. get cameraColorCurvesEnabled(): boolean;
  23073. /**
  23074. * Sets whether the color curves effect is enabled.
  23075. */
  23076. set cameraColorCurvesEnabled(value: boolean);
  23077. /**
  23078. * Gets whether the color grading effect is enabled.
  23079. */
  23080. get cameraColorGradingEnabled(): boolean;
  23081. /**
  23082. * Gets whether the color grading effect is enabled.
  23083. */
  23084. set cameraColorGradingEnabled(value: boolean);
  23085. /**
  23086. * Gets whether tonemapping is enabled or not.
  23087. */
  23088. get cameraToneMappingEnabled(): boolean;
  23089. /**
  23090. * Sets whether tonemapping is enabled or not
  23091. */
  23092. set cameraToneMappingEnabled(value: boolean);
  23093. /**
  23094. * The camera exposure used on this material.
  23095. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  23096. * This corresponds to a photographic exposure.
  23097. */
  23098. get cameraExposure(): number;
  23099. /**
  23100. * The camera exposure used on this material.
  23101. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  23102. * This corresponds to a photographic exposure.
  23103. */
  23104. set cameraExposure(value: number);
  23105. /**
  23106. * Gets The camera contrast used on this material.
  23107. */
  23108. get cameraContrast(): number;
  23109. /**
  23110. * Sets The camera contrast used on this material.
  23111. */
  23112. set cameraContrast(value: number);
  23113. /**
  23114. * Gets the Color Grading 2D Lookup Texture.
  23115. */
  23116. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  23117. /**
  23118. * Sets the Color Grading 2D Lookup Texture.
  23119. */
  23120. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  23121. /**
  23122. * The color grading curves provide additional color adjustment that is applied after any color grading transform (3D LUT).
  23123. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  23124. * 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;
  23125. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  23126. */
  23127. get cameraColorCurves(): Nullable<ColorCurves>;
  23128. /**
  23129. * The color grading curves provide additional color adjustment that is applied after any color grading transform (3D LUT).
  23130. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  23131. * 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;
  23132. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  23133. */
  23134. set cameraColorCurves(value: Nullable<ColorCurves>);
  23135. /**
  23136. * Instantiates a new PBRMaterial instance.
  23137. *
  23138. * @param name The material name
  23139. * @param scene The scene the material will be use in.
  23140. */
  23141. constructor(name: string, scene: Scene);
  23142. /**
  23143. * Returns the name of this material class.
  23144. */
  23145. getClassName(): string;
  23146. /**
  23147. * Makes a duplicate of the current material.
  23148. * @param name - name to use for the new material.
  23149. */
  23150. clone(name: string): PBRMaterial;
  23151. /**
  23152. * Serializes this PBR Material.
  23153. * @returns - An object with the serialized material.
  23154. */
  23155. serialize(): any;
  23156. /**
  23157. * Parses a PBR Material from a serialized object.
  23158. * @param source - Serialized object.
  23159. * @param scene - BJS scene instance.
  23160. * @param rootUrl - url for the scene object
  23161. * @returns - PBRMaterial
  23162. */
  23163. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  23164. }
  23165. }
  23166. declare module BABYLON {
  23167. /** @hidden */
  23168. export var mrtFragmentDeclaration: {
  23169. name: string;
  23170. shader: string;
  23171. };
  23172. }
  23173. declare module BABYLON {
  23174. /** @hidden */
  23175. export var geometryPixelShader: {
  23176. name: string;
  23177. shader: string;
  23178. };
  23179. }
  23180. declare module BABYLON {
  23181. /** @hidden */
  23182. export var instancesDeclaration: {
  23183. name: string;
  23184. shader: string;
  23185. };
  23186. }
  23187. declare module BABYLON {
  23188. /** @hidden */
  23189. export var geometryVertexDeclaration: {
  23190. name: string;
  23191. shader: string;
  23192. };
  23193. }
  23194. declare module BABYLON {
  23195. /** @hidden */
  23196. export var geometryUboDeclaration: {
  23197. name: string;
  23198. shader: string;
  23199. };
  23200. }
  23201. declare module BABYLON {
  23202. /** @hidden */
  23203. export var geometryVertexShader: {
  23204. name: string;
  23205. shader: string;
  23206. };
  23207. }
  23208. declare module BABYLON {
  23209. /** @hidden */
  23210. interface ISavedTransformationMatrix {
  23211. world: Matrix;
  23212. viewProjection: Matrix;
  23213. }
  23214. /**
  23215. * This renderer is helpful to fill one of the render target with a geometry buffer.
  23216. */
  23217. export class GeometryBufferRenderer {
  23218. /**
  23219. * Constant used to retrieve the depth texture index in the G-Buffer textures array
  23220. * using getIndex(GeometryBufferRenderer.DEPTH_TEXTURE_INDEX)
  23221. */
  23222. static readonly DEPTH_TEXTURE_TYPE: number;
  23223. /**
  23224. * Constant used to retrieve the normal texture index in the G-Buffer textures array
  23225. * using getIndex(GeometryBufferRenderer.NORMAL_TEXTURE_INDEX)
  23226. */
  23227. static readonly NORMAL_TEXTURE_TYPE: number;
  23228. /**
  23229. * Constant used to retrieve the position texture index in the G-Buffer textures array
  23230. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  23231. */
  23232. static readonly POSITION_TEXTURE_TYPE: number;
  23233. /**
  23234. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  23235. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  23236. */
  23237. static readonly VELOCITY_TEXTURE_TYPE: number;
  23238. /**
  23239. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  23240. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  23241. */
  23242. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  23243. /**
  23244. * Dictionary used to store the previous transformation matrices of each rendered mesh
  23245. * in order to compute objects velocities when enableVelocity is set to "true"
  23246. * @hidden
  23247. */
  23248. _previousTransformationMatrices: {
  23249. [index: number]: ISavedTransformationMatrix;
  23250. };
  23251. /**
  23252. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  23253. * in order to compute objects velocities when enableVelocity is set to "true"
  23254. * @hidden
  23255. */
  23256. _previousBonesTransformationMatrices: {
  23257. [index: number]: Float32Array;
  23258. };
  23259. /**
  23260. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  23261. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  23262. */
  23263. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  23264. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  23265. renderTransparentMeshes: boolean;
  23266. private _scene;
  23267. private _resizeObserver;
  23268. private _multiRenderTarget;
  23269. private _ratio;
  23270. private _enablePosition;
  23271. private _enableVelocity;
  23272. private _enableReflectivity;
  23273. private _positionIndex;
  23274. private _velocityIndex;
  23275. private _reflectivityIndex;
  23276. private _depthIndex;
  23277. private _normalIndex;
  23278. private _linkedWithPrePass;
  23279. private _prePassRenderer;
  23280. private _attachments;
  23281. private _useUbo;
  23282. protected _effect: Effect;
  23283. protected _cachedDefines: string;
  23284. /**
  23285. * @hidden
  23286. * Sets up internal structures to share outputs with PrePassRenderer
  23287. * This method should only be called by the PrePassRenderer itself
  23288. */
  23289. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  23290. /**
  23291. * @hidden
  23292. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  23293. * This method should only be called by the PrePassRenderer itself
  23294. */
  23295. _unlinkPrePassRenderer(): void;
  23296. /**
  23297. * @hidden
  23298. * Resets the geometry buffer layout
  23299. */
  23300. _resetLayout(): void;
  23301. /**
  23302. * @hidden
  23303. * Replaces a texture in the geometry buffer renderer
  23304. * Useful when linking textures of the prepass renderer
  23305. */
  23306. _forceTextureType(geometryBufferType: number, index: number): void;
  23307. /**
  23308. * @hidden
  23309. * Sets texture attachments
  23310. * Useful when linking textures of the prepass renderer
  23311. */
  23312. _setAttachments(attachments: number[]): void;
  23313. /**
  23314. * @hidden
  23315. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  23316. * Useful when linking textures of the prepass renderer
  23317. */
  23318. _linkInternalTexture(internalTexture: InternalTexture): void;
  23319. /**
  23320. * Gets the render list (meshes to be rendered) used in the G buffer.
  23321. */
  23322. get renderList(): Nullable<AbstractMesh[]>;
  23323. /**
  23324. * Set the render list (meshes to be rendered) used in the G buffer.
  23325. */
  23326. set renderList(meshes: Nullable<AbstractMesh[]>);
  23327. /**
  23328. * Gets whether or not G buffer are supported by the running hardware.
  23329. * This requires draw buffer supports
  23330. */
  23331. get isSupported(): boolean;
  23332. /**
  23333. * Returns the index of the given texture type in the G-Buffer textures array
  23334. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  23335. * @returns the index of the given texture type in the G-Buffer textures array
  23336. */
  23337. getTextureIndex(textureType: number): number;
  23338. /**
  23339. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  23340. */
  23341. get enablePosition(): boolean;
  23342. /**
  23343. * Sets whether or not objects positions are enabled for the G buffer.
  23344. */
  23345. set enablePosition(enable: boolean);
  23346. /**
  23347. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  23348. */
  23349. get enableVelocity(): boolean;
  23350. /**
  23351. * Sets whether or not objects velocities are enabled for the G buffer.
  23352. */
  23353. set enableVelocity(enable: boolean);
  23354. /**
  23355. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  23356. */
  23357. get enableReflectivity(): boolean;
  23358. /**
  23359. * Sets whether or not objects roughness are enabled for the G buffer.
  23360. */
  23361. set enableReflectivity(enable: boolean);
  23362. /**
  23363. * Gets the scene associated with the buffer.
  23364. */
  23365. get scene(): Scene;
  23366. /**
  23367. * Gets the ratio used by the buffer during its creation.
  23368. * How big is the buffer related to the main canvas.
  23369. */
  23370. get ratio(): number;
  23371. /** @hidden */
  23372. static _SceneComponentInitialization: (scene: Scene) => void;
  23373. /**
  23374. * Creates a new G Buffer for the scene
  23375. * @param scene The scene the buffer belongs to
  23376. * @param ratio How big is the buffer related to the main canvas.
  23377. */
  23378. constructor(scene: Scene, ratio?: number);
  23379. /**
  23380. * Checks whether everything is ready to render a submesh to the G buffer.
  23381. * @param subMesh the submesh to check readiness for
  23382. * @param useInstances is the mesh drawn using instance or not
  23383. * @returns true if ready otherwise false
  23384. */
  23385. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  23386. /**
  23387. * Gets the current underlying G Buffer.
  23388. * @returns the buffer
  23389. */
  23390. getGBuffer(): MultiRenderTarget;
  23391. /**
  23392. * Gets the number of samples used to render the buffer (anti aliasing).
  23393. */
  23394. get samples(): number;
  23395. /**
  23396. * Sets the number of samples used to render the buffer (anti aliasing).
  23397. */
  23398. set samples(value: number);
  23399. /**
  23400. * Disposes the renderer and frees up associated resources.
  23401. */
  23402. dispose(): void;
  23403. private _assignRenderTargetIndices;
  23404. protected _createRenderTargets(): void;
  23405. private _copyBonesTransformationMatrices;
  23406. }
  23407. }
  23408. declare module BABYLON {
  23409. /**
  23410. * Renders a pre pass of the scene
  23411. * This means every mesh in the scene will be rendered to a render target texture
  23412. * And then this texture will be composited to the rendering canvas with post processes
  23413. * It is necessary for effects like subsurface scattering or deferred shading
  23414. */
  23415. export class PrePassRenderer {
  23416. /** @hidden */
  23417. static _SceneComponentInitialization: (scene: Scene) => void;
  23418. /**
  23419. * To save performance, we can excluded skinned meshes from the prepass
  23420. */
  23421. excludedSkinnedMesh: AbstractMesh[];
  23422. /**
  23423. * Force material to be excluded from the prepass
  23424. * Can be useful when `useGeometryBufferFallback` is set to `true`
  23425. * and you don't want a material to show in the effect.
  23426. */
  23427. excludedMaterials: Material[];
  23428. private _scene;
  23429. private _engine;
  23430. /**
  23431. * Number of textures in the multi render target texture where the scene is directly rendered
  23432. */
  23433. mrtCount: number;
  23434. private _mrtFormats;
  23435. private _mrtLayout;
  23436. private _textureIndices;
  23437. private _multiRenderAttachments;
  23438. private _defaultAttachments;
  23439. private _clearAttachments;
  23440. /**
  23441. * Returns the index of a texture in the multi render target texture array.
  23442. * @param type Texture type
  23443. * @return The index
  23444. */
  23445. getIndex(type: number): number;
  23446. /**
  23447. * How many samples are used for MSAA of the scene render target
  23448. */
  23449. get samples(): number;
  23450. set samples(n: number);
  23451. private static _textureFormats;
  23452. private _isDirty;
  23453. /**
  23454. * The render target where the scene is directly rendered
  23455. */
  23456. defaultRT: PrePassRenderTarget;
  23457. /**
  23458. * Configuration for prepass effects
  23459. */
  23460. private _effectConfigurations;
  23461. /**
  23462. * @return the prepass render target for the rendering pass.
  23463. * If we are currently rendering a render target, it returns the PrePassRenderTarget
  23464. * associated with that render target. Otherwise, it returns the scene default PrePassRenderTarget
  23465. */
  23466. getRenderTarget(): PrePassRenderTarget;
  23467. /**
  23468. * @hidden
  23469. * Managed by the scene component
  23470. * @param prePassRenderTarget
  23471. */
  23472. _setRenderTarget(prePassRenderTarget: Nullable<PrePassRenderTarget>): void;
  23473. /**
  23474. * Returns true if the currently rendered prePassRenderTarget is the one
  23475. * associated with the scene.
  23476. */
  23477. get currentRTisSceneRT(): boolean;
  23478. private _geometryBuffer;
  23479. /**
  23480. * Prevents the PrePassRenderer from using the GeometryBufferRenderer as a fallback
  23481. */
  23482. doNotUseGeometryRendererFallback: boolean;
  23483. private _refreshGeometryBufferRendererLink;
  23484. private _currentTarget;
  23485. /**
  23486. * All the render targets generated by prepass
  23487. */
  23488. renderTargets: PrePassRenderTarget[];
  23489. private readonly _clearColor;
  23490. private _enabled;
  23491. private _needsCompositionForThisPass;
  23492. private _postProcessesSourceForThisPass;
  23493. /**
  23494. * Indicates if the prepass is enabled
  23495. */
  23496. get enabled(): boolean;
  23497. /**
  23498. * Set to true to disable gamma transform in PrePass.
  23499. * Can be useful in case you already proceed to gamma transform on a material level
  23500. * and your post processes don't need to be in linear color space.
  23501. */
  23502. disableGammaTransform: boolean;
  23503. /**
  23504. * Instanciates a prepass renderer
  23505. * @param scene The scene
  23506. */
  23507. constructor(scene: Scene);
  23508. /**
  23509. * Creates a new PrePassRenderTarget
  23510. * This should be the only way to instanciate a `PrePassRenderTarget`
  23511. * @param name Name of the `PrePassRenderTarget`
  23512. * @param renderTargetTexture RenderTarget the `PrePassRenderTarget` will be attached to.
  23513. * Can be `null` if the created `PrePassRenderTarget` is attached to the scene (default framebuffer).
  23514. * @hidden
  23515. */
  23516. _createRenderTarget(name: string, renderTargetTexture: Nullable<RenderTargetTexture>): PrePassRenderTarget;
  23517. /**
  23518. * Indicates if rendering a prepass is supported
  23519. */
  23520. get isSupported(): boolean;
  23521. /**
  23522. * Sets the proper output textures to draw in the engine.
  23523. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  23524. * @param subMesh Submesh on which the effect is applied
  23525. */
  23526. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  23527. private _reinitializeAttachments;
  23528. private _resetLayout;
  23529. private _updateGeometryBufferLayout;
  23530. /**
  23531. * Restores attachments for single texture draw.
  23532. */
  23533. restoreAttachments(): void;
  23534. /**
  23535. * @hidden
  23536. */
  23537. _beforeDraw(camera?: Camera, faceIndex?: number, layer?: number): void;
  23538. private _prepareFrame;
  23539. private _renderPostProcesses;
  23540. /**
  23541. * @hidden
  23542. */
  23543. _afterDraw(faceIndex?: number, layer?: number): void;
  23544. /**
  23545. * Clears the current prepass render target (in the sense of settings pixels to the scene clear color value)
  23546. * @hidden
  23547. */
  23548. _clear(): void;
  23549. private _bindFrameBuffer;
  23550. private _setEnabled;
  23551. private _setRenderTargetEnabled;
  23552. /**
  23553. * Adds an effect configuration to the prepass render target.
  23554. * If an effect has already been added, it won't add it twice and will return the configuration
  23555. * already present.
  23556. * @param cfg the effect configuration
  23557. * @return the effect configuration now used by the prepass
  23558. */
  23559. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  23560. private _enable;
  23561. private _disable;
  23562. private _getPostProcessesSource;
  23563. private _setupOutputForThisPass;
  23564. private _linkInternalTexture;
  23565. private _needsImageProcessing;
  23566. private _hasImageProcessing;
  23567. /**
  23568. * Internal, gets the first post proces.
  23569. * @returns the first post process to be run on this camera.
  23570. */
  23571. private _getFirstPostProcess;
  23572. /**
  23573. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  23574. */
  23575. markAsDirty(): void;
  23576. /**
  23577. * Enables a texture on the MultiRenderTarget for prepass
  23578. */
  23579. private _enableTextures;
  23580. private _update;
  23581. private _markAllMaterialsAsPrePassDirty;
  23582. /**
  23583. * Disposes the prepass renderer.
  23584. */
  23585. dispose(): void;
  23586. }
  23587. }
  23588. declare module BABYLON {
  23589. /**
  23590. * Size options for a post process
  23591. */
  23592. export type PostProcessOptions = {
  23593. width: number;
  23594. height: number;
  23595. };
  23596. /**
  23597. * PostProcess can be used to apply a shader to a texture after it has been rendered
  23598. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23599. */
  23600. export class PostProcess {
  23601. /**
  23602. * Gets or sets the unique id of the post process
  23603. */
  23604. uniqueId: number;
  23605. /** Name of the PostProcess. */
  23606. name: string;
  23607. /**
  23608. * Width of the texture to apply the post process on
  23609. */
  23610. width: number;
  23611. /**
  23612. * Height of the texture to apply the post process on
  23613. */
  23614. height: number;
  23615. /**
  23616. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  23617. */
  23618. nodeMaterialSource: Nullable<NodeMaterial>;
  23619. /**
  23620. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  23621. * @hidden
  23622. */
  23623. _outputTexture: Nullable<InternalTexture>;
  23624. /**
  23625. * Sampling mode used by the shader
  23626. * See https://doc.babylonjs.com/classes/3.1/texture
  23627. */
  23628. renderTargetSamplingMode: number;
  23629. /**
  23630. * Clear color to use when screen clearing
  23631. */
  23632. clearColor: Color4;
  23633. /**
  23634. * If the buffer needs to be cleared before applying the post process. (default: true)
  23635. * Should be set to false if shader will overwrite all previous pixels.
  23636. */
  23637. autoClear: boolean;
  23638. /**
  23639. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  23640. */
  23641. alphaMode: number;
  23642. /**
  23643. * Sets the setAlphaBlendConstants of the babylon engine
  23644. */
  23645. alphaConstants: Color4;
  23646. /**
  23647. * Animations to be used for the post processing
  23648. */
  23649. animations: Animation[];
  23650. /**
  23651. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  23652. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  23653. */
  23654. enablePixelPerfectMode: boolean;
  23655. /**
  23656. * Force the postprocess to be applied without taking in account viewport
  23657. */
  23658. forceFullscreenViewport: boolean;
  23659. /**
  23660. * List of inspectable custom properties (used by the Inspector)
  23661. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23662. */
  23663. inspectableCustomProperties: IInspectable[];
  23664. /**
  23665. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  23666. *
  23667. * | Value | Type | Description |
  23668. * | ----- | ----------------------------------- | ----------- |
  23669. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  23670. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  23671. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  23672. *
  23673. */
  23674. scaleMode: number;
  23675. /**
  23676. * Force textures to be a power of two (default: false)
  23677. */
  23678. alwaysForcePOT: boolean;
  23679. private _samples;
  23680. /**
  23681. * Number of sample textures (default: 1)
  23682. */
  23683. get samples(): number;
  23684. set samples(n: number);
  23685. /**
  23686. * Modify the scale of the post process to be the same as the viewport (default: false)
  23687. */
  23688. adaptScaleToCurrentViewport: boolean;
  23689. private _camera;
  23690. protected _scene: Scene;
  23691. private _engine;
  23692. private _options;
  23693. private _reusable;
  23694. private _renderId;
  23695. private _textureType;
  23696. private _textureFormat;
  23697. /**
  23698. * Smart array of input and output textures for the post process.
  23699. * @hidden
  23700. */
  23701. _textures: SmartArray<InternalTexture>;
  23702. /**
  23703. * Smart array of input and output textures for the post process.
  23704. * @hidden
  23705. */
  23706. private _textureCache;
  23707. /**
  23708. * The index in _textures that corresponds to the output texture.
  23709. * @hidden
  23710. */
  23711. _currentRenderTextureInd: number;
  23712. private _effect;
  23713. private _samplers;
  23714. private _fragmentUrl;
  23715. private _vertexUrl;
  23716. private _parameters;
  23717. protected _postProcessDefines: Nullable<string>;
  23718. private _scaleRatio;
  23719. protected _indexParameters: any;
  23720. private _shareOutputWithPostProcess;
  23721. private _texelSize;
  23722. /** @hidden */
  23723. _forcedOutputTexture: Nullable<InternalTexture>;
  23724. /**
  23725. * Prepass configuration in case this post process needs a texture from prepass
  23726. * @hidden
  23727. */
  23728. _prePassEffectConfiguration: PrePassEffectConfiguration;
  23729. /**
  23730. * Returns the fragment url or shader name used in the post process.
  23731. * @returns the fragment url or name in the shader store.
  23732. */
  23733. getEffectName(): string;
  23734. /**
  23735. * An event triggered when the postprocess is activated.
  23736. */
  23737. onActivateObservable: Observable<Camera>;
  23738. private _onActivateObserver;
  23739. /**
  23740. * A function that is added to the onActivateObservable
  23741. */
  23742. set onActivate(callback: Nullable<(camera: Camera) => void>);
  23743. /**
  23744. * An event triggered when the postprocess changes its size.
  23745. */
  23746. onSizeChangedObservable: Observable<PostProcess>;
  23747. private _onSizeChangedObserver;
  23748. /**
  23749. * A function that is added to the onSizeChangedObservable
  23750. */
  23751. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  23752. /**
  23753. * An event triggered when the postprocess applies its effect.
  23754. */
  23755. onApplyObservable: Observable<Effect>;
  23756. private _onApplyObserver;
  23757. /**
  23758. * A function that is added to the onApplyObservable
  23759. */
  23760. set onApply(callback: (effect: Effect) => void);
  23761. /**
  23762. * An event triggered before rendering the postprocess
  23763. */
  23764. onBeforeRenderObservable: Observable<Effect>;
  23765. private _onBeforeRenderObserver;
  23766. /**
  23767. * A function that is added to the onBeforeRenderObservable
  23768. */
  23769. set onBeforeRender(callback: (effect: Effect) => void);
  23770. /**
  23771. * An event triggered after rendering the postprocess
  23772. */
  23773. onAfterRenderObservable: Observable<Effect>;
  23774. private _onAfterRenderObserver;
  23775. /**
  23776. * A function that is added to the onAfterRenderObservable
  23777. */
  23778. set onAfterRender(callback: (efect: Effect) => void);
  23779. /**
  23780. * 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
  23781. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  23782. */
  23783. get inputTexture(): InternalTexture;
  23784. set inputTexture(value: InternalTexture);
  23785. /**
  23786. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  23787. * the only way to unset it is to use this function to restore its internal state
  23788. */
  23789. restoreDefaultInputTexture(): void;
  23790. /**
  23791. * Gets the camera which post process is applied to.
  23792. * @returns The camera the post process is applied to.
  23793. */
  23794. getCamera(): Camera;
  23795. /**
  23796. * Gets the texel size of the postprocess.
  23797. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  23798. */
  23799. get texelSize(): Vector2;
  23800. /**
  23801. * Creates a new instance PostProcess
  23802. * @param name The name of the PostProcess.
  23803. * @param fragmentUrl The url of the fragment shader to be used.
  23804. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  23805. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  23806. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23807. * @param camera The camera to apply the render pass to.
  23808. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23809. * @param engine The engine which the post process will be applied. (default: current engine)
  23810. * @param reusable If the post process can be reused on the same frame. (default: false)
  23811. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  23812. * @param textureType Type of textures used when performing the post process. (default: 0)
  23813. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  23814. * @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
  23815. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  23816. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23817. */
  23818. 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);
  23819. /**
  23820. * Gets a string identifying the name of the class
  23821. * @returns "PostProcess" string
  23822. */
  23823. getClassName(): string;
  23824. /**
  23825. * Gets the engine which this post process belongs to.
  23826. * @returns The engine the post process was enabled with.
  23827. */
  23828. getEngine(): Engine;
  23829. /**
  23830. * The effect that is created when initializing the post process.
  23831. * @returns The created effect corresponding the the postprocess.
  23832. */
  23833. getEffect(): Effect;
  23834. /**
  23835. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  23836. * @param postProcess The post process to share the output with.
  23837. * @returns This post process.
  23838. */
  23839. shareOutputWith(postProcess: PostProcess): PostProcess;
  23840. /**
  23841. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  23842. * This should be called if the post process that shares output with this post process is disabled/disposed.
  23843. */
  23844. useOwnOutput(): void;
  23845. /**
  23846. * Updates the effect with the current post process compile time values and recompiles the shader.
  23847. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23848. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23849. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23850. * @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
  23851. * @param onCompiled Called when the shader has been compiled.
  23852. * @param onError Called if there is an error when compiling a shader.
  23853. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  23854. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  23855. */
  23856. 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;
  23857. /**
  23858. * The post process is reusable if it can be used multiple times within one frame.
  23859. * @returns If the post process is reusable
  23860. */
  23861. isReusable(): boolean;
  23862. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  23863. markTextureDirty(): void;
  23864. private _createRenderTargetTexture;
  23865. private _flushTextureCache;
  23866. private _resize;
  23867. /**
  23868. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  23869. * 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.
  23870. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  23871. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  23872. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  23873. * @returns The target texture that was bound to be written to.
  23874. */
  23875. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  23876. /**
  23877. * If the post process is supported.
  23878. */
  23879. get isSupported(): boolean;
  23880. /**
  23881. * The aspect ratio of the output texture.
  23882. */
  23883. get aspectRatio(): number;
  23884. /**
  23885. * Get a value indicating if the post-process is ready to be used
  23886. * @returns true if the post-process is ready (shader is compiled)
  23887. */
  23888. isReady(): boolean;
  23889. /**
  23890. * Binds all textures and uniforms to the shader, this will be run on every pass.
  23891. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  23892. */
  23893. apply(): Nullable<Effect>;
  23894. private _disposeTextures;
  23895. private _disposeTextureCache;
  23896. /**
  23897. * Sets the required values to the prepass renderer.
  23898. * @param prePassRenderer defines the prepass renderer to setup.
  23899. * @returns true if the pre pass is needed.
  23900. */
  23901. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  23902. /**
  23903. * Disposes the post process.
  23904. * @param camera The camera to dispose the post process on.
  23905. */
  23906. dispose(camera?: Camera): void;
  23907. /**
  23908. * Serializes the particle system to a JSON object
  23909. * @returns the JSON object
  23910. */
  23911. serialize(): any;
  23912. /**
  23913. * Clones this post process
  23914. * @returns a new post process similar to this one
  23915. */
  23916. clone(): Nullable<PostProcess>;
  23917. /**
  23918. * Creates a material from parsed material data
  23919. * @param parsedPostProcess defines parsed post process data
  23920. * @param scene defines the hosting scene
  23921. * @param rootUrl defines the root URL to use to load textures
  23922. * @returns a new post process
  23923. */
  23924. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  23925. /** @hidden */
  23926. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  23927. }
  23928. }
  23929. declare module BABYLON {
  23930. /** @hidden */
  23931. export var kernelBlurVaryingDeclaration: {
  23932. name: string;
  23933. shader: string;
  23934. };
  23935. }
  23936. declare module BABYLON {
  23937. /** @hidden */
  23938. export var packingFunctions: {
  23939. name: string;
  23940. shader: string;
  23941. };
  23942. }
  23943. declare module BABYLON {
  23944. /** @hidden */
  23945. export var kernelBlurFragment: {
  23946. name: string;
  23947. shader: string;
  23948. };
  23949. }
  23950. declare module BABYLON {
  23951. /** @hidden */
  23952. export var kernelBlurFragment2: {
  23953. name: string;
  23954. shader: string;
  23955. };
  23956. }
  23957. declare module BABYLON {
  23958. /** @hidden */
  23959. export var kernelBlurPixelShader: {
  23960. name: string;
  23961. shader: string;
  23962. };
  23963. }
  23964. declare module BABYLON {
  23965. /** @hidden */
  23966. export var kernelBlurVertex: {
  23967. name: string;
  23968. shader: string;
  23969. };
  23970. }
  23971. declare module BABYLON {
  23972. /** @hidden */
  23973. export var kernelBlurVertexShader: {
  23974. name: string;
  23975. shader: string;
  23976. };
  23977. }
  23978. declare module BABYLON {
  23979. /**
  23980. * The Blur Post Process which blurs an image based on a kernel and direction.
  23981. * Can be used twice in x and y directions to perform a gaussian blur in two passes.
  23982. */
  23983. export class BlurPostProcess extends PostProcess {
  23984. private blockCompilation;
  23985. protected _kernel: number;
  23986. protected _idealKernel: number;
  23987. protected _packedFloat: boolean;
  23988. private _staticDefines;
  23989. /** The direction in which to blur the image. */
  23990. direction: Vector2;
  23991. /**
  23992. * Sets the length in pixels of the blur sample region
  23993. */
  23994. set kernel(v: number);
  23995. /**
  23996. * Gets the length in pixels of the blur sample region
  23997. */
  23998. get kernel(): number;
  23999. /**
  24000. * Sets whether or not the blur needs to unpack/repack floats
  24001. */
  24002. set packedFloat(v: boolean);
  24003. /**
  24004. * Gets whether or not the blur is unpacking/repacking floats
  24005. */
  24006. get packedFloat(): boolean;
  24007. /**
  24008. * Gets a string identifying the name of the class
  24009. * @returns "BlurPostProcess" string
  24010. */
  24011. getClassName(): string;
  24012. /**
  24013. * Creates a new instance BlurPostProcess
  24014. * @param name The name of the effect.
  24015. * @param direction The direction in which to blur the image.
  24016. * @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.
  24017. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  24018. * @param camera The camera to apply the render pass to.
  24019. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  24020. * @param engine The engine which the post process will be applied. (default: current engine)
  24021. * @param reusable If the post process can be reused on the same frame. (default: false)
  24022. * @param textureType Type of textures used when performing the post process. (default: 0)
  24023. * @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)
  24024. */
  24025. 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);
  24026. /**
  24027. * Updates the effect with the current post process compile time values and recompiles the shader.
  24028. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  24029. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  24030. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  24031. * @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
  24032. * @param onCompiled Called when the shader has been compiled.
  24033. * @param onError Called if there is an error when compiling a shader.
  24034. */
  24035. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  24036. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  24037. /**
  24038. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  24039. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  24040. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  24041. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  24042. * The gaps between physical kernels are compensated for in the weighting of the samples
  24043. * @param idealKernel Ideal blur kernel.
  24044. * @return Nearest best kernel.
  24045. */
  24046. protected _nearestBestKernel(idealKernel: number): number;
  24047. /**
  24048. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  24049. * @param x The point on the Gaussian distribution to sample.
  24050. * @return the value of the Gaussian function at x.
  24051. */
  24052. protected _gaussianWeight(x: number): number;
  24053. /**
  24054. * Generates a string that can be used as a floating point number in GLSL.
  24055. * @param x Value to print.
  24056. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  24057. * @return GLSL float string.
  24058. */
  24059. protected _glslFloat(x: number, decimalFigures?: number): string;
  24060. /** @hidden */
  24061. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  24062. }
  24063. }
  24064. declare module BABYLON {
  24065. /**
  24066. * Mirror texture can be used to simulate the view from a mirror in a scene.
  24067. * It will dynamically be rendered every frame to adapt to the camera point of view.
  24068. * You can then easily use it as a reflectionTexture on a flat surface.
  24069. * In case the surface is not a plane, please consider relying on reflection probes.
  24070. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  24071. */
  24072. export class MirrorTexture extends RenderTargetTexture {
  24073. private scene;
  24074. /**
  24075. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  24076. * 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.
  24077. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  24078. */
  24079. mirrorPlane: Plane;
  24080. /**
  24081. * Define the blur ratio used to blur the reflection if needed.
  24082. */
  24083. set blurRatio(value: number);
  24084. get blurRatio(): number;
  24085. /**
  24086. * Define the adaptive blur kernel used to blur the reflection if needed.
  24087. * This will autocompute the closest best match for the `blurKernel`
  24088. */
  24089. set adaptiveBlurKernel(value: number);
  24090. /**
  24091. * Define the blur kernel used to blur the reflection if needed.
  24092. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  24093. */
  24094. set blurKernel(value: number);
  24095. /**
  24096. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  24097. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  24098. */
  24099. set blurKernelX(value: number);
  24100. get blurKernelX(): number;
  24101. /**
  24102. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  24103. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  24104. */
  24105. set blurKernelY(value: number);
  24106. get blurKernelY(): number;
  24107. private _autoComputeBlurKernel;
  24108. protected _onRatioRescale(): void;
  24109. private _updateGammaSpace;
  24110. private _imageProcessingConfigChangeObserver;
  24111. private _transformMatrix;
  24112. private _mirrorMatrix;
  24113. private _blurX;
  24114. private _blurY;
  24115. private _adaptiveBlurKernel;
  24116. private _blurKernelX;
  24117. private _blurKernelY;
  24118. private _blurRatio;
  24119. /**
  24120. * Instantiates a Mirror Texture.
  24121. * Mirror texture can be used to simulate the view from a mirror in a scene.
  24122. * It will dynamically be rendered every frame to adapt to the camera point of view.
  24123. * You can then easily use it as a reflectionTexture on a flat surface.
  24124. * In case the surface is not a plane, please consider relying on reflection probes.
  24125. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  24126. * @param name
  24127. * @param size
  24128. * @param scene
  24129. * @param generateMipMaps
  24130. * @param type
  24131. * @param samplingMode
  24132. * @param generateDepthBuffer
  24133. */
  24134. constructor(name: string, size: number | {
  24135. width: number;
  24136. height: number;
  24137. } | {
  24138. ratio: number;
  24139. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  24140. private _preparePostProcesses;
  24141. /**
  24142. * Clone the mirror texture.
  24143. * @returns the cloned texture
  24144. */
  24145. clone(): MirrorTexture;
  24146. /**
  24147. * Serialize the texture to a JSON representation you could use in Parse later on
  24148. * @returns the serialized JSON representation
  24149. */
  24150. serialize(): any;
  24151. /**
  24152. * Dispose the texture and release its associated resources.
  24153. */
  24154. dispose(): void;
  24155. }
  24156. }
  24157. declare module BABYLON {
  24158. /**
  24159. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  24160. * @see https://doc.babylonjs.com/babylon101/materials#texture
  24161. */
  24162. export class Texture extends BaseTexture {
  24163. /**
  24164. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  24165. */
  24166. static SerializeBuffers: boolean;
  24167. /**
  24168. * Gets or sets a general boolean used to indicate that texture buffers must be saved as part of the serialization process.
  24169. * If no buffer exists, one will be created as base64 string from the internal webgl data.
  24170. */
  24171. static ForceSerializeBuffers: boolean;
  24172. /** @hidden */
  24173. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  24174. /** @hidden */
  24175. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  24176. /** @hidden */
  24177. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  24178. /** nearest is mag = nearest and min = nearest and mip = linear */
  24179. static readonly NEAREST_SAMPLINGMODE: number;
  24180. /** nearest is mag = nearest and min = nearest and mip = linear */
  24181. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  24182. /** Bilinear is mag = linear and min = linear and mip = nearest */
  24183. static readonly BILINEAR_SAMPLINGMODE: number;
  24184. /** Bilinear is mag = linear and min = linear and mip = nearest */
  24185. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  24186. /** Trilinear is mag = linear and min = linear and mip = linear */
  24187. static readonly TRILINEAR_SAMPLINGMODE: number;
  24188. /** Trilinear is mag = linear and min = linear and mip = linear */
  24189. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  24190. /** mag = nearest and min = nearest and mip = nearest */
  24191. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  24192. /** mag = nearest and min = linear and mip = nearest */
  24193. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  24194. /** mag = nearest and min = linear and mip = linear */
  24195. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  24196. /** mag = nearest and min = linear and mip = none */
  24197. static readonly NEAREST_LINEAR: number;
  24198. /** mag = nearest and min = nearest and mip = none */
  24199. static readonly NEAREST_NEAREST: number;
  24200. /** mag = linear and min = nearest and mip = nearest */
  24201. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  24202. /** mag = linear and min = nearest and mip = linear */
  24203. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  24204. /** mag = linear and min = linear and mip = none */
  24205. static readonly LINEAR_LINEAR: number;
  24206. /** mag = linear and min = nearest and mip = none */
  24207. static readonly LINEAR_NEAREST: number;
  24208. /** Explicit coordinates mode */
  24209. static readonly EXPLICIT_MODE: number;
  24210. /** Spherical coordinates mode */
  24211. static readonly SPHERICAL_MODE: number;
  24212. /** Planar coordinates mode */
  24213. static readonly PLANAR_MODE: number;
  24214. /** Cubic coordinates mode */
  24215. static readonly CUBIC_MODE: number;
  24216. /** Projection coordinates mode */
  24217. static readonly PROJECTION_MODE: number;
  24218. /** Inverse Cubic coordinates mode */
  24219. static readonly SKYBOX_MODE: number;
  24220. /** Inverse Cubic coordinates mode */
  24221. static readonly INVCUBIC_MODE: number;
  24222. /** Equirectangular coordinates mode */
  24223. static readonly EQUIRECTANGULAR_MODE: number;
  24224. /** Equirectangular Fixed coordinates mode */
  24225. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  24226. /** Equirectangular Fixed Mirrored coordinates mode */
  24227. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  24228. /** Texture is not repeating outside of 0..1 UVs */
  24229. static readonly CLAMP_ADDRESSMODE: number;
  24230. /** Texture is repeating outside of 0..1 UVs */
  24231. static readonly WRAP_ADDRESSMODE: number;
  24232. /** Texture is repeating and mirrored */
  24233. static readonly MIRROR_ADDRESSMODE: number;
  24234. /**
  24235. * 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
  24236. */
  24237. static UseSerializedUrlIfAny: boolean;
  24238. /**
  24239. * Define the url of the texture.
  24240. */
  24241. url: Nullable<string>;
  24242. /**
  24243. * Define an offset on the texture to offset the u coordinates of the UVs
  24244. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  24245. */
  24246. uOffset: number;
  24247. /**
  24248. * Define an offset on the texture to offset the v coordinates of the UVs
  24249. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  24250. */
  24251. vOffset: number;
  24252. /**
  24253. * Define an offset on the texture to scale the u coordinates of the UVs
  24254. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  24255. */
  24256. uScale: number;
  24257. /**
  24258. * Define an offset on the texture to scale the v coordinates of the UVs
  24259. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  24260. */
  24261. vScale: number;
  24262. /**
  24263. * Define an offset on the texture to rotate around the u coordinates of the UVs
  24264. * @see https://doc.babylonjs.com/how_to/more_materials
  24265. */
  24266. uAng: number;
  24267. /**
  24268. * Define an offset on the texture to rotate around the v coordinates of the UVs
  24269. * @see https://doc.babylonjs.com/how_to/more_materials
  24270. */
  24271. vAng: number;
  24272. /**
  24273. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  24274. * @see https://doc.babylonjs.com/how_to/more_materials
  24275. */
  24276. wAng: number;
  24277. /**
  24278. * Defines the center of rotation (U)
  24279. */
  24280. uRotationCenter: number;
  24281. /**
  24282. * Defines the center of rotation (V)
  24283. */
  24284. vRotationCenter: number;
  24285. /**
  24286. * Defines the center of rotation (W)
  24287. */
  24288. wRotationCenter: number;
  24289. /**
  24290. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  24291. */
  24292. homogeneousRotationInUVTransform: boolean;
  24293. /**
  24294. * Are mip maps generated for this texture or not.
  24295. */
  24296. get noMipmap(): boolean;
  24297. /**
  24298. * List of inspectable custom properties (used by the Inspector)
  24299. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24300. */
  24301. inspectableCustomProperties: Nullable<IInspectable[]>;
  24302. private _noMipmap;
  24303. /** @hidden */
  24304. _invertY: boolean;
  24305. private _rowGenerationMatrix;
  24306. private _cachedTextureMatrix;
  24307. private _projectionModeMatrix;
  24308. private _t0;
  24309. private _t1;
  24310. private _t2;
  24311. private _cachedUOffset;
  24312. private _cachedVOffset;
  24313. private _cachedUScale;
  24314. private _cachedVScale;
  24315. private _cachedUAng;
  24316. private _cachedVAng;
  24317. private _cachedWAng;
  24318. private _cachedProjectionMatrixId;
  24319. private _cachedURotationCenter;
  24320. private _cachedVRotationCenter;
  24321. private _cachedWRotationCenter;
  24322. private _cachedHomogeneousRotationInUVTransform;
  24323. private _cachedCoordinatesMode;
  24324. /** @hidden */
  24325. protected _initialSamplingMode: number;
  24326. /** @hidden */
  24327. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  24328. private _deleteBuffer;
  24329. protected _format: Nullable<number>;
  24330. private _delayedOnLoad;
  24331. private _delayedOnError;
  24332. private _mimeType?;
  24333. private _loaderOptions?;
  24334. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  24335. get mimeType(): string | undefined;
  24336. /**
  24337. * Observable triggered once the texture has been loaded.
  24338. */
  24339. onLoadObservable: Observable<Texture>;
  24340. protected _isBlocking: boolean;
  24341. /**
  24342. * Is the texture preventing material to render while loading.
  24343. * If false, a default texture will be used instead of the loading one during the preparation step.
  24344. */
  24345. set isBlocking(value: boolean);
  24346. get isBlocking(): boolean;
  24347. /**
  24348. * Get the current sampling mode associated with the texture.
  24349. */
  24350. get samplingMode(): number;
  24351. /**
  24352. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  24353. */
  24354. get invertY(): boolean;
  24355. /**
  24356. * Instantiates a new texture.
  24357. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  24358. * @see https://doc.babylonjs.com/babylon101/materials#texture
  24359. * @param url defines the url of the picture to load as a texture
  24360. * @param sceneOrEngine defines the scene or engine the texture will belong to
  24361. * @param noMipmap defines if the texture will require mip maps or not
  24362. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  24363. * @param samplingMode defines the sampling mode we want for the texture while fetching from it (Texture.NEAREST_SAMPLINGMODE...)
  24364. * @param onLoad defines a callback triggered when the texture has been loaded
  24365. * @param onError defines a callback triggered when an error occurred during the loading session
  24366. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  24367. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  24368. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24369. * @param mimeType defines an optional mime type information
  24370. * @param loaderOptions options to be passed to the loader
  24371. */
  24372. 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);
  24373. /**
  24374. * Update the url (and optional buffer) of this texture if url was null during construction.
  24375. * @param url the url of the texture
  24376. * @param buffer the buffer of the texture (defaults to null)
  24377. * @param onLoad callback called when the texture is loaded (defaults to null)
  24378. */
  24379. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  24380. /**
  24381. * Finish the loading sequence of a texture flagged as delayed load.
  24382. * @hidden
  24383. */
  24384. delayLoad(): void;
  24385. private _prepareRowForTextureGeneration;
  24386. /**
  24387. * Checks if the texture has the same transform matrix than another texture
  24388. * @param texture texture to check against
  24389. * @returns true if the transforms are the same, else false
  24390. */
  24391. checkTransformsAreIdentical(texture: Nullable<Texture>): boolean;
  24392. /**
  24393. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  24394. * @returns the transform matrix of the texture.
  24395. */
  24396. getTextureMatrix(uBase?: number): Matrix;
  24397. /**
  24398. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  24399. * @returns The reflection texture transform
  24400. */
  24401. getReflectionTextureMatrix(): Matrix;
  24402. /**
  24403. * Clones the texture.
  24404. * @returns the cloned texture
  24405. */
  24406. clone(): Texture;
  24407. /**
  24408. * Serialize the texture to a JSON representation we can easily use in the respective Parse function.
  24409. * @returns The JSON representation of the texture
  24410. */
  24411. serialize(): any;
  24412. /**
  24413. * Get the current class name of the texture useful for serialization or dynamic coding.
  24414. * @returns "Texture"
  24415. */
  24416. getClassName(): string;
  24417. /**
  24418. * Dispose the texture and release its associated resources.
  24419. */
  24420. dispose(): void;
  24421. /**
  24422. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  24423. * @param parsedTexture Define the JSON representation of the texture
  24424. * @param scene Define the scene the parsed texture should be instantiated in
  24425. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  24426. * @returns The parsed texture if successful
  24427. */
  24428. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  24429. /**
  24430. * Creates a texture from its base 64 representation.
  24431. * @param data Define the base64 payload without the data: prefix
  24432. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  24433. * @param scene Define the scene the texture should belong to
  24434. * @param noMipmap Forces the texture to not create mip map information if true
  24435. * @param invertY define if the texture needs to be inverted on the y axis during loading
  24436. * @param samplingMode define the sampling mode we want for the texture while fetching from it (Texture.NEAREST_SAMPLINGMODE...)
  24437. * @param onLoad define a callback triggered when the texture has been loaded
  24438. * @param onError define a callback triggered when an error occurred during the loading session
  24439. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24440. * @returns the created texture
  24441. */
  24442. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  24443. /**
  24444. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  24445. * @param data Define the base64 payload without the data: prefix
  24446. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  24447. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  24448. * @param scene Define the scene the texture should belong to
  24449. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  24450. * @param noMipmap Forces the texture to not create mip map information if true
  24451. * @param invertY define if the texture needs to be inverted on the y axis during loading
  24452. * @param samplingMode define the sampling mode we want for the texture while fetching from it (Texture.NEAREST_SAMPLINGMODE...)
  24453. * @param onLoad define a callback triggered when the texture has been loaded
  24454. * @param onError define a callback triggered when an error occurred during the loading session
  24455. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24456. * @returns the created texture
  24457. */
  24458. 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;
  24459. }
  24460. }
  24461. declare module BABYLON {
  24462. /**
  24463. * ThinSprite Class used to represent a thin sprite
  24464. * This is the base class for sprites but can also directly be used with ThinEngine
  24465. * @see https://doc.babylonjs.com/babylon101/sprites
  24466. */
  24467. export class ThinSprite {
  24468. /** Gets or sets the cell index in the sprite sheet */
  24469. cellIndex: number;
  24470. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  24471. cellRef: string;
  24472. /** Gets or sets the current world position */
  24473. position: IVector3Like;
  24474. /** Gets or sets the main color */
  24475. color: IColor4Like;
  24476. /** Gets or sets the width */
  24477. width: number;
  24478. /** Gets or sets the height */
  24479. height: number;
  24480. /** Gets or sets rotation angle */
  24481. angle: number;
  24482. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  24483. invertU: boolean;
  24484. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  24485. invertV: boolean;
  24486. /** Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true */
  24487. isVisible: boolean;
  24488. /**
  24489. * Returns a boolean indicating if the animation is started
  24490. */
  24491. get animationStarted(): boolean;
  24492. /** Gets the initial key for the animation (setting it will restart the animation) */
  24493. get fromIndex(): number;
  24494. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  24495. get toIndex(): number;
  24496. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  24497. get loopAnimation(): boolean;
  24498. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  24499. get delay(): number;
  24500. /** @hidden */
  24501. _xOffset: number;
  24502. /** @hidden */
  24503. _yOffset: number;
  24504. /** @hidden */
  24505. _xSize: number;
  24506. /** @hidden */
  24507. _ySize: number;
  24508. private _animationStarted;
  24509. protected _loopAnimation: boolean;
  24510. protected _fromIndex: number;
  24511. protected _toIndex: number;
  24512. protected _delay: number;
  24513. private _direction;
  24514. private _time;
  24515. private _onBaseAnimationEnd;
  24516. /**
  24517. * Creates a new Thin Sprite
  24518. */
  24519. constructor();
  24520. /**
  24521. * Starts an animation
  24522. * @param from defines the initial key
  24523. * @param to defines the end key
  24524. * @param loop defines if the animation must loop
  24525. * @param delay defines the start delay (in ms)
  24526. * @param onAnimationEnd defines a callback for when the animation ends
  24527. */
  24528. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: Nullable<() => void>): void;
  24529. /** Stops current animation (if any) */
  24530. stopAnimation(): void;
  24531. /** @hidden */
  24532. _animate(deltaTime: number): void;
  24533. }
  24534. }
  24535. declare module BABYLON {
  24536. /** @hidden */
  24537. export var imageProcessingCompatibility: {
  24538. name: string;
  24539. shader: string;
  24540. };
  24541. }
  24542. declare module BABYLON {
  24543. /** @hidden */
  24544. export var spritesPixelShader: {
  24545. name: string;
  24546. shader: string;
  24547. };
  24548. }
  24549. declare module BABYLON {
  24550. /** @hidden */
  24551. export var spritesVertexShader: {
  24552. name: string;
  24553. shader: string;
  24554. };
  24555. }
  24556. declare module BABYLON {
  24557. /**
  24558. * Class used to render sprites.
  24559. *
  24560. * It can be used either to render Sprites or ThinSriptes with ThinEngine only.
  24561. */
  24562. export class SpriteRenderer {
  24563. /**
  24564. * Defines the texture of the spritesheet
  24565. */
  24566. texture: Nullable<ThinTexture>;
  24567. /**
  24568. * Defines the default width of a cell in the spritesheet
  24569. */
  24570. cellWidth: number;
  24571. /**
  24572. * Defines the default height of a cell in the spritesheet
  24573. */
  24574. cellHeight: number;
  24575. /**
  24576. * Blend mode use to render the particle, it can be any of
  24577. * the static Constants.ALPHA_x properties provided in this class.
  24578. * Default value is Constants.ALPHA_COMBINE
  24579. */
  24580. blendMode: number;
  24581. /**
  24582. * Gets or sets a boolean indicating if alpha mode is automatically
  24583. * reset.
  24584. */
  24585. autoResetAlpha: boolean;
  24586. /**
  24587. * Disables writing to the depth buffer when rendering the sprites.
  24588. * It can be handy to disable depth writing when using textures without alpha channel
  24589. * and setting some specific blend modes.
  24590. */
  24591. disableDepthWrite: boolean;
  24592. /**
  24593. * Gets or sets a boolean indicating if the manager must consider scene fog when rendering
  24594. */
  24595. fogEnabled: boolean;
  24596. /**
  24597. * Gets the capacity of the manager
  24598. */
  24599. get capacity(): number;
  24600. private readonly _engine;
  24601. private readonly _useVAO;
  24602. private readonly _useInstancing;
  24603. private readonly _scene;
  24604. private readonly _capacity;
  24605. private readonly _epsilon;
  24606. private _vertexBufferSize;
  24607. private _vertexData;
  24608. private _buffer;
  24609. private _vertexBuffers;
  24610. private _spriteBuffer;
  24611. private _indexBuffer;
  24612. private _effectBase;
  24613. private _effectFog;
  24614. private _vertexArrayObject;
  24615. /**
  24616. * Creates a new sprite Renderer
  24617. * @param engine defines the engine the renderer works with
  24618. * @param capacity defines the maximum allowed number of sprites
  24619. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  24620. * @param scene defines the hosting scene
  24621. */
  24622. constructor(engine: ThinEngine, capacity: number, epsilon?: number, scene?: Nullable<Scene>);
  24623. /**
  24624. * Render all child sprites
  24625. * @param sprites defines the list of sprites to render
  24626. * @param deltaTime defines the time since last frame
  24627. * @param viewMatrix defines the viewMatrix to use to render the sprites
  24628. * @param projectionMatrix defines the projectionMatrix to use to render the sprites
  24629. * @param customSpriteUpdate defines a custom function to update the sprites data before they render
  24630. */
  24631. render(sprites: ThinSprite[], deltaTime: number, viewMatrix: IMatrixLike, projectionMatrix: IMatrixLike, customSpriteUpdate?: Nullable<(sprite: ThinSprite, baseSize: ISize) => void>): void;
  24632. private _appendSpriteVertex;
  24633. /**
  24634. * Release associated resources
  24635. */
  24636. dispose(): void;
  24637. }
  24638. }
  24639. declare module BABYLON {
  24640. /**
  24641. * Defines the minimum interface to fulfill in order to be a sprite manager.
  24642. */
  24643. export interface ISpriteManager extends IDisposable {
  24644. /**
  24645. * Gets manager's name
  24646. */
  24647. name: string;
  24648. /**
  24649. * Restricts the camera to viewing objects with the same layerMask.
  24650. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  24651. */
  24652. layerMask: number;
  24653. /**
  24654. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24655. */
  24656. isPickable: boolean;
  24657. /**
  24658. * Gets the hosting scene
  24659. */
  24660. scene: Scene;
  24661. /**
  24662. * Specifies the rendering group id for this mesh (0 by default)
  24663. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24664. */
  24665. renderingGroupId: number;
  24666. /**
  24667. * Defines the list of sprites managed by the manager.
  24668. */
  24669. sprites: Array<Sprite>;
  24670. /**
  24671. * Gets or sets the spritesheet texture
  24672. */
  24673. texture: Texture;
  24674. /** Defines the default width of a cell in the spritesheet */
  24675. cellWidth: number;
  24676. /** Defines the default height of a cell in the spritesheet */
  24677. cellHeight: number;
  24678. /**
  24679. * Tests the intersection of a sprite with a specific ray.
  24680. * @param ray The ray we are sending to test the collision
  24681. * @param camera The camera space we are sending rays in
  24682. * @param predicate A predicate allowing excluding sprites from the list of object to test
  24683. * @param fastCheck defines if the first intersection will be used (and not the closest)
  24684. * @returns picking info or null.
  24685. */
  24686. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  24687. /**
  24688. * Intersects the sprites with a ray
  24689. * @param ray defines the ray to intersect with
  24690. * @param camera defines the current active camera
  24691. * @param predicate defines a predicate used to select candidate sprites
  24692. * @returns null if no hit or a PickingInfo array
  24693. */
  24694. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  24695. /**
  24696. * Renders the list of sprites on screen.
  24697. */
  24698. render(): void;
  24699. }
  24700. /**
  24701. * Class used to manage multiple sprites on the same spritesheet
  24702. * @see https://doc.babylonjs.com/babylon101/sprites
  24703. */
  24704. export class SpriteManager implements ISpriteManager {
  24705. /** defines the manager's name */
  24706. name: string;
  24707. /** Define the Url to load snippets */
  24708. static SnippetUrl: string;
  24709. /** Snippet ID if the manager was created from the snippet server */
  24710. snippetId: string;
  24711. /** Gets the list of sprites */
  24712. sprites: Sprite[];
  24713. /** Gets or sets the rendering group id (0 by default) */
  24714. renderingGroupId: number;
  24715. /** Gets or sets camera layer mask */
  24716. layerMask: number;
  24717. /** Gets or sets a boolean indicating if the sprites are pickable */
  24718. isPickable: boolean;
  24719. /**
  24720. * An event triggered when the manager is disposed.
  24721. */
  24722. onDisposeObservable: Observable<SpriteManager>;
  24723. /**
  24724. * Callback called when the manager is disposed
  24725. */
  24726. set onDispose(callback: () => void);
  24727. /**
  24728. * Gets or sets the unique id of the sprite
  24729. */
  24730. uniqueId: number;
  24731. /**
  24732. * Gets the array of sprites
  24733. */
  24734. get children(): Sprite[];
  24735. /**
  24736. * Gets the hosting scene
  24737. */
  24738. get scene(): Scene;
  24739. /**
  24740. * Gets the capacity of the manager
  24741. */
  24742. get capacity(): number;
  24743. /**
  24744. * Gets or sets the spritesheet texture
  24745. */
  24746. get texture(): Texture;
  24747. set texture(value: Texture);
  24748. /** Defines the default width of a cell in the spritesheet */
  24749. get cellWidth(): number;
  24750. set cellWidth(value: number);
  24751. /** Defines the default height of a cell in the spritesheet */
  24752. get cellHeight(): number;
  24753. set cellHeight(value: number);
  24754. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  24755. get fogEnabled(): boolean;
  24756. set fogEnabled(value: boolean);
  24757. /**
  24758. * Blend mode use to render the particle, it can be any of
  24759. * the static Constants.ALPHA_x properties provided in this class.
  24760. * Default value is Constants.ALPHA_COMBINE
  24761. */
  24762. get blendMode(): number;
  24763. set blendMode(blendMode: number);
  24764. /** Disables writing to the depth buffer when rendering the sprites.
  24765. * It can be handy to disable depth writing when using textures without alpha channel
  24766. * and setting some specific blend modes.
  24767. */
  24768. disableDepthWrite: boolean;
  24769. private _spriteRenderer;
  24770. /** Associative array from JSON sprite data file */
  24771. private _cellData;
  24772. /** Array of sprite names from JSON sprite data file */
  24773. private _spriteMap;
  24774. /** True when packed cell data from JSON file is ready*/
  24775. private _packedAndReady;
  24776. private _textureContent;
  24777. private _onDisposeObserver;
  24778. private _fromPacked;
  24779. private _scene;
  24780. /**
  24781. * Creates a new sprite manager
  24782. * @param name defines the manager's name
  24783. * @param imgUrl defines the sprite sheet url
  24784. * @param capacity defines the maximum allowed number of sprites
  24785. * @param cellSize defines the size of a sprite cell
  24786. * @param scene defines the hosting scene
  24787. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  24788. * @param samplingMode defines the sampling mode to use with spritesheet
  24789. * @param fromPacked set to false; do not alter
  24790. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  24791. */
  24792. constructor(
  24793. /** defines the manager's name */
  24794. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  24795. /**
  24796. * Returns the string "SpriteManager"
  24797. * @returns "SpriteManager"
  24798. */
  24799. getClassName(): string;
  24800. private _makePacked;
  24801. private _checkTextureAlpha;
  24802. /**
  24803. * Intersects the sprites with a ray
  24804. * @param ray defines the ray to intersect with
  24805. * @param camera defines the current active camera
  24806. * @param predicate defines a predicate used to select candidate sprites
  24807. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  24808. * @returns null if no hit or a PickingInfo
  24809. */
  24810. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  24811. /**
  24812. * Intersects the sprites with a ray
  24813. * @param ray defines the ray to intersect with
  24814. * @param camera defines the current active camera
  24815. * @param predicate defines a predicate used to select candidate sprites
  24816. * @returns null if no hit or a PickingInfo array
  24817. */
  24818. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  24819. /**
  24820. * Render all child sprites
  24821. */
  24822. render(): void;
  24823. private _customUpdate;
  24824. /**
  24825. * Release associated resources
  24826. */
  24827. dispose(): void;
  24828. /**
  24829. * Serializes the sprite manager to a JSON object
  24830. * @param serializeTexture defines if the texture must be serialized as well
  24831. * @returns the JSON object
  24832. */
  24833. serialize(serializeTexture?: boolean): any;
  24834. /**
  24835. * Parses a JSON object to create a new sprite manager.
  24836. * @param parsedManager The JSON object to parse
  24837. * @param scene The scene to create the sprite manager
  24838. * @param rootUrl The root url to use to load external dependencies like texture
  24839. * @returns the new sprite manager
  24840. */
  24841. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  24842. /**
  24843. * Creates a sprite manager from a snippet saved in a remote file
  24844. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  24845. * @param url defines the url to load from
  24846. * @param scene defines the hosting scene
  24847. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  24848. * @returns a promise that will resolve to the new sprite manager
  24849. */
  24850. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  24851. /**
  24852. * Creates a sprite manager from a snippet saved by the sprite editor
  24853. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  24854. * @param scene defines the hosting scene
  24855. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  24856. * @returns a promise that will resolve to the new sprite manager
  24857. */
  24858. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  24859. }
  24860. }
  24861. declare module BABYLON {
  24862. /**
  24863. * Class used to represent a sprite
  24864. * @see https://doc.babylonjs.com/babylon101/sprites
  24865. */
  24866. export class Sprite extends ThinSprite implements IAnimatable {
  24867. /** defines the name */
  24868. name: string;
  24869. /** Gets or sets the current world position */
  24870. position: Vector3;
  24871. /** Gets or sets the main color */
  24872. color: Color4;
  24873. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  24874. disposeWhenFinishedAnimating: boolean;
  24875. /** Gets the list of attached animations */
  24876. animations: Nullable<Array<Animation>>;
  24877. /** Gets or sets a boolean indicating if the sprite can be picked */
  24878. isPickable: boolean;
  24879. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  24880. useAlphaForPicking: boolean;
  24881. /**
  24882. * Gets or sets the associated action manager
  24883. */
  24884. actionManager: Nullable<ActionManager>;
  24885. /**
  24886. * An event triggered when the control has been disposed
  24887. */
  24888. onDisposeObservable: Observable<Sprite>;
  24889. private _manager;
  24890. private _onAnimationEnd;
  24891. /**
  24892. * Gets or sets the sprite size
  24893. */
  24894. get size(): number;
  24895. set size(value: number);
  24896. /**
  24897. * Gets or sets the unique id of the sprite
  24898. */
  24899. uniqueId: number;
  24900. /**
  24901. * Gets the manager of this sprite
  24902. */
  24903. get manager(): ISpriteManager;
  24904. /**
  24905. * Creates a new Sprite
  24906. * @param name defines the name
  24907. * @param manager defines the manager
  24908. */
  24909. constructor(
  24910. /** defines the name */
  24911. name: string, manager: ISpriteManager);
  24912. /**
  24913. * Returns the string "Sprite"
  24914. * @returns "Sprite"
  24915. */
  24916. getClassName(): string;
  24917. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  24918. get fromIndex(): number;
  24919. set fromIndex(value: number);
  24920. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  24921. get toIndex(): number;
  24922. set toIndex(value: number);
  24923. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  24924. get loopAnimation(): boolean;
  24925. set loopAnimation(value: boolean);
  24926. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  24927. get delay(): number;
  24928. set delay(value: number);
  24929. /**
  24930. * Starts an animation
  24931. * @param from defines the initial key
  24932. * @param to defines the end key
  24933. * @param loop defines if the animation must loop
  24934. * @param delay defines the start delay (in ms)
  24935. * @param onAnimationEnd defines a callback to call when animation ends
  24936. */
  24937. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  24938. private _endAnimation;
  24939. /** Release associated resources */
  24940. dispose(): void;
  24941. /**
  24942. * Serializes the sprite to a JSON object
  24943. * @returns the JSON object
  24944. */
  24945. serialize(): any;
  24946. /**
  24947. * Parses a JSON object to create a new sprite
  24948. * @param parsedSprite The JSON object to parse
  24949. * @param manager defines the hosting manager
  24950. * @returns the new sprite
  24951. */
  24952. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  24953. }
  24954. }
  24955. declare module BABYLON {
  24956. /**
  24957. * Information about the result of picking within a scene
  24958. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  24959. */
  24960. export class PickingInfo {
  24961. /** @hidden */
  24962. _pickingUnavailable: boolean;
  24963. /**
  24964. * If the pick collided with an object
  24965. */
  24966. hit: boolean;
  24967. /**
  24968. * Distance away where the pick collided
  24969. */
  24970. distance: number;
  24971. /**
  24972. * The location of pick collision
  24973. */
  24974. pickedPoint: Nullable<Vector3>;
  24975. /**
  24976. * The mesh corresponding the the pick collision
  24977. */
  24978. pickedMesh: Nullable<AbstractMesh>;
  24979. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  24980. bu: number;
  24981. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  24982. bv: number;
  24983. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  24984. faceId: number;
  24985. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  24986. subMeshFaceId: number;
  24987. /** Id of the the submesh that was picked */
  24988. subMeshId: number;
  24989. /** If a sprite was picked, this will be the sprite the pick collided with */
  24990. pickedSprite: Nullable<Sprite>;
  24991. /** If we are picking a mesh with thin instance, this will give you the picked thin instance */
  24992. thinInstanceIndex: number;
  24993. /**
  24994. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  24995. */
  24996. originMesh: Nullable<AbstractMesh>;
  24997. /**
  24998. * The ray that was used to perform the picking.
  24999. */
  25000. ray: Nullable<Ray>;
  25001. /**
  25002. * Gets the normal corresponding to the face the pick collided with
  25003. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  25004. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  25005. * @returns The normal corresponding to the face the pick collided with
  25006. */
  25007. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  25008. /**
  25009. * Gets the texture coordinates of where the pick occurred
  25010. * @returns the vector containing the coordinates of the texture
  25011. */
  25012. getTextureCoordinates(): Nullable<Vector2>;
  25013. }
  25014. }
  25015. declare module BABYLON {
  25016. /**
  25017. * Gather the list of pointer event types as constants.
  25018. */
  25019. export class PointerEventTypes {
  25020. /**
  25021. * 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.
  25022. */
  25023. static readonly POINTERDOWN: number;
  25024. /**
  25025. * The pointerup event is fired when a pointer is no longer active.
  25026. */
  25027. static readonly POINTERUP: number;
  25028. /**
  25029. * The pointermove event is fired when a pointer changes coordinates.
  25030. */
  25031. static readonly POINTERMOVE: number;
  25032. /**
  25033. * The pointerwheel event is fired when a mouse wheel has been rotated.
  25034. */
  25035. static readonly POINTERWHEEL: number;
  25036. /**
  25037. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  25038. */
  25039. static readonly POINTERPICK: number;
  25040. /**
  25041. * The pointertap event is fired when a the object has been touched and released without drag.
  25042. */
  25043. static readonly POINTERTAP: number;
  25044. /**
  25045. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  25046. */
  25047. static readonly POINTERDOUBLETAP: number;
  25048. }
  25049. /**
  25050. * Base class of pointer info types.
  25051. */
  25052. export class PointerInfoBase {
  25053. /**
  25054. * Defines the type of event (PointerEventTypes)
  25055. */
  25056. type: number;
  25057. /**
  25058. * Defines the related dom event
  25059. */
  25060. event: IMouseEvent;
  25061. /**
  25062. * Instantiates the base class of pointers info.
  25063. * @param type Defines the type of event (PointerEventTypes)
  25064. * @param event Defines the related dom event
  25065. */
  25066. constructor(
  25067. /**
  25068. * Defines the type of event (PointerEventTypes)
  25069. */
  25070. type: number,
  25071. /**
  25072. * Defines the related dom event
  25073. */
  25074. event: IMouseEvent);
  25075. }
  25076. /**
  25077. * This class is used to store pointer related info for the onPrePointerObservable event.
  25078. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  25079. */
  25080. export class PointerInfoPre extends PointerInfoBase {
  25081. /**
  25082. * Ray from a pointer if availible (eg. 6dof controller)
  25083. */
  25084. ray: Nullable<Ray>;
  25085. /**
  25086. * Defines the local position of the pointer on the canvas.
  25087. */
  25088. localPosition: Vector2;
  25089. /**
  25090. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  25091. */
  25092. skipOnPointerObservable: boolean;
  25093. /**
  25094. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  25095. * @param type Defines the type of event (PointerEventTypes)
  25096. * @param event Defines the related dom event
  25097. * @param localX Defines the local x coordinates of the pointer when the event occured
  25098. * @param localY Defines the local y coordinates of the pointer when the event occured
  25099. */
  25100. constructor(type: number, event: IMouseEvent, localX: number, localY: number);
  25101. }
  25102. /**
  25103. * This type contains all the data related to a pointer event in Babylon.js.
  25104. * 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.
  25105. */
  25106. export class PointerInfo extends PointerInfoBase {
  25107. /**
  25108. * Defines the picking info associated to the info (if any)\
  25109. */
  25110. pickInfo: Nullable<PickingInfo>;
  25111. /**
  25112. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  25113. * @param type Defines the type of event (PointerEventTypes)
  25114. * @param event Defines the related dom event
  25115. * @param pickInfo Defines the picking info associated to the info (if any)\
  25116. */
  25117. constructor(type: number, event: IMouseEvent,
  25118. /**
  25119. * Defines the picking info associated to the info (if any)\
  25120. */
  25121. pickInfo: Nullable<PickingInfo>);
  25122. }
  25123. /**
  25124. * Data relating to a touch event on the screen.
  25125. */
  25126. export interface PointerTouch {
  25127. /**
  25128. * X coordinate of touch.
  25129. */
  25130. x: number;
  25131. /**
  25132. * Y coordinate of touch.
  25133. */
  25134. y: number;
  25135. /**
  25136. * Id of touch. Unique for each finger.
  25137. */
  25138. pointerId: number;
  25139. /**
  25140. * Event type passed from DOM.
  25141. */
  25142. type: any;
  25143. }
  25144. }
  25145. declare module BABYLON {
  25146. /**
  25147. * Manage the mouse inputs to control the movement of a free camera.
  25148. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25149. */
  25150. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  25151. /**
  25152. * Define if touch is enabled in the mouse input
  25153. */
  25154. touchEnabled: boolean;
  25155. /**
  25156. * Defines the camera the input is attached to.
  25157. */
  25158. camera: FreeCamera;
  25159. /**
  25160. * Defines the buttons associated with the input to handle camera move.
  25161. */
  25162. buttons: number[];
  25163. /**
  25164. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  25165. */
  25166. angularSensibility: number;
  25167. private _pointerInput;
  25168. private _onMouseMove;
  25169. private _observer;
  25170. private previousPosition;
  25171. /**
  25172. * Observable for when a pointer move event occurs containing the move offset
  25173. */
  25174. onPointerMovedObservable: Observable<{
  25175. offsetX: number;
  25176. offsetY: number;
  25177. }>;
  25178. /**
  25179. * @hidden
  25180. * If the camera should be rotated automatically based on pointer movement
  25181. */
  25182. _allowCameraRotation: boolean;
  25183. /**
  25184. * Manage the mouse inputs to control the movement of a free camera.
  25185. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25186. * @param touchEnabled Defines if touch is enabled or not
  25187. */
  25188. constructor(
  25189. /**
  25190. * Define if touch is enabled in the mouse input
  25191. */
  25192. touchEnabled?: boolean);
  25193. /**
  25194. * Attach the input controls to a specific dom element to get the input from.
  25195. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25196. */
  25197. attachControl(noPreventDefault?: boolean): void;
  25198. /**
  25199. * Called on JS contextmenu event.
  25200. * Override this method to provide functionality.
  25201. */
  25202. protected onContextMenu(evt: PointerEvent): void;
  25203. /**
  25204. * Detach the current controls from the specified dom element.
  25205. */
  25206. detachControl(): void;
  25207. /**
  25208. * Gets the class name of the current input.
  25209. * @returns the class name
  25210. */
  25211. getClassName(): string;
  25212. /**
  25213. * Get the friendly name associated with the input class.
  25214. * @returns the input friendly name
  25215. */
  25216. getSimpleName(): string;
  25217. }
  25218. }
  25219. declare module BABYLON {
  25220. /**
  25221. * Base class for mouse wheel input..
  25222. * See FollowCameraMouseWheelInput in src/Cameras/Inputs/freeCameraMouseWheelInput.ts
  25223. * for example usage.
  25224. */
  25225. export abstract class BaseCameraMouseWheelInput implements ICameraInput<Camera> {
  25226. /**
  25227. * Defines the camera the input is attached to.
  25228. */
  25229. abstract camera: Camera;
  25230. /**
  25231. * How fast is the camera moves in relation to X axis mouseWheel events.
  25232. * Use negative value to reverse direction.
  25233. */
  25234. wheelPrecisionX: number;
  25235. /**
  25236. * How fast is the camera moves in relation to Y axis mouseWheel events.
  25237. * Use negative value to reverse direction.
  25238. */
  25239. wheelPrecisionY: number;
  25240. /**
  25241. * How fast is the camera moves in relation to Z axis mouseWheel events.
  25242. * Use negative value to reverse direction.
  25243. */
  25244. wheelPrecisionZ: number;
  25245. /**
  25246. * Observable for when a mouse wheel move event occurs.
  25247. */
  25248. onChangedObservable: Observable<{
  25249. wheelDeltaX: number;
  25250. wheelDeltaY: number;
  25251. wheelDeltaZ: number;
  25252. }>;
  25253. private _wheel;
  25254. private _observer;
  25255. /**
  25256. * Attach the input controls to a specific dom element to get the input from.
  25257. * @param noPreventDefault Defines whether event caught by the controls
  25258. * should call preventdefault().
  25259. * (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25260. */
  25261. attachControl(noPreventDefault?: boolean): void;
  25262. /**
  25263. * Detach the current controls from the specified dom element.
  25264. */
  25265. detachControl(): void;
  25266. /**
  25267. * Called for each rendered frame.
  25268. */
  25269. checkInputs(): void;
  25270. /**
  25271. * Gets the class name of the current input.
  25272. * @returns the class name
  25273. */
  25274. getClassName(): string;
  25275. /**
  25276. * Get the friendly name associated with the input class.
  25277. * @returns the input friendly name
  25278. */
  25279. getSimpleName(): string;
  25280. /**
  25281. * Incremental value of multiple mouse wheel movements of the X axis.
  25282. * Should be zero-ed when read.
  25283. */
  25284. protected _wheelDeltaX: number;
  25285. /**
  25286. * Incremental value of multiple mouse wheel movements of the Y axis.
  25287. * Should be zero-ed when read.
  25288. */
  25289. protected _wheelDeltaY: number;
  25290. /**
  25291. * Incremental value of multiple mouse wheel movements of the Z axis.
  25292. * Should be zero-ed when read.
  25293. */
  25294. protected _wheelDeltaZ: number;
  25295. /**
  25296. * Firefox uses a different scheme to report scroll distances to other
  25297. * browsers. Rather than use complicated methods to calculate the exact
  25298. * multiple we need to apply, let's just cheat and use a constant.
  25299. * https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/deltaMode
  25300. * https://stackoverflow.com/questions/20110224/what-is-the-height-of-a-line-in-a-wheel-event-deltamode-dom-delta-line
  25301. */
  25302. private readonly _ffMultiplier;
  25303. /**
  25304. * Different event attributes for wheel data fall into a few set ranges.
  25305. * Some relevant but dated date here:
  25306. * https://stackoverflow.com/questions/5527601/normalizing-mousewheel-speed-across-browsers
  25307. */
  25308. private readonly _normalize;
  25309. }
  25310. }
  25311. declare module BABYLON {
  25312. /**
  25313. * Manage the mouse wheel inputs to control a free camera.
  25314. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25315. */
  25316. export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
  25317. /**
  25318. * Defines the camera the input is attached to.
  25319. */
  25320. camera: FreeCamera;
  25321. /**
  25322. * Gets the class name of the current input.
  25323. * @returns the class name
  25324. */
  25325. getClassName(): string;
  25326. /**
  25327. * Set which movement axis (relative to camera's orientation) the mouse
  25328. * wheel's X axis controls.
  25329. * @param axis The axis to be moved. Set null to clear.
  25330. */
  25331. set wheelXMoveRelative(axis: Nullable<Coordinate>);
  25332. /**
  25333. * Get the configured movement axis (relative to camera's orientation) the
  25334. * mouse wheel's X axis controls.
  25335. * @returns The configured axis or null if none.
  25336. */
  25337. get wheelXMoveRelative(): Nullable<Coordinate>;
  25338. /**
  25339. * Set which movement axis (relative to camera's orientation) the mouse
  25340. * wheel's Y axis controls.
  25341. * @param axis The axis to be moved. Set null to clear.
  25342. */
  25343. set wheelYMoveRelative(axis: Nullable<Coordinate>);
  25344. /**
  25345. * Get the configured movement axis (relative to camera's orientation) the
  25346. * mouse wheel's Y axis controls.
  25347. * @returns The configured axis or null if none.
  25348. */
  25349. get wheelYMoveRelative(): Nullable<Coordinate>;
  25350. /**
  25351. * Set which movement axis (relative to camera's orientation) the mouse
  25352. * wheel's Z axis controls.
  25353. * @param axis The axis to be moved. Set null to clear.
  25354. */
  25355. set wheelZMoveRelative(axis: Nullable<Coordinate>);
  25356. /**
  25357. * Get the configured movement axis (relative to camera's orientation) the
  25358. * mouse wheel's Z axis controls.
  25359. * @returns The configured axis or null if none.
  25360. */
  25361. get wheelZMoveRelative(): Nullable<Coordinate>;
  25362. /**
  25363. * Set which rotation axis (relative to camera's orientation) the mouse
  25364. * wheel's X axis controls.
  25365. * @param axis The axis to be moved. Set null to clear.
  25366. */
  25367. set wheelXRotateRelative(axis: Nullable<Coordinate>);
  25368. /**
  25369. * Get the configured rotation axis (relative to camera's orientation) the
  25370. * mouse wheel's X axis controls.
  25371. * @returns The configured axis or null if none.
  25372. */
  25373. get wheelXRotateRelative(): Nullable<Coordinate>;
  25374. /**
  25375. * Set which rotation axis (relative to camera's orientation) the mouse
  25376. * wheel's Y axis controls.
  25377. * @param axis The axis to be moved. Set null to clear.
  25378. */
  25379. set wheelYRotateRelative(axis: Nullable<Coordinate>);
  25380. /**
  25381. * Get the configured rotation axis (relative to camera's orientation) the
  25382. * mouse wheel's Y axis controls.
  25383. * @returns The configured axis or null if none.
  25384. */
  25385. get wheelYRotateRelative(): Nullable<Coordinate>;
  25386. /**
  25387. * Set which rotation axis (relative to camera's orientation) the mouse
  25388. * wheel's Z axis controls.
  25389. * @param axis The axis to be moved. Set null to clear.
  25390. */
  25391. set wheelZRotateRelative(axis: Nullable<Coordinate>);
  25392. /**
  25393. * Get the configured rotation axis (relative to camera's orientation) the
  25394. * mouse wheel's Z axis controls.
  25395. * @returns The configured axis or null if none.
  25396. */
  25397. get wheelZRotateRelative(): Nullable<Coordinate>;
  25398. /**
  25399. * Set which movement axis (relative to the scene) the mouse wheel's X axis
  25400. * controls.
  25401. * @param axis The axis to be moved. Set null to clear.
  25402. */
  25403. set wheelXMoveScene(axis: Nullable<Coordinate>);
  25404. /**
  25405. * Get the configured movement axis (relative to the scene) the mouse wheel's
  25406. * X axis controls.
  25407. * @returns The configured axis or null if none.
  25408. */
  25409. get wheelXMoveScene(): Nullable<Coordinate>;
  25410. /**
  25411. * Set which movement axis (relative to the scene) the mouse wheel's Y axis
  25412. * controls.
  25413. * @param axis The axis to be moved. Set null to clear.
  25414. */
  25415. set wheelYMoveScene(axis: Nullable<Coordinate>);
  25416. /**
  25417. * Get the configured movement axis (relative to the scene) the mouse wheel's
  25418. * Y axis controls.
  25419. * @returns The configured axis or null if none.
  25420. */
  25421. get wheelYMoveScene(): Nullable<Coordinate>;
  25422. /**
  25423. * Set which movement axis (relative to the scene) the mouse wheel's Z axis
  25424. * controls.
  25425. * @param axis The axis to be moved. Set null to clear.
  25426. */
  25427. set wheelZMoveScene(axis: Nullable<Coordinate>);
  25428. /**
  25429. * Get the configured movement axis (relative to the scene) the mouse wheel's
  25430. * Z axis controls.
  25431. * @returns The configured axis or null if none.
  25432. */
  25433. get wheelZMoveScene(): Nullable<Coordinate>;
  25434. /**
  25435. * Called for each rendered frame.
  25436. */
  25437. checkInputs(): void;
  25438. private _moveRelative;
  25439. private _rotateRelative;
  25440. private _moveScene;
  25441. /**
  25442. * These are set to the desired default behaviour.
  25443. */
  25444. private _wheelXAction;
  25445. private _wheelXActionCoordinate;
  25446. private _wheelYAction;
  25447. private _wheelYActionCoordinate;
  25448. private _wheelZAction;
  25449. private _wheelZActionCoordinate;
  25450. /**
  25451. * Update the camera according to any configured properties for the 3
  25452. * mouse-wheel axis.
  25453. */
  25454. private _updateCamera;
  25455. /**
  25456. * Update one property of the camera.
  25457. */
  25458. private _updateCameraProperty;
  25459. }
  25460. }
  25461. declare module BABYLON {
  25462. /**
  25463. * Manage the touch inputs to control the movement of a free camera.
  25464. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25465. */
  25466. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  25467. /**
  25468. * Define if mouse events can be treated as touch events
  25469. */
  25470. allowMouse: boolean;
  25471. /**
  25472. * Defines the camera the input is attached to.
  25473. */
  25474. camera: FreeCamera;
  25475. /**
  25476. * Defines the touch sensibility for rotation.
  25477. * The higher the faster.
  25478. */
  25479. touchAngularSensibility: number;
  25480. /**
  25481. * Defines the touch sensibility for move.
  25482. * The higher the faster.
  25483. */
  25484. touchMoveSensibility: number;
  25485. private _offsetX;
  25486. private _offsetY;
  25487. private _pointerPressed;
  25488. private _pointerInput?;
  25489. private _observer;
  25490. private _onLostFocus;
  25491. /**
  25492. * Manage the touch inputs to control the movement of a free camera.
  25493. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25494. * @param allowMouse Defines if mouse events can be treated as touch events
  25495. */
  25496. constructor(
  25497. /**
  25498. * Define if mouse events can be treated as touch events
  25499. */
  25500. allowMouse?: boolean);
  25501. /**
  25502. * Attach the input controls to a specific dom element to get the input from.
  25503. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25504. */
  25505. attachControl(noPreventDefault?: boolean): void;
  25506. /**
  25507. * Detach the current controls from the specified dom element.
  25508. */
  25509. detachControl(): void;
  25510. /**
  25511. * Update the current camera state depending on the inputs that have been used this frame.
  25512. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  25513. */
  25514. checkInputs(): void;
  25515. /**
  25516. * Gets the class name of the current input.
  25517. * @returns the class name
  25518. */
  25519. getClassName(): string;
  25520. /**
  25521. * Get the friendly name associated with the input class.
  25522. * @returns the input friendly name
  25523. */
  25524. getSimpleName(): string;
  25525. }
  25526. }
  25527. declare module BABYLON {
  25528. /**
  25529. * Default Inputs manager for the FreeCamera.
  25530. * It groups all the default supported inputs for ease of use.
  25531. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25532. */
  25533. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  25534. /**
  25535. * @hidden
  25536. */
  25537. _mouseInput: Nullable<FreeCameraMouseInput>;
  25538. /**
  25539. * @hidden
  25540. */
  25541. _mouseWheelInput: Nullable<FreeCameraMouseWheelInput>;
  25542. /**
  25543. * Instantiates a new FreeCameraInputsManager.
  25544. * @param camera Defines the camera the inputs belong to
  25545. */
  25546. constructor(camera: FreeCamera);
  25547. /**
  25548. * Add keyboard input support to the input manager.
  25549. * @returns the current input manager
  25550. */
  25551. addKeyboard(): FreeCameraInputsManager;
  25552. /**
  25553. * Add mouse input support to the input manager.
  25554. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  25555. * @returns the current input manager
  25556. */
  25557. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  25558. /**
  25559. * Removes the mouse input support from the manager
  25560. * @returns the current input manager
  25561. */
  25562. removeMouse(): FreeCameraInputsManager;
  25563. /**
  25564. * Add mouse wheel input support to the input manager.
  25565. * @returns the current input manager
  25566. */
  25567. addMouseWheel(): FreeCameraInputsManager;
  25568. /**
  25569. * Removes the mouse wheel input support from the manager
  25570. * @returns the current input manager
  25571. */
  25572. removeMouseWheel(): FreeCameraInputsManager;
  25573. /**
  25574. * Add touch input support to the input manager.
  25575. * @returns the current input manager
  25576. */
  25577. addTouch(): FreeCameraInputsManager;
  25578. /**
  25579. * Remove all attached input methods from a camera
  25580. */
  25581. clear(): void;
  25582. }
  25583. }
  25584. declare module BABYLON {
  25585. /**
  25586. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  25587. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  25588. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  25589. */
  25590. export class FreeCamera extends TargetCamera {
  25591. /**
  25592. * Define the collision ellipsoid of the camera.
  25593. * This is helpful to simulate a camera body like the player body around the camera
  25594. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  25595. */
  25596. ellipsoid: Vector3;
  25597. /**
  25598. * Define an offset for the position of the ellipsoid around the camera.
  25599. * This can be helpful to determine the center of the body near the gravity center of the body
  25600. * instead of its head.
  25601. */
  25602. ellipsoidOffset: Vector3;
  25603. /**
  25604. * Enable or disable collisions of the camera with the rest of the scene objects.
  25605. */
  25606. checkCollisions: boolean;
  25607. /**
  25608. * Enable or disable gravity on the camera.
  25609. */
  25610. applyGravity: boolean;
  25611. /**
  25612. * Define the input manager associated to the camera.
  25613. */
  25614. inputs: FreeCameraInputsManager;
  25615. /**
  25616. * Gets the input sensibility for a mouse input. (default is 2000.0)
  25617. * Higher values reduce sensitivity.
  25618. */
  25619. get angularSensibility(): number;
  25620. /**
  25621. * Sets the input sensibility for a mouse input. (default is 2000.0)
  25622. * Higher values reduce sensitivity.
  25623. */
  25624. set angularSensibility(value: number);
  25625. /**
  25626. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  25627. */
  25628. get keysUp(): number[];
  25629. set keysUp(value: number[]);
  25630. /**
  25631. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  25632. */
  25633. get keysUpward(): number[];
  25634. set keysUpward(value: number[]);
  25635. /**
  25636. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  25637. */
  25638. get keysDown(): number[];
  25639. set keysDown(value: number[]);
  25640. /**
  25641. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  25642. */
  25643. get keysDownward(): number[];
  25644. set keysDownward(value: number[]);
  25645. /**
  25646. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  25647. */
  25648. get keysLeft(): number[];
  25649. set keysLeft(value: number[]);
  25650. /**
  25651. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  25652. */
  25653. get keysRight(): number[];
  25654. set keysRight(value: number[]);
  25655. /**
  25656. * Event raised when the camera collide with a mesh in the scene.
  25657. */
  25658. onCollide: (collidedMesh: AbstractMesh) => void;
  25659. private _collider;
  25660. private _needMoveForGravity;
  25661. private _oldPosition;
  25662. private _diffPosition;
  25663. private _newPosition;
  25664. /** @hidden */
  25665. _localDirection: Vector3;
  25666. /** @hidden */
  25667. _transformedDirection: Vector3;
  25668. /**
  25669. * Instantiates a Free Camera.
  25670. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  25671. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  25672. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  25673. * @param name Define the name of the camera in the scene
  25674. * @param position Define the start position of the camera in the scene
  25675. * @param scene Define the scene the camera belongs to
  25676. * @param setActiveOnSceneIfNoneActive Defines whether the camera should be marked as active if not other active cameras have been defined
  25677. */
  25678. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25679. /**
  25680. * Attach the input controls to a specific dom element to get the input from.
  25681. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25682. */
  25683. attachControl(noPreventDefault?: boolean): void;
  25684. /**
  25685. * Attach the input controls to a specific dom element to get the input from.
  25686. * @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
  25687. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25688. * BACK COMPAT SIGNATURE ONLY.
  25689. */
  25690. attachControl(ignored: any, noPreventDefault?: boolean): void;
  25691. /**
  25692. * Detach the current controls from the specified dom element.
  25693. */
  25694. detachControl(): void;
  25695. /**
  25696. * Detach the current controls from the specified dom element.
  25697. * @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
  25698. */
  25699. detachControl(ignored: any): void;
  25700. private _collisionMask;
  25701. /**
  25702. * Define a collision mask to limit the list of object the camera can collide with
  25703. */
  25704. get collisionMask(): number;
  25705. set collisionMask(mask: number);
  25706. /** @hidden */
  25707. _collideWithWorld(displacement: Vector3): void;
  25708. private _onCollisionPositionChange;
  25709. /** @hidden */
  25710. _checkInputs(): void;
  25711. /** @hidden */
  25712. _decideIfNeedsToMove(): boolean;
  25713. /** @hidden */
  25714. _updatePosition(): void;
  25715. /**
  25716. * Destroy the camera and release the current resources hold by it.
  25717. */
  25718. dispose(): void;
  25719. /**
  25720. * Gets the current object class name.
  25721. * @return the class name
  25722. */
  25723. getClassName(): string;
  25724. }
  25725. }
  25726. declare module BABYLON {
  25727. /**
  25728. * Represents a gamepad control stick position
  25729. */
  25730. export class StickValues {
  25731. /**
  25732. * The x component of the control stick
  25733. */
  25734. x: number;
  25735. /**
  25736. * The y component of the control stick
  25737. */
  25738. y: number;
  25739. /**
  25740. * Initializes the gamepad x and y control stick values
  25741. * @param x The x component of the gamepad control stick value
  25742. * @param y The y component of the gamepad control stick value
  25743. */
  25744. constructor(
  25745. /**
  25746. * The x component of the control stick
  25747. */
  25748. x: number,
  25749. /**
  25750. * The y component of the control stick
  25751. */
  25752. y: number);
  25753. }
  25754. /**
  25755. * An interface which manages callbacks for gamepad button changes
  25756. */
  25757. export interface GamepadButtonChanges {
  25758. /**
  25759. * Called when a gamepad has been changed
  25760. */
  25761. changed: boolean;
  25762. /**
  25763. * Called when a gamepad press event has been triggered
  25764. */
  25765. pressChanged: boolean;
  25766. /**
  25767. * Called when a touch event has been triggered
  25768. */
  25769. touchChanged: boolean;
  25770. /**
  25771. * Called when a value has changed
  25772. */
  25773. valueChanged: boolean;
  25774. }
  25775. /**
  25776. * Represents a gamepad
  25777. */
  25778. export class Gamepad {
  25779. /**
  25780. * The id of the gamepad
  25781. */
  25782. id: string;
  25783. /**
  25784. * The index of the gamepad
  25785. */
  25786. index: number;
  25787. /**
  25788. * The browser gamepad
  25789. */
  25790. browserGamepad: any;
  25791. /**
  25792. * Specifies what type of gamepad this represents
  25793. */
  25794. type: number;
  25795. private _leftStick;
  25796. private _rightStick;
  25797. /** @hidden */
  25798. _isConnected: boolean;
  25799. private _leftStickAxisX;
  25800. private _leftStickAxisY;
  25801. private _rightStickAxisX;
  25802. private _rightStickAxisY;
  25803. /**
  25804. * Triggered when the left control stick has been changed
  25805. */
  25806. private _onleftstickchanged;
  25807. /**
  25808. * Triggered when the right control stick has been changed
  25809. */
  25810. private _onrightstickchanged;
  25811. /**
  25812. * Represents a gamepad controller
  25813. */
  25814. static GAMEPAD: number;
  25815. /**
  25816. * Represents a generic controller
  25817. */
  25818. static GENERIC: number;
  25819. /**
  25820. * Represents an XBox controller
  25821. */
  25822. static XBOX: number;
  25823. /**
  25824. * Represents a pose-enabled controller
  25825. */
  25826. static POSE_ENABLED: number;
  25827. /**
  25828. * Represents an Dual Shock controller
  25829. */
  25830. static DUALSHOCK: number;
  25831. /**
  25832. * Specifies whether the left control stick should be Y-inverted
  25833. */
  25834. protected _invertLeftStickY: boolean;
  25835. /**
  25836. * Specifies if the gamepad has been connected
  25837. */
  25838. get isConnected(): boolean;
  25839. /**
  25840. * Initializes the gamepad
  25841. * @param id The id of the gamepad
  25842. * @param index The index of the gamepad
  25843. * @param browserGamepad The browser gamepad
  25844. * @param leftStickX The x component of the left joystick
  25845. * @param leftStickY The y component of the left joystick
  25846. * @param rightStickX The x component of the right joystick
  25847. * @param rightStickY The y component of the right joystick
  25848. */
  25849. constructor(
  25850. /**
  25851. * The id of the gamepad
  25852. */
  25853. id: string,
  25854. /**
  25855. * The index of the gamepad
  25856. */
  25857. index: number,
  25858. /**
  25859. * The browser gamepad
  25860. */
  25861. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  25862. /**
  25863. * Callback triggered when the left joystick has changed
  25864. * @param callback
  25865. */
  25866. onleftstickchanged(callback: (values: StickValues) => void): void;
  25867. /**
  25868. * Callback triggered when the right joystick has changed
  25869. * @param callback
  25870. */
  25871. onrightstickchanged(callback: (values: StickValues) => void): void;
  25872. /**
  25873. * Gets the left joystick
  25874. */
  25875. get leftStick(): StickValues;
  25876. /**
  25877. * Sets the left joystick values
  25878. */
  25879. set leftStick(newValues: StickValues);
  25880. /**
  25881. * Gets the right joystick
  25882. */
  25883. get rightStick(): StickValues;
  25884. /**
  25885. * Sets the right joystick value
  25886. */
  25887. set rightStick(newValues: StickValues);
  25888. /**
  25889. * Updates the gamepad joystick positions
  25890. */
  25891. update(): void;
  25892. /**
  25893. * Disposes the gamepad
  25894. */
  25895. dispose(): void;
  25896. }
  25897. /**
  25898. * Represents a generic gamepad
  25899. */
  25900. export class GenericPad extends Gamepad {
  25901. private _buttons;
  25902. private _onbuttondown;
  25903. private _onbuttonup;
  25904. /**
  25905. * Observable triggered when a button has been pressed
  25906. */
  25907. onButtonDownObservable: Observable<number>;
  25908. /**
  25909. * Observable triggered when a button has been released
  25910. */
  25911. onButtonUpObservable: Observable<number>;
  25912. /**
  25913. * Callback triggered when a button has been pressed
  25914. * @param callback Called when a button has been pressed
  25915. */
  25916. onbuttondown(callback: (buttonPressed: number) => void): void;
  25917. /**
  25918. * Callback triggered when a button has been released
  25919. * @param callback Called when a button has been released
  25920. */
  25921. onbuttonup(callback: (buttonReleased: number) => void): void;
  25922. /**
  25923. * Initializes the generic gamepad
  25924. * @param id The id of the generic gamepad
  25925. * @param index The index of the generic gamepad
  25926. * @param browserGamepad The browser gamepad
  25927. */
  25928. constructor(id: string, index: number, browserGamepad: any);
  25929. private _setButtonValue;
  25930. /**
  25931. * Updates the generic gamepad
  25932. */
  25933. update(): void;
  25934. /**
  25935. * Disposes the generic gamepad
  25936. */
  25937. dispose(): void;
  25938. }
  25939. }
  25940. declare module BABYLON {
  25941. /**
  25942. * Defines a runtime animation
  25943. */
  25944. export class RuntimeAnimation {
  25945. private _events;
  25946. /**
  25947. * The current frame of the runtime animation
  25948. */
  25949. private _currentFrame;
  25950. /**
  25951. * The animation used by the runtime animation
  25952. */
  25953. private _animation;
  25954. /**
  25955. * The target of the runtime animation
  25956. */
  25957. private _target;
  25958. /**
  25959. * The initiating animatable
  25960. */
  25961. private _host;
  25962. /**
  25963. * The original value of the runtime animation
  25964. */
  25965. private _originalValue;
  25966. /**
  25967. * The original blend value of the runtime animation
  25968. */
  25969. private _originalBlendValue;
  25970. /**
  25971. * The offsets cache of the runtime animation
  25972. */
  25973. private _offsetsCache;
  25974. /**
  25975. * The high limits cache of the runtime animation
  25976. */
  25977. private _highLimitsCache;
  25978. /**
  25979. * Specifies if the runtime animation has been stopped
  25980. */
  25981. private _stopped;
  25982. /**
  25983. * The blending factor of the runtime animation
  25984. */
  25985. private _blendingFactor;
  25986. /**
  25987. * The BabylonJS scene
  25988. */
  25989. private _scene;
  25990. /**
  25991. * The current value of the runtime animation
  25992. */
  25993. private _currentValue;
  25994. /** @hidden */
  25995. _animationState: _IAnimationState;
  25996. /**
  25997. * The active target of the runtime animation
  25998. */
  25999. private _activeTargets;
  26000. private _currentActiveTarget;
  26001. private _directTarget;
  26002. /**
  26003. * The target path of the runtime animation
  26004. */
  26005. private _targetPath;
  26006. /**
  26007. * The weight of the runtime animation
  26008. */
  26009. private _weight;
  26010. /**
  26011. * The ratio offset of the runtime animation
  26012. */
  26013. private _ratioOffset;
  26014. /**
  26015. * The previous delay of the runtime animation
  26016. */
  26017. private _previousDelay;
  26018. /**
  26019. * The previous ratio of the runtime animation
  26020. */
  26021. private _previousRatio;
  26022. private _enableBlending;
  26023. private _keys;
  26024. private _minFrame;
  26025. private _maxFrame;
  26026. private _minValue;
  26027. private _maxValue;
  26028. private _targetIsArray;
  26029. /**
  26030. * Gets the current frame of the runtime animation
  26031. */
  26032. get currentFrame(): number;
  26033. /**
  26034. * Gets the weight of the runtime animation
  26035. */
  26036. get weight(): number;
  26037. /**
  26038. * Gets the current value of the runtime animation
  26039. */
  26040. get currentValue(): any;
  26041. /**
  26042. * Gets the target path of the runtime animation
  26043. */
  26044. get targetPath(): string;
  26045. /**
  26046. * Gets the actual target of the runtime animation
  26047. */
  26048. get target(): any;
  26049. /**
  26050. * Gets the additive state of the runtime animation
  26051. */
  26052. get isAdditive(): boolean;
  26053. /** @hidden */
  26054. _onLoop: () => void;
  26055. /**
  26056. * Create a new RuntimeAnimation object
  26057. * @param target defines the target of the animation
  26058. * @param animation defines the source animation object
  26059. * @param scene defines the hosting scene
  26060. * @param host defines the initiating Animatable
  26061. */
  26062. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  26063. private _preparePath;
  26064. /**
  26065. * Gets the animation from the runtime animation
  26066. */
  26067. get animation(): Animation;
  26068. /**
  26069. * Resets the runtime animation to the beginning
  26070. * @param restoreOriginal defines whether to restore the target property to the original value
  26071. */
  26072. reset(restoreOriginal?: boolean): void;
  26073. /**
  26074. * Specifies if the runtime animation is stopped
  26075. * @returns Boolean specifying if the runtime animation is stopped
  26076. */
  26077. isStopped(): boolean;
  26078. /**
  26079. * Disposes of the runtime animation
  26080. */
  26081. dispose(): void;
  26082. /**
  26083. * Apply the interpolated value to the target
  26084. * @param currentValue defines the value computed by the animation
  26085. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  26086. */
  26087. setValue(currentValue: any, weight: number): void;
  26088. private _getOriginalValues;
  26089. private _setValue;
  26090. /**
  26091. * Gets the loop pmode of the runtime animation
  26092. * @returns Loop Mode
  26093. */
  26094. private _getCorrectLoopMode;
  26095. /**
  26096. * Move the current animation to a given frame
  26097. * @param frame defines the frame to move to
  26098. */
  26099. goToFrame(frame: number): void;
  26100. /**
  26101. * @hidden Internal use only
  26102. */
  26103. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  26104. /**
  26105. * Execute the current animation
  26106. * @param delay defines the delay to add to the current frame
  26107. * @param from defines the lower bound of the animation range
  26108. * @param to defines the upper bound of the animation range
  26109. * @param loop defines if the current animation must loop
  26110. * @param speedRatio defines the current speed ratio
  26111. * @param weight defines the weight of the animation (default is -1 so no weight)
  26112. * @param onLoop optional callback called when animation loops
  26113. * @returns a boolean indicating if the animation is running
  26114. */
  26115. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  26116. }
  26117. }
  26118. declare module BABYLON {
  26119. /**
  26120. * Class used to store an actual running animation
  26121. */
  26122. export class Animatable {
  26123. /** defines the target object */
  26124. target: any;
  26125. /** defines the starting frame number (default is 0) */
  26126. fromFrame: number;
  26127. /** defines the ending frame number (default is 100) */
  26128. toFrame: number;
  26129. /** defines if the animation must loop (default is false) */
  26130. loopAnimation: boolean;
  26131. /** defines a callback to call when animation ends if it is not looping */
  26132. onAnimationEnd?: (() => void) | null | undefined;
  26133. /** defines a callback to call when animation loops */
  26134. onAnimationLoop?: (() => void) | null | undefined;
  26135. /** defines whether the animation should be evaluated additively */
  26136. isAdditive: boolean;
  26137. private _localDelayOffset;
  26138. private _pausedDelay;
  26139. private _runtimeAnimations;
  26140. private _paused;
  26141. private _scene;
  26142. private _speedRatio;
  26143. private _weight;
  26144. private _syncRoot;
  26145. /**
  26146. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  26147. * This will only apply for non looping animation (default is true)
  26148. */
  26149. disposeOnEnd: boolean;
  26150. /**
  26151. * Gets a boolean indicating if the animation has started
  26152. */
  26153. animationStarted: boolean;
  26154. /**
  26155. * Observer raised when the animation ends
  26156. */
  26157. onAnimationEndObservable: Observable<Animatable>;
  26158. /**
  26159. * Observer raised when the animation loops
  26160. */
  26161. onAnimationLoopObservable: Observable<Animatable>;
  26162. /**
  26163. * Gets the root Animatable used to synchronize and normalize animations
  26164. */
  26165. get syncRoot(): Nullable<Animatable>;
  26166. /**
  26167. * Gets the current frame of the first RuntimeAnimation
  26168. * Used to synchronize Animatables
  26169. */
  26170. get masterFrame(): number;
  26171. /**
  26172. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  26173. */
  26174. get weight(): number;
  26175. set weight(value: number);
  26176. /**
  26177. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  26178. */
  26179. get speedRatio(): number;
  26180. set speedRatio(value: number);
  26181. /**
  26182. * Creates a new Animatable
  26183. * @param scene defines the hosting scene
  26184. * @param target defines the target object
  26185. * @param fromFrame defines the starting frame number (default is 0)
  26186. * @param toFrame defines the ending frame number (default is 100)
  26187. * @param loopAnimation defines if the animation must loop (default is false)
  26188. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  26189. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  26190. * @param animations defines a group of animation to add to the new Animatable
  26191. * @param onAnimationLoop defines a callback to call when animation loops
  26192. * @param isAdditive defines whether the animation should be evaluated additively
  26193. */
  26194. constructor(scene: Scene,
  26195. /** defines the target object */
  26196. target: any,
  26197. /** defines the starting frame number (default is 0) */
  26198. fromFrame?: number,
  26199. /** defines the ending frame number (default is 100) */
  26200. toFrame?: number,
  26201. /** defines if the animation must loop (default is false) */
  26202. loopAnimation?: boolean, speedRatio?: number,
  26203. /** defines a callback to call when animation ends if it is not looping */
  26204. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  26205. /** defines a callback to call when animation loops */
  26206. onAnimationLoop?: (() => void) | null | undefined,
  26207. /** defines whether the animation should be evaluated additively */
  26208. isAdditive?: boolean);
  26209. /**
  26210. * Synchronize and normalize current Animatable with a source Animatable
  26211. * This is useful when using animation weights and when animations are not of the same length
  26212. * @param root defines the root Animatable to synchronize with
  26213. * @returns the current Animatable
  26214. */
  26215. syncWith(root: Animatable): Animatable;
  26216. /**
  26217. * Gets the list of runtime animations
  26218. * @returns an array of RuntimeAnimation
  26219. */
  26220. getAnimations(): RuntimeAnimation[];
  26221. /**
  26222. * Adds more animations to the current animatable
  26223. * @param target defines the target of the animations
  26224. * @param animations defines the new animations to add
  26225. */
  26226. appendAnimations(target: any, animations: Animation[]): void;
  26227. /**
  26228. * Gets the source animation for a specific property
  26229. * @param property defines the property to look for
  26230. * @returns null or the source animation for the given property
  26231. */
  26232. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  26233. /**
  26234. * Gets the runtime animation for a specific property
  26235. * @param property defines the property to look for
  26236. * @returns null or the runtime animation for the given property
  26237. */
  26238. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  26239. /**
  26240. * Resets the animatable to its original state
  26241. */
  26242. reset(): void;
  26243. /**
  26244. * Allows the animatable to blend with current running animations
  26245. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  26246. * @param blendingSpeed defines the blending speed to use
  26247. */
  26248. enableBlending(blendingSpeed: number): void;
  26249. /**
  26250. * Disable animation blending
  26251. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  26252. */
  26253. disableBlending(): void;
  26254. /**
  26255. * Jump directly to a given frame
  26256. * @param frame defines the frame to jump to
  26257. */
  26258. goToFrame(frame: number): void;
  26259. /**
  26260. * Pause the animation
  26261. */
  26262. pause(): void;
  26263. /**
  26264. * Restart the animation
  26265. */
  26266. restart(): void;
  26267. private _raiseOnAnimationEnd;
  26268. /**
  26269. * Stop and delete the current animation
  26270. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  26271. * @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)
  26272. */
  26273. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  26274. /**
  26275. * Wait asynchronously for the animation to end
  26276. * @returns a promise which will be fulfilled when the animation ends
  26277. */
  26278. waitAsync(): Promise<Animatable>;
  26279. /** @hidden */
  26280. _animate(delay: number): boolean;
  26281. }
  26282. interface Scene {
  26283. /** @hidden */
  26284. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  26285. /** @hidden */
  26286. _processLateAnimationBindingsForMatrices(holder: {
  26287. totalWeight: number;
  26288. totalAdditiveWeight: number;
  26289. animations: RuntimeAnimation[];
  26290. additiveAnimations: RuntimeAnimation[];
  26291. originalValue: Matrix;
  26292. }): any;
  26293. /** @hidden */
  26294. _processLateAnimationBindingsForQuaternions(holder: {
  26295. totalWeight: number;
  26296. totalAdditiveWeight: number;
  26297. animations: RuntimeAnimation[];
  26298. additiveAnimations: RuntimeAnimation[];
  26299. originalValue: Quaternion;
  26300. }, refQuaternion: Quaternion): Quaternion;
  26301. /** @hidden */
  26302. _processLateAnimationBindings(): void;
  26303. /**
  26304. * Will start the animation sequence of a given target
  26305. * @param target defines the target
  26306. * @param from defines from which frame should animation start
  26307. * @param to defines until which frame should animation run.
  26308. * @param weight defines the weight to apply to the animation (1.0 by default)
  26309. * @param loop defines if the animation loops
  26310. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  26311. * @param onAnimationEnd defines the function to be executed when the animation ends
  26312. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  26313. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  26314. * @param onAnimationLoop defines the callback to call when an animation loops
  26315. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  26316. * @returns the animatable object created for this animation
  26317. */
  26318. 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;
  26319. /**
  26320. * Will start the animation sequence of a given target
  26321. * @param target defines the target
  26322. * @param from defines from which frame should animation start
  26323. * @param to defines until which frame should animation run.
  26324. * @param loop defines if the animation loops
  26325. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  26326. * @param onAnimationEnd defines the function to be executed when the animation ends
  26327. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  26328. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  26329. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  26330. * @param onAnimationLoop defines the callback to call when an animation loops
  26331. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  26332. * @returns the animatable object created for this animation
  26333. */
  26334. 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;
  26335. /**
  26336. * Will start the animation sequence of a given target and its hierarchy
  26337. * @param target defines the target
  26338. * @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.
  26339. * @param from defines from which frame should animation start
  26340. * @param to defines until which frame should animation run.
  26341. * @param loop defines if the animation loops
  26342. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  26343. * @param onAnimationEnd defines the function to be executed when the animation ends
  26344. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  26345. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  26346. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  26347. * @param onAnimationLoop defines the callback to call when an animation loops
  26348. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  26349. * @returns the list of created animatables
  26350. */
  26351. 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[];
  26352. /**
  26353. * Begin a new animation on a given node
  26354. * @param target defines the target where the animation will take place
  26355. * @param animations defines the list of animations to start
  26356. * @param from defines the initial value
  26357. * @param to defines the final value
  26358. * @param loop defines if you want animation to loop (off by default)
  26359. * @param speedRatio defines the speed ratio to apply to all animations
  26360. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26361. * @param onAnimationLoop defines the callback to call when an animation loops
  26362. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  26363. * @returns the list of created animatables
  26364. */
  26365. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  26366. /**
  26367. * Begin a new animation on a given node and its hierarchy
  26368. * @param target defines the root node where the animation will take place
  26369. * @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.
  26370. * @param animations defines the list of animations to start
  26371. * @param from defines the initial value
  26372. * @param to defines the final value
  26373. * @param loop defines if you want animation to loop (off by default)
  26374. * @param speedRatio defines the speed ratio to apply to all animations
  26375. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26376. * @param onAnimationLoop defines the callback to call when an animation loops
  26377. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  26378. * @returns the list of animatables created for all nodes
  26379. */
  26380. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  26381. /**
  26382. * Gets the animatable associated with a specific target
  26383. * @param target defines the target of the animatable
  26384. * @returns the required animatable if found
  26385. */
  26386. getAnimatableByTarget(target: any): Nullable<Animatable>;
  26387. /**
  26388. * Gets all animatables associated with a given target
  26389. * @param target defines the target to look animatables for
  26390. * @returns an array of Animatables
  26391. */
  26392. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  26393. /**
  26394. * Stops and removes all animations that have been applied to the scene
  26395. */
  26396. stopAllAnimations(): void;
  26397. /**
  26398. * Gets the current delta time used by animation engine
  26399. */
  26400. deltaTime: number;
  26401. }
  26402. interface Bone {
  26403. /**
  26404. * Copy an animation range from another bone
  26405. * @param source defines the source bone
  26406. * @param rangeName defines the range name to copy
  26407. * @param frameOffset defines the frame offset
  26408. * @param rescaleAsRequired defines if rescaling must be applied if required
  26409. * @param skelDimensionsRatio defines the scaling ratio
  26410. * @returns true if operation was successful
  26411. */
  26412. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  26413. }
  26414. }
  26415. declare module BABYLON {
  26416. /**
  26417. * Class used to override all child animations of a given target
  26418. */
  26419. export class AnimationPropertiesOverride {
  26420. /**
  26421. * Gets or sets a value indicating if animation blending must be used
  26422. */
  26423. enableBlending: boolean;
  26424. /**
  26425. * Gets or sets the blending speed to use when enableBlending is true
  26426. */
  26427. blendingSpeed: number;
  26428. /**
  26429. * Gets or sets the default loop mode to use
  26430. */
  26431. loopMode: number;
  26432. }
  26433. }
  26434. declare module BABYLON {
  26435. /**
  26436. * Class used to handle skinning animations
  26437. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26438. */
  26439. export class Skeleton implements IAnimatable {
  26440. /** defines the skeleton name */
  26441. name: string;
  26442. /** defines the skeleton Id */
  26443. id: string;
  26444. /**
  26445. * Defines the list of child bones
  26446. */
  26447. bones: Bone[];
  26448. /**
  26449. * Defines an estimate of the dimension of the skeleton at rest
  26450. */
  26451. dimensionsAtRest: Vector3;
  26452. /**
  26453. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  26454. */
  26455. needInitialSkinMatrix: boolean;
  26456. /**
  26457. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  26458. */
  26459. overrideMesh: Nullable<AbstractMesh>;
  26460. /**
  26461. * Gets the list of animations attached to this skeleton
  26462. */
  26463. animations: Array<Animation>;
  26464. private _scene;
  26465. private _isDirty;
  26466. private _transformMatrices;
  26467. private _transformMatrixTexture;
  26468. private _meshesWithPoseMatrix;
  26469. private _animatables;
  26470. private _identity;
  26471. private _synchronizedWithMesh;
  26472. private _ranges;
  26473. private _lastAbsoluteTransformsUpdateId;
  26474. private _canUseTextureForBones;
  26475. private _uniqueId;
  26476. /** @hidden */
  26477. _numBonesWithLinkedTransformNode: number;
  26478. /** @hidden */
  26479. _hasWaitingData: Nullable<boolean>;
  26480. /** @hidden */
  26481. _waitingOverrideMeshId: Nullable<string>;
  26482. /**
  26483. * Specifies if the skeleton should be serialized
  26484. */
  26485. doNotSerialize: boolean;
  26486. private _useTextureToStoreBoneMatrices;
  26487. /**
  26488. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  26489. * Please note that this option is not available if the hardware does not support it
  26490. */
  26491. get useTextureToStoreBoneMatrices(): boolean;
  26492. set useTextureToStoreBoneMatrices(value: boolean);
  26493. private _animationPropertiesOverride;
  26494. /**
  26495. * Gets or sets the animation properties override
  26496. */
  26497. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  26498. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  26499. /**
  26500. * List of inspectable custom properties (used by the Inspector)
  26501. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  26502. */
  26503. inspectableCustomProperties: IInspectable[];
  26504. /**
  26505. * An observable triggered before computing the skeleton's matrices
  26506. */
  26507. onBeforeComputeObservable: Observable<Skeleton>;
  26508. /**
  26509. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  26510. */
  26511. get isUsingTextureForMatrices(): boolean;
  26512. /**
  26513. * Gets the unique ID of this skeleton
  26514. */
  26515. get uniqueId(): number;
  26516. /**
  26517. * Creates a new skeleton
  26518. * @param name defines the skeleton name
  26519. * @param id defines the skeleton Id
  26520. * @param scene defines the hosting scene
  26521. */
  26522. constructor(
  26523. /** defines the skeleton name */
  26524. name: string,
  26525. /** defines the skeleton Id */
  26526. id: string, scene: Scene);
  26527. /**
  26528. * Gets the current object class name.
  26529. * @return the class name
  26530. */
  26531. getClassName(): string;
  26532. /**
  26533. * Returns an array containing the root bones
  26534. * @returns an array containing the root bones
  26535. */
  26536. getChildren(): Array<Bone>;
  26537. /**
  26538. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  26539. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  26540. * @returns a Float32Array containing matrices data
  26541. */
  26542. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  26543. /**
  26544. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  26545. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  26546. * @returns a raw texture containing the data
  26547. */
  26548. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  26549. /**
  26550. * Gets the current hosting scene
  26551. * @returns a scene object
  26552. */
  26553. getScene(): Scene;
  26554. /**
  26555. * Gets a string representing the current skeleton data
  26556. * @param fullDetails defines a boolean indicating if we want a verbose version
  26557. * @returns a string representing the current skeleton data
  26558. */
  26559. toString(fullDetails?: boolean): string;
  26560. /**
  26561. * Get bone's index searching by name
  26562. * @param name defines bone's name to search for
  26563. * @return the indice of the bone. Returns -1 if not found
  26564. */
  26565. getBoneIndexByName(name: string): number;
  26566. /**
  26567. * Create a new animation range
  26568. * @param name defines the name of the range
  26569. * @param from defines the start key
  26570. * @param to defines the end key
  26571. */
  26572. createAnimationRange(name: string, from: number, to: number): void;
  26573. /**
  26574. * Delete a specific animation range
  26575. * @param name defines the name of the range
  26576. * @param deleteFrames defines if frames must be removed as well
  26577. */
  26578. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26579. /**
  26580. * Gets a specific animation range
  26581. * @param name defines the name of the range to look for
  26582. * @returns the requested animation range or null if not found
  26583. */
  26584. getAnimationRange(name: string): Nullable<AnimationRange>;
  26585. /**
  26586. * Gets the list of all animation ranges defined on this skeleton
  26587. * @returns an array
  26588. */
  26589. getAnimationRanges(): Nullable<AnimationRange>[];
  26590. /**
  26591. * Copy animation range from a source skeleton.
  26592. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  26593. * @param source defines the source skeleton
  26594. * @param name defines the name of the range to copy
  26595. * @param rescaleAsRequired defines if rescaling must be applied if required
  26596. * @returns true if operation was successful
  26597. */
  26598. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  26599. /**
  26600. * Forces the skeleton to go to rest pose
  26601. */
  26602. returnToRest(): void;
  26603. private _getHighestAnimationFrame;
  26604. /**
  26605. * Begin a specific animation range
  26606. * @param name defines the name of the range to start
  26607. * @param loop defines if looping must be turned on (false by default)
  26608. * @param speedRatio defines the speed ratio to apply (1 by default)
  26609. * @param onAnimationEnd defines a callback which will be called when animation will end
  26610. * @returns a new animatable
  26611. */
  26612. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26613. /**
  26614. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  26615. * @param skeleton defines the Skeleton containing the animation range to convert
  26616. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  26617. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  26618. * @returns the original skeleton
  26619. */
  26620. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  26621. /** @hidden */
  26622. _markAsDirty(): void;
  26623. /** @hidden */
  26624. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  26625. /** @hidden */
  26626. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  26627. private _computeTransformMatrices;
  26628. /**
  26629. * Build all resources required to render a skeleton
  26630. */
  26631. prepare(): void;
  26632. /**
  26633. * Gets the list of animatables currently running for this skeleton
  26634. * @returns an array of animatables
  26635. */
  26636. getAnimatables(): IAnimatable[];
  26637. /**
  26638. * Clone the current skeleton
  26639. * @param name defines the name of the new skeleton
  26640. * @param id defines the id of the new skeleton
  26641. * @returns the new skeleton
  26642. */
  26643. clone(name: string, id?: string): Skeleton;
  26644. /**
  26645. * Enable animation blending for this skeleton
  26646. * @param blendingSpeed defines the blending speed to apply
  26647. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  26648. */
  26649. enableBlending(blendingSpeed?: number): void;
  26650. /**
  26651. * Releases all resources associated with the current skeleton
  26652. */
  26653. dispose(): void;
  26654. /**
  26655. * Serialize the skeleton in a JSON object
  26656. * @returns a JSON object
  26657. */
  26658. serialize(): any;
  26659. /**
  26660. * Creates a new skeleton from serialized data
  26661. * @param parsedSkeleton defines the serialized data
  26662. * @param scene defines the hosting scene
  26663. * @returns a new skeleton
  26664. */
  26665. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  26666. /**
  26667. * Compute all node absolute transforms
  26668. * @param forceUpdate defines if computation must be done even if cache is up to date
  26669. */
  26670. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  26671. /**
  26672. * Gets the root pose matrix
  26673. * @returns a matrix
  26674. */
  26675. getPoseMatrix(): Nullable<Matrix>;
  26676. /**
  26677. * Sorts bones per internal index
  26678. */
  26679. sortBones(): void;
  26680. private _sortBones;
  26681. /**
  26682. * Set the current local matrix as the restPose for all bones in the skeleton.
  26683. */
  26684. setCurrentPoseAsRest(): void;
  26685. }
  26686. }
  26687. declare module BABYLON {
  26688. /**
  26689. * Class used to store bone information
  26690. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26691. */
  26692. export class Bone extends Node {
  26693. /**
  26694. * defines the bone name
  26695. */
  26696. name: string;
  26697. private static _tmpVecs;
  26698. private static _tmpQuat;
  26699. private static _tmpMats;
  26700. /**
  26701. * Gets the list of child bones
  26702. */
  26703. children: Bone[];
  26704. /** Gets the animations associated with this bone */
  26705. animations: Animation[];
  26706. /**
  26707. * Gets or sets bone length
  26708. */
  26709. length: number;
  26710. /**
  26711. * @hidden Internal only
  26712. * Set this value to map this bone to a different index in the transform matrices
  26713. * Set this value to -1 to exclude the bone from the transform matrices
  26714. */
  26715. _index: Nullable<number>;
  26716. private _skeleton;
  26717. private _localMatrix;
  26718. private _restPose;
  26719. private _bindPose;
  26720. private _baseMatrix;
  26721. private _absoluteTransform;
  26722. private _invertedAbsoluteTransform;
  26723. private _parent;
  26724. private _scalingDeterminant;
  26725. private _worldTransform;
  26726. private _localScaling;
  26727. private _localRotation;
  26728. private _localPosition;
  26729. private _needToDecompose;
  26730. private _needToCompose;
  26731. /** @hidden */
  26732. _linkedTransformNode: Nullable<TransformNode>;
  26733. /** @hidden */
  26734. _waitingTransformNodeId: Nullable<string>;
  26735. /** @hidden */
  26736. get _matrix(): Matrix;
  26737. /** @hidden */
  26738. set _matrix(value: Matrix);
  26739. /**
  26740. * Create a new bone
  26741. * @param name defines the bone name
  26742. * @param skeleton defines the parent skeleton
  26743. * @param parentBone defines the parent (can be null if the bone is the root)
  26744. * @param localMatrix defines the local matrix
  26745. * @param restPose defines the rest pose matrix
  26746. * @param baseMatrix defines the base matrix
  26747. * @param index defines index of the bone in the hierarchy
  26748. */
  26749. constructor(
  26750. /**
  26751. * defines the bone name
  26752. */
  26753. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  26754. /**
  26755. * Gets the current object class name.
  26756. * @return the class name
  26757. */
  26758. getClassName(): string;
  26759. /**
  26760. * Gets the parent skeleton
  26761. * @returns a skeleton
  26762. */
  26763. getSkeleton(): Skeleton;
  26764. /**
  26765. * Gets parent bone
  26766. * @returns a bone or null if the bone is the root of the bone hierarchy
  26767. */
  26768. getParent(): Nullable<Bone>;
  26769. /**
  26770. * Returns an array containing the root bones
  26771. * @returns an array containing the root bones
  26772. */
  26773. getChildren(): Array<Bone>;
  26774. /**
  26775. * Gets the node index in matrix array generated for rendering
  26776. * @returns the node index
  26777. */
  26778. getIndex(): number;
  26779. /**
  26780. * Sets the parent bone
  26781. * @param parent defines the parent (can be null if the bone is the root)
  26782. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  26783. */
  26784. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  26785. /**
  26786. * Gets the local matrix
  26787. * @returns a matrix
  26788. */
  26789. getLocalMatrix(): Matrix;
  26790. /**
  26791. * Gets the base matrix (initial matrix which remains unchanged)
  26792. * @returns a matrix
  26793. */
  26794. getBaseMatrix(): Matrix;
  26795. /**
  26796. * Gets the rest pose matrix
  26797. * @returns a matrix
  26798. */
  26799. getRestPose(): Matrix;
  26800. /**
  26801. * Sets the rest pose matrix
  26802. * @param matrix the local-space rest pose to set for this bone
  26803. */
  26804. setRestPose(matrix: Matrix): void;
  26805. /**
  26806. * Gets the bind pose matrix
  26807. * @returns the bind pose matrix
  26808. */
  26809. getBindPose(): Matrix;
  26810. /**
  26811. * Sets the bind pose matrix
  26812. * @param matrix the local-space bind pose to set for this bone
  26813. */
  26814. setBindPose(matrix: Matrix): void;
  26815. /**
  26816. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  26817. */
  26818. getWorldMatrix(): Matrix;
  26819. /**
  26820. * Sets the local matrix to rest pose matrix
  26821. */
  26822. returnToRest(): void;
  26823. /**
  26824. * Gets the inverse of the absolute transform matrix.
  26825. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  26826. * @returns a matrix
  26827. */
  26828. getInvertedAbsoluteTransform(): Matrix;
  26829. /**
  26830. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  26831. * @returns a matrix
  26832. */
  26833. getAbsoluteTransform(): Matrix;
  26834. /**
  26835. * Links with the given transform node.
  26836. * The local matrix of this bone is copied from the transform node every frame.
  26837. * @param transformNode defines the transform node to link to
  26838. */
  26839. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  26840. /**
  26841. * Gets the node used to drive the bone's transformation
  26842. * @returns a transform node or null
  26843. */
  26844. getTransformNode(): Nullable<TransformNode>;
  26845. /** Gets or sets current position (in local space) */
  26846. get position(): Vector3;
  26847. set position(newPosition: Vector3);
  26848. /** Gets or sets current rotation (in local space) */
  26849. get rotation(): Vector3;
  26850. set rotation(newRotation: Vector3);
  26851. /** Gets or sets current rotation quaternion (in local space) */
  26852. get rotationQuaternion(): Quaternion;
  26853. set rotationQuaternion(newRotation: Quaternion);
  26854. /** Gets or sets current scaling (in local space) */
  26855. get scaling(): Vector3;
  26856. set scaling(newScaling: Vector3);
  26857. /**
  26858. * Gets the animation properties override
  26859. */
  26860. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  26861. private _decompose;
  26862. private _compose;
  26863. /**
  26864. * Update the base and local matrices
  26865. * @param matrix defines the new base or local matrix
  26866. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  26867. * @param updateLocalMatrix defines if the local matrix should be updated
  26868. */
  26869. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  26870. /** @hidden */
  26871. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  26872. /**
  26873. * Flag the bone as dirty (Forcing it to update everything)
  26874. */
  26875. markAsDirty(): void;
  26876. /** @hidden */
  26877. _markAsDirtyAndCompose(): void;
  26878. private _markAsDirtyAndDecompose;
  26879. /**
  26880. * Translate the bone in local or world space
  26881. * @param vec The amount to translate the bone
  26882. * @param space The space that the translation is in
  26883. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26884. */
  26885. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  26886. /**
  26887. * Set the position of the bone in local or world space
  26888. * @param position The position to set the bone
  26889. * @param space The space that the position is in
  26890. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26891. */
  26892. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  26893. /**
  26894. * Set the absolute position of the bone (world space)
  26895. * @param position The position to set the bone
  26896. * @param mesh The mesh that this bone is attached to
  26897. */
  26898. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  26899. /**
  26900. * Scale the bone on the x, y and z axes (in local space)
  26901. * @param x The amount to scale the bone on the x axis
  26902. * @param y The amount to scale the bone on the y axis
  26903. * @param z The amount to scale the bone on the z axis
  26904. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  26905. */
  26906. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  26907. /**
  26908. * Set the bone scaling in local space
  26909. * @param scale defines the scaling vector
  26910. */
  26911. setScale(scale: Vector3): void;
  26912. /**
  26913. * Gets the current scaling in local space
  26914. * @returns the current scaling vector
  26915. */
  26916. getScale(): Vector3;
  26917. /**
  26918. * Gets the current scaling in local space and stores it in a target vector
  26919. * @param result defines the target vector
  26920. */
  26921. getScaleToRef(result: Vector3): void;
  26922. /**
  26923. * Set the yaw, pitch, and roll of the bone in local or world space
  26924. * @param yaw The rotation of the bone on the y axis
  26925. * @param pitch The rotation of the bone on the x axis
  26926. * @param roll The rotation of the bone on the z axis
  26927. * @param space The space that the axes of rotation are in
  26928. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26929. */
  26930. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  26931. /**
  26932. * Add a rotation to the bone on an axis in local or world space
  26933. * @param axis The axis to rotate the bone on
  26934. * @param amount The amount to rotate the bone
  26935. * @param space The space that the axis is in
  26936. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26937. */
  26938. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  26939. /**
  26940. * Set the rotation of the bone to a particular axis angle in local or world space
  26941. * @param axis The axis to rotate the bone on
  26942. * @param angle The angle that the bone should be rotated to
  26943. * @param space The space that the axis is in
  26944. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26945. */
  26946. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  26947. /**
  26948. * Set the euler rotation of the bone in local or world space
  26949. * @param rotation The euler rotation that the bone should be set to
  26950. * @param space The space that the rotation is in
  26951. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26952. */
  26953. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  26954. /**
  26955. * Set the quaternion rotation of the bone in local or world space
  26956. * @param quat The quaternion rotation that the bone should be set to
  26957. * @param space The space that the rotation is in
  26958. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26959. */
  26960. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  26961. /**
  26962. * Set the rotation matrix of the bone in local or world space
  26963. * @param rotMat The rotation matrix that the bone should be set to
  26964. * @param space The space that the rotation is in
  26965. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26966. */
  26967. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  26968. private _rotateWithMatrix;
  26969. private _getNegativeRotationToRef;
  26970. /**
  26971. * Get the position of the bone in local or world space
  26972. * @param space The space that the returned position is in
  26973. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26974. * @returns The position of the bone
  26975. */
  26976. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  26977. /**
  26978. * Copy the position of the bone to a vector3 in local or world space
  26979. * @param space The space that the returned position is in
  26980. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26981. * @param result The vector3 to copy the position to
  26982. */
  26983. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  26984. /**
  26985. * Get the absolute position of the bone (world space)
  26986. * @param mesh The mesh that this bone is attached to
  26987. * @returns The absolute position of the bone
  26988. */
  26989. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  26990. /**
  26991. * Copy the absolute position of the bone (world space) to the result param
  26992. * @param mesh The mesh that this bone is attached to
  26993. * @param result The vector3 to copy the absolute position to
  26994. */
  26995. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  26996. /**
  26997. * Compute the absolute transforms of this bone and its children
  26998. */
  26999. computeAbsoluteTransforms(): void;
  27000. /**
  27001. * Get the world direction from an axis that is in the local space of the bone
  27002. * @param localAxis The local direction that is used to compute the world direction
  27003. * @param mesh The mesh that this bone is attached to
  27004. * @returns The world direction
  27005. */
  27006. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  27007. /**
  27008. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  27009. * @param localAxis The local direction that is used to compute the world direction
  27010. * @param mesh The mesh that this bone is attached to
  27011. * @param result The vector3 that the world direction will be copied to
  27012. */
  27013. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  27014. /**
  27015. * Get the euler rotation of the bone in local or world space
  27016. * @param space The space that the rotation should be in
  27017. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27018. * @returns The euler rotation
  27019. */
  27020. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  27021. /**
  27022. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  27023. * @param space The space that the rotation should be in
  27024. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27025. * @param result The vector3 that the rotation should be copied to
  27026. */
  27027. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  27028. /**
  27029. * Get the quaternion rotation of the bone in either local or world space
  27030. * @param space The space that the rotation should be in
  27031. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27032. * @returns The quaternion rotation
  27033. */
  27034. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  27035. /**
  27036. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  27037. * @param space The space that the rotation should be in
  27038. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27039. * @param result The quaternion that the rotation should be copied to
  27040. */
  27041. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  27042. /**
  27043. * Get the rotation matrix of the bone in local or world space
  27044. * @param space The space that the rotation should be in
  27045. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27046. * @returns The rotation matrix
  27047. */
  27048. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  27049. /**
  27050. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  27051. * @param space The space that the rotation should be in
  27052. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27053. * @param result The quaternion that the rotation should be copied to
  27054. */
  27055. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  27056. /**
  27057. * Get the world position of a point that is in the local space of the bone
  27058. * @param position The local position
  27059. * @param mesh The mesh that this bone is attached to
  27060. * @returns The world position
  27061. */
  27062. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  27063. /**
  27064. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  27065. * @param position The local position
  27066. * @param mesh The mesh that this bone is attached to
  27067. * @param result The vector3 that the world position should be copied to
  27068. */
  27069. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  27070. /**
  27071. * Get the local position of a point that is in world space
  27072. * @param position The world position
  27073. * @param mesh The mesh that this bone is attached to
  27074. * @returns The local position
  27075. */
  27076. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  27077. /**
  27078. * Get the local position of a point that is in world space and copy it to the result param
  27079. * @param position The world position
  27080. * @param mesh The mesh that this bone is attached to
  27081. * @param result The vector3 that the local position should be copied to
  27082. */
  27083. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  27084. /**
  27085. * Set the current local matrix as the restPose for this bone.
  27086. */
  27087. setCurrentPoseAsRest(): void;
  27088. }
  27089. }
  27090. declare module BABYLON {
  27091. /**
  27092. * 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.
  27093. * @see https://doc.babylonjs.com/how_to/transformnode
  27094. */
  27095. export class TransformNode extends Node {
  27096. /**
  27097. * Object will not rotate to face the camera
  27098. */
  27099. static BILLBOARDMODE_NONE: number;
  27100. /**
  27101. * Object will rotate to face the camera but only on the x axis
  27102. */
  27103. static BILLBOARDMODE_X: number;
  27104. /**
  27105. * Object will rotate to face the camera but only on the y axis
  27106. */
  27107. static BILLBOARDMODE_Y: number;
  27108. /**
  27109. * Object will rotate to face the camera but only on the z axis
  27110. */
  27111. static BILLBOARDMODE_Z: number;
  27112. /**
  27113. * Object will rotate to face the camera
  27114. */
  27115. static BILLBOARDMODE_ALL: number;
  27116. /**
  27117. * Object will rotate to face the camera's position instead of orientation
  27118. */
  27119. static BILLBOARDMODE_USE_POSITION: number;
  27120. private static _TmpRotation;
  27121. private static _TmpScaling;
  27122. private static _TmpTranslation;
  27123. private _forward;
  27124. private _forwardInverted;
  27125. private _up;
  27126. private _right;
  27127. private _rightInverted;
  27128. private _position;
  27129. private _rotation;
  27130. private _rotationQuaternion;
  27131. protected _scaling: Vector3;
  27132. protected _isDirty: boolean;
  27133. private _transformToBoneReferal;
  27134. private _isAbsoluteSynced;
  27135. private _billboardMode;
  27136. /**
  27137. * Gets or sets the billboard mode. Default is 0.
  27138. *
  27139. * | Value | Type | Description |
  27140. * | --- | --- | --- |
  27141. * | 0 | BILLBOARDMODE_NONE | |
  27142. * | 1 | BILLBOARDMODE_X | |
  27143. * | 2 | BILLBOARDMODE_Y | |
  27144. * | 4 | BILLBOARDMODE_Z | |
  27145. * | 7 | BILLBOARDMODE_ALL | |
  27146. *
  27147. */
  27148. get billboardMode(): number;
  27149. set billboardMode(value: number);
  27150. private _preserveParentRotationForBillboard;
  27151. /**
  27152. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  27153. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  27154. */
  27155. get preserveParentRotationForBillboard(): boolean;
  27156. set preserveParentRotationForBillboard(value: boolean);
  27157. /**
  27158. * 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
  27159. */
  27160. scalingDeterminant: number;
  27161. private _infiniteDistance;
  27162. /**
  27163. * Gets or sets the distance of the object to max, often used by skybox
  27164. */
  27165. get infiniteDistance(): boolean;
  27166. set infiniteDistance(value: boolean);
  27167. /**
  27168. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  27169. * By default the system will update normals to compensate
  27170. */
  27171. ignoreNonUniformScaling: boolean;
  27172. /**
  27173. * 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
  27174. */
  27175. reIntegrateRotationIntoRotationQuaternion: boolean;
  27176. /** @hidden */
  27177. _poseMatrix: Nullable<Matrix>;
  27178. /** @hidden */
  27179. _localMatrix: Matrix;
  27180. private _usePivotMatrix;
  27181. private _absolutePosition;
  27182. private _absoluteScaling;
  27183. private _absoluteRotationQuaternion;
  27184. private _pivotMatrix;
  27185. private _pivotMatrixInverse;
  27186. /** @hidden */
  27187. _postMultiplyPivotMatrix: boolean;
  27188. protected _isWorldMatrixFrozen: boolean;
  27189. /** @hidden */
  27190. _indexInSceneTransformNodesArray: number;
  27191. /**
  27192. * An event triggered after the world matrix is updated
  27193. */
  27194. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  27195. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  27196. /**
  27197. * Gets a string identifying the name of the class
  27198. * @returns "TransformNode" string
  27199. */
  27200. getClassName(): string;
  27201. /**
  27202. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  27203. */
  27204. get position(): Vector3;
  27205. set position(newPosition: Vector3);
  27206. /**
  27207. * 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)).
  27208. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  27209. */
  27210. get rotation(): Vector3;
  27211. set rotation(newRotation: Vector3);
  27212. /**
  27213. * 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)).
  27214. */
  27215. get scaling(): Vector3;
  27216. set scaling(newScaling: Vector3);
  27217. /**
  27218. * 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).
  27219. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  27220. */
  27221. get rotationQuaternion(): Nullable<Quaternion>;
  27222. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  27223. /**
  27224. * The forward direction of that transform in world space.
  27225. */
  27226. get forward(): Vector3;
  27227. /**
  27228. * The up direction of that transform in world space.
  27229. */
  27230. get up(): Vector3;
  27231. /**
  27232. * The right direction of that transform in world space.
  27233. */
  27234. get right(): Vector3;
  27235. /**
  27236. * Copies the parameter passed Matrix into the mesh Pose matrix.
  27237. * @param matrix the matrix to copy the pose from
  27238. * @returns this TransformNode.
  27239. */
  27240. updatePoseMatrix(matrix: Matrix): TransformNode;
  27241. /**
  27242. * Returns the mesh Pose matrix.
  27243. * @returns the pose matrix
  27244. */
  27245. getPoseMatrix(): Matrix;
  27246. /** @hidden */
  27247. _isSynchronized(): boolean;
  27248. /** @hidden */
  27249. _initCache(): void;
  27250. /**
  27251. * Flag the transform node as dirty (Forcing it to update everything)
  27252. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  27253. * @returns this transform node
  27254. */
  27255. markAsDirty(property: string): TransformNode;
  27256. /**
  27257. * Returns the current mesh absolute position.
  27258. * Returns a Vector3.
  27259. */
  27260. get absolutePosition(): Vector3;
  27261. /**
  27262. * Returns the current mesh absolute scaling.
  27263. * Returns a Vector3.
  27264. */
  27265. get absoluteScaling(): Vector3;
  27266. /**
  27267. * Returns the current mesh absolute rotation.
  27268. * Returns a Quaternion.
  27269. */
  27270. get absoluteRotationQuaternion(): Quaternion;
  27271. /**
  27272. * Sets a new matrix to apply before all other transformation
  27273. * @param matrix defines the transform matrix
  27274. * @returns the current TransformNode
  27275. */
  27276. setPreTransformMatrix(matrix: Matrix): TransformNode;
  27277. /**
  27278. * Sets a new pivot matrix to the current node
  27279. * @param matrix defines the new pivot matrix to use
  27280. * @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
  27281. * @returns the current TransformNode
  27282. */
  27283. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  27284. /**
  27285. * Returns the mesh pivot matrix.
  27286. * Default : Identity.
  27287. * @returns the matrix
  27288. */
  27289. getPivotMatrix(): Matrix;
  27290. /**
  27291. * Instantiate (when possible) or clone that node with its hierarchy
  27292. * @param newParent defines the new parent to use for the instance (or clone)
  27293. * @param options defines options to configure how copy is done
  27294. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  27295. * @returns an instance (or a clone) of the current node with its hiearchy
  27296. */
  27297. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  27298. doNotInstantiate: boolean;
  27299. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  27300. /**
  27301. * Prevents the World matrix to be computed any longer
  27302. * @param newWorldMatrix defines an optional matrix to use as world matrix
  27303. * @returns the TransformNode.
  27304. */
  27305. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  27306. /**
  27307. * Allows back the World matrix computation.
  27308. * @returns the TransformNode.
  27309. */
  27310. unfreezeWorldMatrix(): this;
  27311. /**
  27312. * True if the World matrix has been frozen.
  27313. */
  27314. get isWorldMatrixFrozen(): boolean;
  27315. /**
  27316. * Returns the mesh absolute position in the World.
  27317. * @returns a Vector3.
  27318. */
  27319. getAbsolutePosition(): Vector3;
  27320. /**
  27321. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  27322. * @param absolutePosition the absolute position to set
  27323. * @returns the TransformNode.
  27324. */
  27325. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  27326. /**
  27327. * Sets the mesh position in its local space.
  27328. * @param vector3 the position to set in localspace
  27329. * @returns the TransformNode.
  27330. */
  27331. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  27332. /**
  27333. * Returns the mesh position in the local space from the current World matrix values.
  27334. * @returns a new Vector3.
  27335. */
  27336. getPositionExpressedInLocalSpace(): Vector3;
  27337. /**
  27338. * Translates the mesh along the passed Vector3 in its local space.
  27339. * @param vector3 the distance to translate in localspace
  27340. * @returns the TransformNode.
  27341. */
  27342. locallyTranslate(vector3: Vector3): TransformNode;
  27343. private static _lookAtVectorCache;
  27344. /**
  27345. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  27346. * @param targetPoint the position (must be in same space as current mesh) to look at
  27347. * @param yawCor optional yaw (y-axis) correction in radians
  27348. * @param pitchCor optional pitch (x-axis) correction in radians
  27349. * @param rollCor optional roll (z-axis) correction in radians
  27350. * @param space the chosen space of the target
  27351. * @returns the TransformNode.
  27352. */
  27353. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  27354. /**
  27355. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  27356. * This Vector3 is expressed in the World space.
  27357. * @param localAxis axis to rotate
  27358. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  27359. */
  27360. getDirection(localAxis: Vector3): Vector3;
  27361. /**
  27362. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  27363. * localAxis is expressed in the mesh local space.
  27364. * result is computed in the Wordl space from the mesh World matrix.
  27365. * @param localAxis axis to rotate
  27366. * @param result the resulting transformnode
  27367. * @returns this TransformNode.
  27368. */
  27369. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  27370. /**
  27371. * Sets this transform node rotation to the given local axis.
  27372. * @param localAxis the axis in local space
  27373. * @param yawCor optional yaw (y-axis) correction in radians
  27374. * @param pitchCor optional pitch (x-axis) correction in radians
  27375. * @param rollCor optional roll (z-axis) correction in radians
  27376. * @returns this TransformNode
  27377. */
  27378. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  27379. /**
  27380. * Sets a new pivot point to the current node
  27381. * @param point defines the new pivot point to use
  27382. * @param space defines if the point is in world or local space (local by default)
  27383. * @returns the current TransformNode
  27384. */
  27385. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  27386. /**
  27387. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  27388. * @returns the pivot point
  27389. */
  27390. getPivotPoint(): Vector3;
  27391. /**
  27392. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  27393. * @param result the vector3 to store the result
  27394. * @returns this TransformNode.
  27395. */
  27396. getPivotPointToRef(result: Vector3): TransformNode;
  27397. /**
  27398. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  27399. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  27400. */
  27401. getAbsolutePivotPoint(): Vector3;
  27402. /**
  27403. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  27404. * @param result vector3 to store the result
  27405. * @returns this TransformNode.
  27406. */
  27407. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  27408. /**
  27409. * Defines the passed node as the parent of the current node.
  27410. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  27411. * @see https://doc.babylonjs.com/how_to/parenting
  27412. * @param node the node ot set as the parent
  27413. * @returns this TransformNode.
  27414. */
  27415. setParent(node: Nullable<Node>): TransformNode;
  27416. private _nonUniformScaling;
  27417. /**
  27418. * True if the scaling property of this object is non uniform eg. (1,2,1)
  27419. */
  27420. get nonUniformScaling(): boolean;
  27421. /** @hidden */
  27422. _updateNonUniformScalingState(value: boolean): boolean;
  27423. /**
  27424. * Attach the current TransformNode to another TransformNode associated with a bone
  27425. * @param bone Bone affecting the TransformNode
  27426. * @param affectedTransformNode TransformNode associated with the bone
  27427. * @returns this object
  27428. */
  27429. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  27430. /**
  27431. * Detach the transform node if its associated with a bone
  27432. * @returns this object
  27433. */
  27434. detachFromBone(): TransformNode;
  27435. private static _rotationAxisCache;
  27436. /**
  27437. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  27438. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  27439. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  27440. * The passed axis is also normalized.
  27441. * @param axis the axis to rotate around
  27442. * @param amount the amount to rotate in radians
  27443. * @param space Space to rotate in (Default: local)
  27444. * @returns the TransformNode.
  27445. */
  27446. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  27447. /**
  27448. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  27449. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  27450. * The passed axis is also normalized. .
  27451. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  27452. * @param point the point to rotate around
  27453. * @param axis the axis to rotate around
  27454. * @param amount the amount to rotate in radians
  27455. * @returns the TransformNode
  27456. */
  27457. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  27458. /**
  27459. * Translates the mesh along the axis vector for the passed distance in the given space.
  27460. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  27461. * @param axis the axis to translate in
  27462. * @param distance the distance to translate
  27463. * @param space Space to rotate in (Default: local)
  27464. * @returns the TransformNode.
  27465. */
  27466. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  27467. /**
  27468. * Adds a rotation step to the mesh current rotation.
  27469. * x, y, z are Euler angles expressed in radians.
  27470. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  27471. * This means this rotation is made in the mesh local space only.
  27472. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  27473. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  27474. * ```javascript
  27475. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  27476. * ```
  27477. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  27478. * 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.
  27479. * @param x Rotation to add
  27480. * @param y Rotation to add
  27481. * @param z Rotation to add
  27482. * @returns the TransformNode.
  27483. */
  27484. addRotation(x: number, y: number, z: number): TransformNode;
  27485. /**
  27486. * @hidden
  27487. */
  27488. protected _getEffectiveParent(): Nullable<Node>;
  27489. /**
  27490. * Computes the world matrix of the node
  27491. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27492. * @returns the world matrix
  27493. */
  27494. computeWorldMatrix(force?: boolean): Matrix;
  27495. /**
  27496. * Resets this nodeTransform's local matrix to Matrix.Identity().
  27497. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  27498. */
  27499. resetLocalMatrix(independentOfChildren?: boolean): void;
  27500. protected _afterComputeWorldMatrix(): void;
  27501. /**
  27502. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  27503. * @param func callback function to add
  27504. *
  27505. * @returns the TransformNode.
  27506. */
  27507. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  27508. /**
  27509. * Removes a registered callback function.
  27510. * @param func callback function to remove
  27511. * @returns the TransformNode.
  27512. */
  27513. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  27514. /**
  27515. * Gets the position of the current mesh in camera space
  27516. * @param camera defines the camera to use
  27517. * @returns a position
  27518. */
  27519. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  27520. /**
  27521. * Returns the distance from the mesh to the active camera
  27522. * @param camera defines the camera to use
  27523. * @returns the distance
  27524. */
  27525. getDistanceToCamera(camera?: Nullable<Camera>): number;
  27526. /**
  27527. * Clone the current transform node
  27528. * @param name Name of the new clone
  27529. * @param newParent New parent for the clone
  27530. * @param doNotCloneChildren Do not clone children hierarchy
  27531. * @returns the new transform node
  27532. */
  27533. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  27534. /**
  27535. * Serializes the objects information.
  27536. * @param currentSerializationObject defines the object to serialize in
  27537. * @returns the serialized object
  27538. */
  27539. serialize(currentSerializationObject?: any): any;
  27540. /**
  27541. * Returns a new TransformNode object parsed from the source provided.
  27542. * @param parsedTransformNode is the source.
  27543. * @param scene the scene the object belongs to
  27544. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  27545. * @returns a new TransformNode object parsed from the source provided.
  27546. */
  27547. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  27548. /**
  27549. * Get all child-transformNodes of this node
  27550. * @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
  27551. * @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
  27552. * @returns an array of TransformNode
  27553. */
  27554. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  27555. /**
  27556. * Releases resources associated with this transform node.
  27557. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27558. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27559. */
  27560. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27561. /**
  27562. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  27563. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  27564. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  27565. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  27566. * @returns the current mesh
  27567. */
  27568. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  27569. private _syncAbsoluteScalingAndRotation;
  27570. }
  27571. }
  27572. declare module BABYLON {
  27573. /**
  27574. * Defines the types of pose enabled controllers that are supported
  27575. */
  27576. export enum PoseEnabledControllerType {
  27577. /**
  27578. * HTC Vive
  27579. */
  27580. VIVE = 0,
  27581. /**
  27582. * Oculus Rift
  27583. */
  27584. OCULUS = 1,
  27585. /**
  27586. * Windows mixed reality
  27587. */
  27588. WINDOWS = 2,
  27589. /**
  27590. * Samsung gear VR
  27591. */
  27592. GEAR_VR = 3,
  27593. /**
  27594. * Google Daydream
  27595. */
  27596. DAYDREAM = 4,
  27597. /**
  27598. * Generic
  27599. */
  27600. GENERIC = 5
  27601. }
  27602. /**
  27603. * Defines the MutableGamepadButton interface for the state of a gamepad button
  27604. */
  27605. export interface MutableGamepadButton {
  27606. /**
  27607. * Value of the button/trigger
  27608. */
  27609. value: number;
  27610. /**
  27611. * If the button/trigger is currently touched
  27612. */
  27613. touched: boolean;
  27614. /**
  27615. * If the button/trigger is currently pressed
  27616. */
  27617. pressed: boolean;
  27618. }
  27619. /**
  27620. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  27621. * @hidden
  27622. */
  27623. export interface ExtendedGamepadButton extends GamepadButton {
  27624. /**
  27625. * If the button/trigger is currently pressed
  27626. */
  27627. readonly pressed: boolean;
  27628. /**
  27629. * If the button/trigger is currently touched
  27630. */
  27631. readonly touched: boolean;
  27632. /**
  27633. * Value of the button/trigger
  27634. */
  27635. readonly value: number;
  27636. }
  27637. /** @hidden */
  27638. export interface _GamePadFactory {
  27639. /**
  27640. * Returns whether or not the current gamepad can be created for this type of controller.
  27641. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  27642. * @returns true if it can be created, otherwise false
  27643. */
  27644. canCreate(gamepadInfo: any): boolean;
  27645. /**
  27646. * Creates a new instance of the Gamepad.
  27647. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  27648. * @returns the new gamepad instance
  27649. */
  27650. create(gamepadInfo: any): Gamepad;
  27651. }
  27652. /**
  27653. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  27654. */
  27655. export class PoseEnabledControllerHelper {
  27656. /** @hidden */
  27657. static _ControllerFactories: _GamePadFactory[];
  27658. /** @hidden */
  27659. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  27660. /**
  27661. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  27662. * @param vrGamepad the gamepad to initialized
  27663. * @returns a vr controller of the type the gamepad identified as
  27664. */
  27665. static InitiateController(vrGamepad: any): Gamepad;
  27666. }
  27667. /**
  27668. * Defines the PoseEnabledController object that contains state of a vr capable controller
  27669. */
  27670. export class PoseEnabledController extends Gamepad implements PoseControlled {
  27671. /**
  27672. * If the controller is used in a webXR session
  27673. */
  27674. isXR: boolean;
  27675. private _deviceRoomPosition;
  27676. private _deviceRoomRotationQuaternion;
  27677. /**
  27678. * The device position in babylon space
  27679. */
  27680. devicePosition: Vector3;
  27681. /**
  27682. * The device rotation in babylon space
  27683. */
  27684. deviceRotationQuaternion: Quaternion;
  27685. /**
  27686. * The scale factor of the device in babylon space
  27687. */
  27688. deviceScaleFactor: number;
  27689. /**
  27690. * (Likely devicePosition should be used instead) The device position in its room space
  27691. */
  27692. position: Vector3;
  27693. /**
  27694. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  27695. */
  27696. rotationQuaternion: Quaternion;
  27697. /**
  27698. * The type of controller (Eg. Windows mixed reality)
  27699. */
  27700. controllerType: PoseEnabledControllerType;
  27701. protected _calculatedPosition: Vector3;
  27702. private _calculatedRotation;
  27703. /**
  27704. * The raw pose from the device
  27705. */
  27706. rawPose: DevicePose;
  27707. private _trackPosition;
  27708. private _maxRotationDistFromHeadset;
  27709. private _draggedRoomRotation;
  27710. /**
  27711. * @hidden
  27712. */
  27713. _disableTrackPosition(fixedPosition: Vector3): void;
  27714. /**
  27715. * Internal, the mesh attached to the controller
  27716. * @hidden
  27717. */
  27718. _mesh: Nullable<AbstractMesh>;
  27719. private _poseControlledCamera;
  27720. private _leftHandSystemQuaternion;
  27721. /**
  27722. * Internal, matrix used to convert room space to babylon space
  27723. * @hidden
  27724. */
  27725. _deviceToWorld: Matrix;
  27726. /**
  27727. * Node to be used when casting a ray from the controller
  27728. * @hidden
  27729. */
  27730. _pointingPoseNode: Nullable<TransformNode>;
  27731. /**
  27732. * Name of the child mesh that can be used to cast a ray from the controller
  27733. */
  27734. static readonly POINTING_POSE: string;
  27735. /**
  27736. * Creates a new PoseEnabledController from a gamepad
  27737. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  27738. */
  27739. constructor(browserGamepad: any);
  27740. private _workingMatrix;
  27741. /**
  27742. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  27743. */
  27744. update(): void;
  27745. /**
  27746. * Updates only the pose device and mesh without doing any button event checking
  27747. */
  27748. protected _updatePoseAndMesh(): void;
  27749. /**
  27750. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  27751. * @param poseData raw pose fromthe device
  27752. */
  27753. updateFromDevice(poseData: DevicePose): void;
  27754. /**
  27755. * @hidden
  27756. */
  27757. _meshAttachedObservable: Observable<AbstractMesh>;
  27758. /**
  27759. * Attaches a mesh to the controller
  27760. * @param mesh the mesh to be attached
  27761. */
  27762. attachToMesh(mesh: AbstractMesh): void;
  27763. /**
  27764. * Attaches the controllers mesh to a camera
  27765. * @param camera the camera the mesh should be attached to
  27766. */
  27767. attachToPoseControlledCamera(camera: TargetCamera): void;
  27768. /**
  27769. * Disposes of the controller
  27770. */
  27771. dispose(): void;
  27772. /**
  27773. * The mesh that is attached to the controller
  27774. */
  27775. get mesh(): Nullable<AbstractMesh>;
  27776. /**
  27777. * Gets the ray of the controller in the direction the controller is pointing
  27778. * @param length the length the resulting ray should be
  27779. * @returns a ray in the direction the controller is pointing
  27780. */
  27781. getForwardRay(length?: number): Ray;
  27782. }
  27783. }
  27784. declare module BABYLON {
  27785. /**
  27786. * Defines the WebVRController object that represents controllers tracked in 3D space
  27787. */
  27788. export abstract class WebVRController extends PoseEnabledController {
  27789. /**
  27790. * Internal, the default controller model for the controller
  27791. */
  27792. protected _defaultModel: Nullable<AbstractMesh>;
  27793. /**
  27794. * Fired when the trigger state has changed
  27795. */
  27796. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  27797. /**
  27798. * Fired when the main button state has changed
  27799. */
  27800. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  27801. /**
  27802. * Fired when the secondary button state has changed
  27803. */
  27804. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  27805. /**
  27806. * Fired when the pad state has changed
  27807. */
  27808. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  27809. /**
  27810. * Fired when controllers stick values have changed
  27811. */
  27812. onPadValuesChangedObservable: Observable<StickValues>;
  27813. /**
  27814. * Array of button availible on the controller
  27815. */
  27816. protected _buttons: Array<MutableGamepadButton>;
  27817. private _onButtonStateChange;
  27818. /**
  27819. * Fired when a controller button's state has changed
  27820. * @param callback the callback containing the button that was modified
  27821. */
  27822. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  27823. /**
  27824. * X and Y axis corresponding to the controllers joystick
  27825. */
  27826. pad: StickValues;
  27827. /**
  27828. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  27829. */
  27830. hand: string;
  27831. /**
  27832. * The default controller model for the controller
  27833. */
  27834. get defaultModel(): Nullable<AbstractMesh>;
  27835. /**
  27836. * Creates a new WebVRController from a gamepad
  27837. * @param vrGamepad the gamepad that the WebVRController should be created from
  27838. */
  27839. constructor(vrGamepad: any);
  27840. /**
  27841. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  27842. */
  27843. update(): void;
  27844. /**
  27845. * Function to be called when a button is modified
  27846. */
  27847. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  27848. /**
  27849. * Loads a mesh and attaches it to the controller
  27850. * @param scene the scene the mesh should be added to
  27851. * @param meshLoaded callback for when the mesh has been loaded
  27852. */
  27853. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  27854. private _setButtonValue;
  27855. private _changes;
  27856. private _checkChanges;
  27857. /**
  27858. * Disposes of th webVRCOntroller
  27859. */
  27860. dispose(): void;
  27861. }
  27862. }
  27863. declare module BABYLON {
  27864. /**
  27865. * The HemisphericLight simulates the ambient environment light,
  27866. * so the passed direction is the light reflection direction, not the incoming direction.
  27867. */
  27868. export class HemisphericLight extends Light {
  27869. /**
  27870. * The groundColor is the light in the opposite direction to the one specified during creation.
  27871. * 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.
  27872. */
  27873. groundColor: Color3;
  27874. /**
  27875. * The light reflection direction, not the incoming direction.
  27876. */
  27877. direction: Vector3;
  27878. /**
  27879. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  27880. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  27881. * The HemisphericLight can't cast shadows.
  27882. * Documentation : https://doc.babylonjs.com/babylon101/lights
  27883. * @param name The friendly name of the light
  27884. * @param direction The direction of the light reflection
  27885. * @param scene The scene the light belongs to
  27886. */
  27887. constructor(name: string, direction: Vector3, scene: Scene);
  27888. protected _buildUniformLayout(): void;
  27889. /**
  27890. * Returns the string "HemisphericLight".
  27891. * @return The class name
  27892. */
  27893. getClassName(): string;
  27894. /**
  27895. * Sets the HemisphericLight direction towards the passed target (Vector3).
  27896. * Returns the updated direction.
  27897. * @param target The target the direction should point to
  27898. * @return The computed direction
  27899. */
  27900. setDirectionToTarget(target: Vector3): Vector3;
  27901. /**
  27902. * Returns the shadow generator associated to the light.
  27903. * @returns Always null for hemispheric lights because it does not support shadows.
  27904. */
  27905. getShadowGenerator(): Nullable<IShadowGenerator>;
  27906. /**
  27907. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  27908. * @param effect The effect to update
  27909. * @param lightIndex The index of the light in the effect to update
  27910. * @returns The hemispheric light
  27911. */
  27912. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  27913. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  27914. /**
  27915. * Computes the world matrix of the node
  27916. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27917. * @param useWasUpdatedFlag defines a reserved property
  27918. * @returns the world matrix
  27919. */
  27920. computeWorldMatrix(): Matrix;
  27921. /**
  27922. * Returns the integer 3.
  27923. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  27924. */
  27925. getTypeID(): number;
  27926. /**
  27927. * Prepares the list of defines specific to the light type.
  27928. * @param defines the list of defines
  27929. * @param lightIndex defines the index of the light for the effect
  27930. */
  27931. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  27932. }
  27933. }
  27934. declare module BABYLON {
  27935. /** @hidden */
  27936. export var vrMultiviewToSingleviewPixelShader: {
  27937. name: string;
  27938. shader: string;
  27939. };
  27940. }
  27941. declare module BABYLON {
  27942. /**
  27943. * Renders to multiple views with a single draw call
  27944. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  27945. */
  27946. export class MultiviewRenderTarget extends RenderTargetTexture {
  27947. /**
  27948. * Creates a multiview render target
  27949. * @param scene scene used with the render target
  27950. * @param size the size of the render target (used for each view)
  27951. */
  27952. constructor(scene: Scene, size?: number | {
  27953. width: number;
  27954. height: number;
  27955. } | {
  27956. ratio: number;
  27957. });
  27958. /**
  27959. * @hidden
  27960. * @param faceIndex the face index, if its a cube texture
  27961. */
  27962. _bindFrameBuffer(faceIndex?: number): void;
  27963. /**
  27964. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  27965. * @returns the view count
  27966. */
  27967. getViewCount(): number;
  27968. }
  27969. }
  27970. declare module BABYLON {
  27971. interface Engine {
  27972. /**
  27973. * Creates a new multiview render target
  27974. * @param width defines the width of the texture
  27975. * @param height defines the height of the texture
  27976. * @returns the created multiview texture
  27977. */
  27978. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  27979. /**
  27980. * Binds a multiview framebuffer to be drawn to
  27981. * @param multiviewTexture texture to bind
  27982. */
  27983. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  27984. }
  27985. interface Camera {
  27986. /**
  27987. * @hidden
  27988. * 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)
  27989. */
  27990. _useMultiviewToSingleView: boolean;
  27991. /**
  27992. * @hidden
  27993. * 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)
  27994. */
  27995. _multiviewTexture: Nullable<RenderTargetTexture>;
  27996. /**
  27997. * @hidden
  27998. * ensures the multiview texture of the camera exists and has the specified width/height
  27999. * @param width height to set on the multiview texture
  28000. * @param height width to set on the multiview texture
  28001. */
  28002. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  28003. }
  28004. interface Scene {
  28005. /** @hidden */
  28006. _transformMatrixR: Matrix;
  28007. /** @hidden */
  28008. _multiviewSceneUbo: Nullable<UniformBuffer>;
  28009. /** @hidden */
  28010. _createMultiviewUbo(): void;
  28011. /** @hidden */
  28012. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  28013. /** @hidden */
  28014. _renderMultiviewToSingleView(camera: Camera): void;
  28015. }
  28016. }
  28017. declare module BABYLON {
  28018. /**
  28019. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  28020. * This will not be used for webXR as it supports displaying texture arrays directly
  28021. */
  28022. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  28023. /**
  28024. * Gets a string identifying the name of the class
  28025. * @returns "VRMultiviewToSingleviewPostProcess" string
  28026. */
  28027. getClassName(): string;
  28028. /**
  28029. * Initializes a VRMultiviewToSingleview
  28030. * @param name name of the post process
  28031. * @param camera camera to be applied to
  28032. * @param scaleFactor scaling factor to the size of the output texture
  28033. */
  28034. constructor(name: string, camera: Camera, scaleFactor: number);
  28035. }
  28036. }
  28037. declare module BABYLON {
  28038. /**
  28039. * Interface used to define additional presentation attributes
  28040. */
  28041. export interface IVRPresentationAttributes {
  28042. /**
  28043. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  28044. */
  28045. highRefreshRate: boolean;
  28046. /**
  28047. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  28048. */
  28049. foveationLevel: number;
  28050. }
  28051. interface Engine {
  28052. /** @hidden */
  28053. _vrDisplay: any;
  28054. /** @hidden */
  28055. _vrSupported: boolean;
  28056. /** @hidden */
  28057. _oldSize: Size;
  28058. /** @hidden */
  28059. _oldHardwareScaleFactor: number;
  28060. /** @hidden */
  28061. _vrExclusivePointerMode: boolean;
  28062. /** @hidden */
  28063. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  28064. /** @hidden */
  28065. _onVRDisplayPointerRestricted: () => void;
  28066. /** @hidden */
  28067. _onVRDisplayPointerUnrestricted: () => void;
  28068. /** @hidden */
  28069. _onVrDisplayConnect: Nullable<(display: any) => void>;
  28070. /** @hidden */
  28071. _onVrDisplayDisconnect: Nullable<() => void>;
  28072. /** @hidden */
  28073. _onVrDisplayPresentChange: Nullable<() => void>;
  28074. /**
  28075. * Observable signaled when VR display mode changes
  28076. */
  28077. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  28078. /**
  28079. * Observable signaled when VR request present is complete
  28080. */
  28081. onVRRequestPresentComplete: Observable<boolean>;
  28082. /**
  28083. * Observable signaled when VR request present starts
  28084. */
  28085. onVRRequestPresentStart: Observable<Engine>;
  28086. /**
  28087. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  28088. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  28089. */
  28090. isInVRExclusivePointerMode: boolean;
  28091. /**
  28092. * Gets a boolean indicating if a webVR device was detected
  28093. * @returns true if a webVR device was detected
  28094. */
  28095. isVRDevicePresent(): boolean;
  28096. /**
  28097. * Gets the current webVR device
  28098. * @returns the current webVR device (or null)
  28099. */
  28100. getVRDevice(): any;
  28101. /**
  28102. * Initializes a webVR display and starts listening to display change events
  28103. * The onVRDisplayChangedObservable will be notified upon these changes
  28104. * @returns A promise containing a VRDisplay and if vr is supported
  28105. */
  28106. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  28107. /** @hidden */
  28108. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  28109. /**
  28110. * Gets or sets the presentation attributes used to configure VR rendering
  28111. */
  28112. vrPresentationAttributes?: IVRPresentationAttributes;
  28113. /**
  28114. * Call this function to switch to webVR mode
  28115. * Will do nothing if webVR is not supported or if there is no webVR device
  28116. * @param options the webvr options provided to the camera. mainly used for multiview
  28117. * @see https://doc.babylonjs.com/how_to/webvr_camera
  28118. */
  28119. enableVR(options: WebVROptions): void;
  28120. /** @hidden */
  28121. _onVRFullScreenTriggered(): void;
  28122. }
  28123. }
  28124. declare module BABYLON {
  28125. /**
  28126. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  28127. * IMPORTANT!! The data is right-hand data.
  28128. * @export
  28129. * @interface DevicePose
  28130. */
  28131. export interface DevicePose {
  28132. /**
  28133. * The position of the device, values in array are [x,y,z].
  28134. */
  28135. readonly position: Nullable<Float32Array>;
  28136. /**
  28137. * The linearVelocity of the device, values in array are [x,y,z].
  28138. */
  28139. readonly linearVelocity: Nullable<Float32Array>;
  28140. /**
  28141. * The linearAcceleration of the device, values in array are [x,y,z].
  28142. */
  28143. readonly linearAcceleration: Nullable<Float32Array>;
  28144. /**
  28145. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  28146. */
  28147. readonly orientation: Nullable<Float32Array>;
  28148. /**
  28149. * The angularVelocity of the device, values in array are [x,y,z].
  28150. */
  28151. readonly angularVelocity: Nullable<Float32Array>;
  28152. /**
  28153. * The angularAcceleration of the device, values in array are [x,y,z].
  28154. */
  28155. readonly angularAcceleration: Nullable<Float32Array>;
  28156. }
  28157. /**
  28158. * Interface representing a pose controlled object in Babylon.
  28159. * A pose controlled object has both regular pose values as well as pose values
  28160. * from an external device such as a VR head mounted display
  28161. */
  28162. export interface PoseControlled {
  28163. /**
  28164. * The position of the object in babylon space.
  28165. */
  28166. position: Vector3;
  28167. /**
  28168. * The rotation quaternion of the object in babylon space.
  28169. */
  28170. rotationQuaternion: Quaternion;
  28171. /**
  28172. * The position of the device in babylon space.
  28173. */
  28174. devicePosition?: Vector3;
  28175. /**
  28176. * The rotation quaternion of the device in babylon space.
  28177. */
  28178. deviceRotationQuaternion: Quaternion;
  28179. /**
  28180. * The raw pose coming from the device.
  28181. */
  28182. rawPose: Nullable<DevicePose>;
  28183. /**
  28184. * The scale of the device to be used when translating from device space to babylon space.
  28185. */
  28186. deviceScaleFactor: number;
  28187. /**
  28188. * Updates the poseControlled values based on the input device pose.
  28189. * @param poseData the pose data to update the object with
  28190. */
  28191. updateFromDevice(poseData: DevicePose): void;
  28192. }
  28193. /**
  28194. * Set of options to customize the webVRCamera
  28195. */
  28196. export interface WebVROptions {
  28197. /**
  28198. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  28199. */
  28200. trackPosition?: boolean;
  28201. /**
  28202. * Sets the scale of the vrDevice in babylon space. (default: 1)
  28203. */
  28204. positionScale?: number;
  28205. /**
  28206. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  28207. */
  28208. displayName?: string;
  28209. /**
  28210. * Should the native controller meshes be initialized. (default: true)
  28211. */
  28212. controllerMeshes?: boolean;
  28213. /**
  28214. * Creating a default HemiLight only on controllers. (default: true)
  28215. */
  28216. defaultLightingOnControllers?: boolean;
  28217. /**
  28218. * If you don't want to use the default VR button of the helper. (default: false)
  28219. */
  28220. useCustomVRButton?: boolean;
  28221. /**
  28222. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  28223. */
  28224. customVRButton?: HTMLButtonElement;
  28225. /**
  28226. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  28227. */
  28228. rayLength?: number;
  28229. /**
  28230. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  28231. */
  28232. defaultHeight?: number;
  28233. /**
  28234. * If multiview should be used if available (default: false)
  28235. */
  28236. useMultiview?: boolean;
  28237. }
  28238. /**
  28239. * This represents a WebVR camera.
  28240. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  28241. * @example https://doc.babylonjs.com/how_to/webvr_camera
  28242. */
  28243. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  28244. private webVROptions;
  28245. /**
  28246. * @hidden
  28247. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  28248. */
  28249. _vrDevice: any;
  28250. /**
  28251. * The rawPose of the vrDevice.
  28252. */
  28253. rawPose: Nullable<DevicePose>;
  28254. private _onVREnabled;
  28255. private _specsVersion;
  28256. private _attached;
  28257. private _frameData;
  28258. protected _descendants: Array<Node>;
  28259. private _deviceRoomPosition;
  28260. /** @hidden */
  28261. _deviceRoomRotationQuaternion: Quaternion;
  28262. private _standingMatrix;
  28263. /**
  28264. * Represents device position in babylon space.
  28265. */
  28266. devicePosition: Vector3;
  28267. /**
  28268. * Represents device rotation in babylon space.
  28269. */
  28270. deviceRotationQuaternion: Quaternion;
  28271. /**
  28272. * The scale of the device to be used when translating from device space to babylon space.
  28273. */
  28274. deviceScaleFactor: number;
  28275. private _deviceToWorld;
  28276. private _worldToDevice;
  28277. /**
  28278. * References to the webVR controllers for the vrDevice.
  28279. */
  28280. controllers: Array<WebVRController>;
  28281. /**
  28282. * Emits an event when a controller is attached.
  28283. */
  28284. onControllersAttachedObservable: Observable<WebVRController[]>;
  28285. /**
  28286. * Emits an event when a controller's mesh has been loaded;
  28287. */
  28288. onControllerMeshLoadedObservable: Observable<WebVRController>;
  28289. /**
  28290. * Emits an event when the HMD's pose has been updated.
  28291. */
  28292. onPoseUpdatedFromDeviceObservable: Observable<any>;
  28293. private _poseSet;
  28294. /**
  28295. * If the rig cameras be used as parent instead of this camera.
  28296. */
  28297. rigParenting: boolean;
  28298. private _lightOnControllers;
  28299. private _defaultHeight?;
  28300. /**
  28301. * Instantiates a WebVRFreeCamera.
  28302. * @param name The name of the WebVRFreeCamera
  28303. * @param position The starting anchor position for the camera
  28304. * @param scene The scene the camera belongs to
  28305. * @param webVROptions a set of customizable options for the webVRCamera
  28306. */
  28307. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  28308. /**
  28309. * Gets the device distance from the ground in meters.
  28310. * @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.
  28311. */
  28312. deviceDistanceToRoomGround(): number;
  28313. /**
  28314. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  28315. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  28316. */
  28317. useStandingMatrix(callback?: (bool: boolean) => void): void;
  28318. /**
  28319. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  28320. * @returns A promise with a boolean set to if the standing matrix is supported.
  28321. */
  28322. useStandingMatrixAsync(): Promise<boolean>;
  28323. /**
  28324. * Disposes the camera
  28325. */
  28326. dispose(): void;
  28327. /**
  28328. * Gets a vrController by name.
  28329. * @param name The name of the controller to retreive
  28330. * @returns the controller matching the name specified or null if not found
  28331. */
  28332. getControllerByName(name: string): Nullable<WebVRController>;
  28333. private _leftController;
  28334. /**
  28335. * The controller corresponding to the users left hand.
  28336. */
  28337. get leftController(): Nullable<WebVRController>;
  28338. private _rightController;
  28339. /**
  28340. * The controller corresponding to the users right hand.
  28341. */
  28342. get rightController(): Nullable<WebVRController>;
  28343. /**
  28344. * Casts a ray forward from the vrCamera's gaze.
  28345. * @param length Length of the ray (default: 100)
  28346. * @returns the ray corresponding to the gaze
  28347. */
  28348. getForwardRay(length?: number): Ray;
  28349. /**
  28350. * @hidden
  28351. * Updates the camera based on device's frame data
  28352. */
  28353. _checkInputs(): void;
  28354. /**
  28355. * Updates the poseControlled values based on the input device pose.
  28356. * @param poseData Pose coming from the device
  28357. */
  28358. updateFromDevice(poseData: DevicePose): void;
  28359. private _detachIfAttached;
  28360. /**
  28361. * WebVR's attach control will start broadcasting frames to the device.
  28362. * Note that in certain browsers (chrome for example) this function must be called
  28363. * within a user-interaction callback. Example:
  28364. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  28365. *
  28366. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  28367. */
  28368. attachControl(noPreventDefault?: boolean): void;
  28369. /**
  28370. * Detach the current controls from the specified dom element.
  28371. */
  28372. detachControl(): void;
  28373. /**
  28374. * @returns the name of this class
  28375. */
  28376. getClassName(): string;
  28377. /**
  28378. * Calls resetPose on the vrDisplay
  28379. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  28380. */
  28381. resetToCurrentRotation(): void;
  28382. /**
  28383. * @hidden
  28384. * Updates the rig cameras (left and right eye)
  28385. */
  28386. _updateRigCameras(): void;
  28387. private _workingVector;
  28388. private _oneVector;
  28389. private _workingMatrix;
  28390. private updateCacheCalled;
  28391. private _correctPositionIfNotTrackPosition;
  28392. /**
  28393. * @hidden
  28394. * Updates the cached values of the camera
  28395. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  28396. */
  28397. _updateCache(ignoreParentClass?: boolean): void;
  28398. /**
  28399. * @hidden
  28400. * Get current device position in babylon world
  28401. */
  28402. _computeDevicePosition(): void;
  28403. /**
  28404. * Updates the current device position and rotation in the babylon world
  28405. */
  28406. update(): void;
  28407. /**
  28408. * @hidden
  28409. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  28410. * @returns an identity matrix
  28411. */
  28412. _getViewMatrix(): Matrix;
  28413. private _tmpMatrix;
  28414. /**
  28415. * This function is called by the two RIG cameras.
  28416. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  28417. * @hidden
  28418. */
  28419. _getWebVRViewMatrix(): Matrix;
  28420. /** @hidden */
  28421. _getWebVRProjectionMatrix(): Matrix;
  28422. private _onGamepadConnectedObserver;
  28423. private _onGamepadDisconnectedObserver;
  28424. private _updateCacheWhenTrackingDisabledObserver;
  28425. /**
  28426. * Initializes the controllers and their meshes
  28427. */
  28428. initControllers(): void;
  28429. }
  28430. }
  28431. declare module BABYLON {
  28432. /**
  28433. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  28434. *
  28435. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  28436. *
  28437. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  28438. */
  28439. export class MaterialHelper {
  28440. /**
  28441. * Bind the current view position to an effect.
  28442. * @param effect The effect to be bound
  28443. * @param scene The scene the eyes position is used from
  28444. * @param variableName name of the shader variable that will hold the eye position
  28445. * @param isVector3 true to indicates that variableName is a Vector3 and not a Vector4
  28446. * @return the computed eye position
  28447. */
  28448. static BindEyePosition(effect: Nullable<Effect>, scene: Scene, variableName?: string, isVector3?: boolean): Vector4;
  28449. /**
  28450. * Update the scene ubo before it can be used in rendering processing
  28451. * @param scene the scene to retrieve the ubo from
  28452. * @returns the scene UniformBuffer
  28453. */
  28454. static FinalizeSceneUbo(scene: Scene): UniformBuffer;
  28455. /**
  28456. * Binds the scene's uniform buffer to the effect.
  28457. * @param effect defines the effect to bind to the scene uniform buffer
  28458. * @param sceneUbo defines the uniform buffer storing scene data
  28459. */
  28460. static BindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  28461. /**
  28462. * Helps preparing the defines values about the UVs in used in the effect.
  28463. * UVs are shared as much as we can across channels in the shaders.
  28464. * @param texture The texture we are preparing the UVs for
  28465. * @param defines The defines to update
  28466. * @param key The channel key "diffuse", "specular"... used in the shader
  28467. */
  28468. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  28469. /**
  28470. * Binds a texture matrix value to its corresponding uniform
  28471. * @param texture The texture to bind the matrix for
  28472. * @param uniformBuffer The uniform buffer receiving the data
  28473. * @param key The channel key "diffuse", "specular"... used in the shader
  28474. */
  28475. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  28476. /**
  28477. * Gets the current status of the fog (should it be enabled?)
  28478. * @param mesh defines the mesh to evaluate for fog support
  28479. * @param scene defines the hosting scene
  28480. * @returns true if fog must be enabled
  28481. */
  28482. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  28483. /**
  28484. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  28485. * @param mesh defines the current mesh
  28486. * @param scene defines the current scene
  28487. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  28488. * @param pointsCloud defines if point cloud rendering has to be turned on
  28489. * @param fogEnabled defines if fog has to be turned on
  28490. * @param alphaTest defines if alpha testing has to be turned on
  28491. * @param defines defines the current list of defines
  28492. */
  28493. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  28494. /**
  28495. * Helper used to prepare the list of defines associated with frame values for shader compilation
  28496. * @param scene defines the current scene
  28497. * @param engine defines the current engine
  28498. * @param defines specifies the list of active defines
  28499. * @param useInstances defines if instances have to be turned on
  28500. * @param useClipPlane defines if clip plane have to be turned on
  28501. * @param useInstances defines if instances have to be turned on
  28502. * @param useThinInstances defines if thin instances have to be turned on
  28503. */
  28504. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  28505. /**
  28506. * Prepares the defines for bones
  28507. * @param mesh The mesh containing the geometry data we will draw
  28508. * @param defines The defines to update
  28509. */
  28510. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  28511. /**
  28512. * Prepares the defines for morph targets
  28513. * @param mesh The mesh containing the geometry data we will draw
  28514. * @param defines The defines to update
  28515. */
  28516. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  28517. /**
  28518. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  28519. * @param mesh The mesh containing the geometry data we will draw
  28520. * @param defines The defines to update
  28521. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  28522. * @param useBones Precise whether bones should be used or not (override mesh info)
  28523. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  28524. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  28525. * @returns false if defines are considered not dirty and have not been checked
  28526. */
  28527. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  28528. /**
  28529. * Prepares the defines related to multiview
  28530. * @param scene The scene we are intending to draw
  28531. * @param defines The defines to update
  28532. */
  28533. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  28534. /**
  28535. * Prepares the defines related to the prepass
  28536. * @param scene The scene we are intending to draw
  28537. * @param defines The defines to update
  28538. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  28539. */
  28540. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  28541. /**
  28542. * Prepares the defines related to the light information passed in parameter
  28543. * @param scene The scene we are intending to draw
  28544. * @param mesh The mesh the effect is compiling for
  28545. * @param light The light the effect is compiling for
  28546. * @param lightIndex The index of the light
  28547. * @param defines The defines to update
  28548. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  28549. * @param state Defines the current state regarding what is needed (normals, etc...)
  28550. */
  28551. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  28552. needNormals: boolean;
  28553. needRebuild: boolean;
  28554. shadowEnabled: boolean;
  28555. specularEnabled: boolean;
  28556. lightmapMode: boolean;
  28557. }): void;
  28558. /**
  28559. * Prepares the defines related to the light information passed in parameter
  28560. * @param scene The scene we are intending to draw
  28561. * @param mesh The mesh the effect is compiling for
  28562. * @param defines The defines to update
  28563. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  28564. * @param maxSimultaneousLights Specifies how manuy lights can be added to the effect at max
  28565. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  28566. * @returns true if normals will be required for the rest of the effect
  28567. */
  28568. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  28569. /**
  28570. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  28571. * @param lightIndex defines the light index
  28572. * @param uniformsList The uniform list
  28573. * @param samplersList The sampler list
  28574. * @param projectedLightTexture defines if projected texture must be used
  28575. * @param uniformBuffersList defines an optional list of uniform buffers
  28576. * @param updateOnlyBuffersList True to only update the uniformBuffersList array
  28577. */
  28578. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>, updateOnlyBuffersList?: boolean): void;
  28579. /**
  28580. * Prepares the uniforms and samplers list to be used in the effect
  28581. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the list and extra information
  28582. * @param samplersList The sampler list
  28583. * @param defines The defines helping in the list generation
  28584. * @param maxSimultaneousLights The maximum number of simultaneous light allowed in the effect
  28585. */
  28586. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  28587. /**
  28588. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  28589. * @param defines The defines to update while falling back
  28590. * @param fallbacks The authorized effect fallbacks
  28591. * @param maxSimultaneousLights The maximum number of lights allowed
  28592. * @param rank the current rank of the Effect
  28593. * @returns The newly affected rank
  28594. */
  28595. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  28596. private static _TmpMorphInfluencers;
  28597. /**
  28598. * Prepares the list of attributes required for morph targets according to the effect defines.
  28599. * @param attribs The current list of supported attribs
  28600. * @param mesh The mesh to prepare the morph targets attributes for
  28601. * @param influencers The number of influencers
  28602. */
  28603. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  28604. /**
  28605. * Prepares the list of attributes required for morph targets according to the effect defines.
  28606. * @param attribs The current list of supported attribs
  28607. * @param mesh The mesh to prepare the morph targets attributes for
  28608. * @param defines The current Defines of the effect
  28609. */
  28610. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  28611. /**
  28612. * Prepares the list of attributes required for bones according to the effect defines.
  28613. * @param attribs The current list of supported attribs
  28614. * @param mesh The mesh to prepare the bones attributes for
  28615. * @param defines The current Defines of the effect
  28616. * @param fallbacks The current effect fallback strategy
  28617. */
  28618. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  28619. /**
  28620. * Check and prepare the list of attributes required for instances according to the effect defines.
  28621. * @param attribs The current list of supported attribs
  28622. * @param defines The current MaterialDefines of the effect
  28623. */
  28624. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  28625. /**
  28626. * Add the list of attributes required for instances to the attribs array.
  28627. * @param attribs The current list of supported attribs
  28628. */
  28629. static PushAttributesForInstances(attribs: string[]): void;
  28630. /**
  28631. * Binds the light information to the effect.
  28632. * @param light The light containing the generator
  28633. * @param effect The effect we are binding the data to
  28634. * @param lightIndex The light index in the effect used to render
  28635. */
  28636. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  28637. /**
  28638. * Binds the lights information from the scene to the effect for the given mesh.
  28639. * @param light Light to bind
  28640. * @param lightIndex Light index
  28641. * @param scene The scene where the light belongs to
  28642. * @param effect The effect we are binding the data to
  28643. * @param useSpecular Defines if specular is supported
  28644. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  28645. */
  28646. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  28647. /**
  28648. * Binds the lights information from the scene to the effect for the given mesh.
  28649. * @param scene The scene the lights belongs to
  28650. * @param mesh The mesh we are binding the information to render
  28651. * @param effect The effect we are binding the data to
  28652. * @param defines The generated defines for the effect
  28653. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  28654. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  28655. */
  28656. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  28657. private static _tempFogColor;
  28658. /**
  28659. * Binds the fog information from the scene to the effect for the given mesh.
  28660. * @param scene The scene the lights belongs to
  28661. * @param mesh The mesh we are binding the information to render
  28662. * @param effect The effect we are binding the data to
  28663. * @param linearSpace Defines if the fog effect is applied in linear space
  28664. */
  28665. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  28666. /**
  28667. * Binds the bones information from the mesh to the effect.
  28668. * @param mesh The mesh we are binding the information to render
  28669. * @param effect The effect we are binding the data to
  28670. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  28671. */
  28672. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  28673. private static _CopyBonesTransformationMatrices;
  28674. /**
  28675. * Binds the morph targets information from the mesh to the effect.
  28676. * @param abstractMesh The mesh we are binding the information to render
  28677. * @param effect The effect we are binding the data to
  28678. */
  28679. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  28680. /**
  28681. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  28682. * @param defines The generated defines used in the effect
  28683. * @param effect The effect we are binding the data to
  28684. * @param scene The scene we are willing to render with logarithmic scale for
  28685. */
  28686. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  28687. /**
  28688. * Binds the clip plane information from the scene to the effect.
  28689. * @param scene The scene the clip plane information are extracted from
  28690. * @param effect The effect we are binding the data to
  28691. */
  28692. static BindClipPlane(effect: Effect, scene: Scene): void;
  28693. }
  28694. }
  28695. declare module BABYLON {
  28696. /** @hidden */
  28697. export var bayerDitherFunctions: {
  28698. name: string;
  28699. shader: string;
  28700. };
  28701. }
  28702. declare module BABYLON {
  28703. /** @hidden */
  28704. export var shadowMapFragmentDeclaration: {
  28705. name: string;
  28706. shader: string;
  28707. };
  28708. }
  28709. declare module BABYLON {
  28710. /** @hidden */
  28711. export var shadowMapFragment: {
  28712. name: string;
  28713. shader: string;
  28714. };
  28715. }
  28716. declare module BABYLON {
  28717. /** @hidden */
  28718. export var shadowMapPixelShader: {
  28719. name: string;
  28720. shader: string;
  28721. };
  28722. }
  28723. declare module BABYLON {
  28724. /** @hidden */
  28725. export var shadowMapVertexDeclaration: {
  28726. name: string;
  28727. shader: string;
  28728. };
  28729. }
  28730. declare module BABYLON {
  28731. /** @hidden */
  28732. export var shadowMapVertexNormalBias: {
  28733. name: string;
  28734. shader: string;
  28735. };
  28736. }
  28737. declare module BABYLON {
  28738. /** @hidden */
  28739. export var shadowMapVertexMetric: {
  28740. name: string;
  28741. shader: string;
  28742. };
  28743. }
  28744. declare module BABYLON {
  28745. /** @hidden */
  28746. export var shadowMapVertexShader: {
  28747. name: string;
  28748. shader: string;
  28749. };
  28750. }
  28751. declare module BABYLON {
  28752. /** @hidden */
  28753. export var depthBoxBlurPixelShader: {
  28754. name: string;
  28755. shader: string;
  28756. };
  28757. }
  28758. declare module BABYLON {
  28759. /** @hidden */
  28760. export var shadowMapFragmentSoftTransparentShadow: {
  28761. name: string;
  28762. shader: string;
  28763. };
  28764. }
  28765. declare module BABYLON {
  28766. /**
  28767. * Creates an instance based on a source mesh.
  28768. */
  28769. export class InstancedMesh extends AbstractMesh {
  28770. private _sourceMesh;
  28771. private _currentLOD;
  28772. /** @hidden */
  28773. _indexInSourceMeshInstanceArray: number;
  28774. constructor(name: string, source: Mesh);
  28775. /**
  28776. * Returns the string "InstancedMesh".
  28777. */
  28778. getClassName(): string;
  28779. /** Gets the list of lights affecting that mesh */
  28780. get lightSources(): Light[];
  28781. _resyncLightSources(): void;
  28782. _resyncLightSource(light: Light): void;
  28783. _removeLightSource(light: Light, dispose: boolean): void;
  28784. /**
  28785. * If the source mesh receives shadows
  28786. */
  28787. get receiveShadows(): boolean;
  28788. /**
  28789. * The material of the source mesh
  28790. */
  28791. get material(): Nullable<Material>;
  28792. /**
  28793. * Visibility of the source mesh
  28794. */
  28795. get visibility(): number;
  28796. /**
  28797. * Skeleton of the source mesh
  28798. */
  28799. get skeleton(): Nullable<Skeleton>;
  28800. /**
  28801. * Rendering ground id of the source mesh
  28802. */
  28803. get renderingGroupId(): number;
  28804. set renderingGroupId(value: number);
  28805. /**
  28806. * Returns the total number of vertices (integer).
  28807. */
  28808. getTotalVertices(): number;
  28809. /**
  28810. * Returns a positive integer : the total number of indices in this mesh geometry.
  28811. * @returns the numner of indices or zero if the mesh has no geometry.
  28812. */
  28813. getTotalIndices(): number;
  28814. /**
  28815. * The source mesh of the instance
  28816. */
  28817. get sourceMesh(): Mesh;
  28818. /**
  28819. * Creates a new InstancedMesh object from the mesh model.
  28820. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28821. * @param name defines the name of the new instance
  28822. * @returns a new InstancedMesh
  28823. */
  28824. createInstance(name: string): InstancedMesh;
  28825. /**
  28826. * Is this node ready to be used/rendered
  28827. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28828. * @return {boolean} is it ready
  28829. */
  28830. isReady(completeCheck?: boolean): boolean;
  28831. /**
  28832. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  28833. * @param kind kind of verticies to retrieve (eg. positions, normals, uvs, etc.)
  28834. * @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.
  28835. * @returns a float array or a Float32Array of the requested kind of data : positions, normals, uvs, etc.
  28836. */
  28837. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  28838. /**
  28839. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28840. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28841. * The `data` are either a numeric array either a Float32Array.
  28842. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initially none) or updater.
  28843. * 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).
  28844. * Note that a new underlying VertexBuffer object is created each call.
  28845. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28846. *
  28847. * Possible `kind` values :
  28848. * - VertexBuffer.PositionKind
  28849. * - VertexBuffer.UVKind
  28850. * - VertexBuffer.UV2Kind
  28851. * - VertexBuffer.UV3Kind
  28852. * - VertexBuffer.UV4Kind
  28853. * - VertexBuffer.UV5Kind
  28854. * - VertexBuffer.UV6Kind
  28855. * - VertexBuffer.ColorKind
  28856. * - VertexBuffer.MatricesIndicesKind
  28857. * - VertexBuffer.MatricesIndicesExtraKind
  28858. * - VertexBuffer.MatricesWeightsKind
  28859. * - VertexBuffer.MatricesWeightsExtraKind
  28860. *
  28861. * Returns the Mesh.
  28862. */
  28863. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28864. /**
  28865. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28866. * If the mesh has no geometry, it is simply returned as it is.
  28867. * The `data` are either a numeric array either a Float32Array.
  28868. * No new underlying VertexBuffer object is created.
  28869. * 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.
  28870. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  28871. *
  28872. * Possible `kind` values :
  28873. * - VertexBuffer.PositionKind
  28874. * - VertexBuffer.UVKind
  28875. * - VertexBuffer.UV2Kind
  28876. * - VertexBuffer.UV3Kind
  28877. * - VertexBuffer.UV4Kind
  28878. * - VertexBuffer.UV5Kind
  28879. * - VertexBuffer.UV6Kind
  28880. * - VertexBuffer.ColorKind
  28881. * - VertexBuffer.MatricesIndicesKind
  28882. * - VertexBuffer.MatricesIndicesExtraKind
  28883. * - VertexBuffer.MatricesWeightsKind
  28884. * - VertexBuffer.MatricesWeightsExtraKind
  28885. *
  28886. * Returns the Mesh.
  28887. */
  28888. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  28889. /**
  28890. * Sets the mesh indices.
  28891. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  28892. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28893. * This method creates a new index buffer each call.
  28894. * Returns the Mesh.
  28895. */
  28896. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  28897. /**
  28898. * Boolean : True if the mesh owns the requested kind of data.
  28899. */
  28900. isVerticesDataPresent(kind: string): boolean;
  28901. /**
  28902. * Returns an array of indices (IndicesArray).
  28903. */
  28904. getIndices(): Nullable<IndicesArray>;
  28905. get _positions(): Nullable<Vector3[]>;
  28906. /**
  28907. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28908. * This means the mesh underlying bounding box and sphere are recomputed.
  28909. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28910. * @returns the current mesh
  28911. */
  28912. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  28913. /** @hidden */
  28914. _preActivate(): InstancedMesh;
  28915. /** @hidden */
  28916. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28917. /** @hidden */
  28918. _postActivate(): void;
  28919. getWorldMatrix(): Matrix;
  28920. get isAnInstance(): boolean;
  28921. /**
  28922. * Returns the current associated LOD AbstractMesh.
  28923. */
  28924. getLOD(camera: Camera): AbstractMesh;
  28925. /** @hidden */
  28926. _preActivateForIntermediateRendering(renderId: number): Mesh;
  28927. /** @hidden */
  28928. _syncSubMeshes(): InstancedMesh;
  28929. /** @hidden */
  28930. _generatePointsArray(): boolean;
  28931. /** @hidden */
  28932. _updateBoundingInfo(): AbstractMesh;
  28933. /**
  28934. * Creates a new InstancedMesh from the current mesh.
  28935. * - name (string) : the cloned mesh name
  28936. * - newParent (optional Node) : the optional Node to parent the clone to.
  28937. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  28938. *
  28939. * Returns the clone.
  28940. */
  28941. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  28942. /**
  28943. * Disposes the InstancedMesh.
  28944. * Returns nothing.
  28945. */
  28946. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28947. }
  28948. interface Mesh {
  28949. /**
  28950. * Register a custom buffer that will be instanced
  28951. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  28952. * @param kind defines the buffer kind
  28953. * @param stride defines the stride in floats
  28954. */
  28955. registerInstancedBuffer(kind: string, stride: number): void;
  28956. /**
  28957. * Invalidate VertexArrayObjects belonging to the mesh (but not to the Geometry of the mesh).
  28958. */
  28959. _invalidateInstanceVertexArrayObject(): void;
  28960. /**
  28961. * true to use the edge renderer for all instances of this mesh
  28962. */
  28963. edgesShareWithInstances: boolean;
  28964. /** @hidden */
  28965. _userInstancedBuffersStorage: {
  28966. data: {
  28967. [key: string]: Float32Array;
  28968. };
  28969. sizes: {
  28970. [key: string]: number;
  28971. };
  28972. vertexBuffers: {
  28973. [key: string]: Nullable<VertexBuffer>;
  28974. };
  28975. strides: {
  28976. [key: string]: number;
  28977. };
  28978. vertexArrayObjects?: {
  28979. [key: string]: WebGLVertexArrayObject;
  28980. };
  28981. };
  28982. }
  28983. interface AbstractMesh {
  28984. /**
  28985. * Object used to store instanced buffers defined by user
  28986. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  28987. */
  28988. instancedBuffers: {
  28989. [key: string]: any;
  28990. };
  28991. }
  28992. }
  28993. declare module BABYLON {
  28994. /**
  28995. * Defines the options associated with the creation of a shader material.
  28996. */
  28997. export interface IShaderMaterialOptions {
  28998. /**
  28999. * Does the material work in alpha blend mode
  29000. */
  29001. needAlphaBlending: boolean;
  29002. /**
  29003. * Does the material work in alpha test mode
  29004. */
  29005. needAlphaTesting: boolean;
  29006. /**
  29007. * The list of attribute names used in the shader
  29008. */
  29009. attributes: string[];
  29010. /**
  29011. * The list of uniform names used in the shader
  29012. */
  29013. uniforms: string[];
  29014. /**
  29015. * The list of UBO names used in the shader
  29016. */
  29017. uniformBuffers: string[];
  29018. /**
  29019. * The list of sampler names used in the shader
  29020. */
  29021. samplers: string[];
  29022. /**
  29023. * The list of defines used in the shader
  29024. */
  29025. defines: string[];
  29026. }
  29027. /**
  29028. * 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.
  29029. *
  29030. * This returned material effects how the mesh will look based on the code in the shaders.
  29031. *
  29032. * @see https://doc.babylonjs.com/how_to/shader_material
  29033. */
  29034. export class ShaderMaterial extends Material {
  29035. private _shaderPath;
  29036. private _options;
  29037. private _textures;
  29038. private _textureArrays;
  29039. private _floats;
  29040. private _ints;
  29041. private _floatsArrays;
  29042. private _colors3;
  29043. private _colors3Arrays;
  29044. private _colors4;
  29045. private _colors4Arrays;
  29046. private _vectors2;
  29047. private _vectors3;
  29048. private _vectors4;
  29049. private _matrices;
  29050. private _matrixArrays;
  29051. private _matrices3x3;
  29052. private _matrices2x2;
  29053. private _vectors2Arrays;
  29054. private _vectors3Arrays;
  29055. private _vectors4Arrays;
  29056. private _cachedWorldViewMatrix;
  29057. private _cachedWorldViewProjectionMatrix;
  29058. private _renderId;
  29059. private _multiview;
  29060. private _cachedDefines;
  29061. /** Define the Url to load snippets */
  29062. static SnippetUrl: string;
  29063. /** Snippet ID if the material was created from the snippet server */
  29064. snippetId: string;
  29065. /**
  29066. * Instantiate a new shader material.
  29067. * 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.
  29068. * This returned material effects how the mesh will look based on the code in the shaders.
  29069. * @see https://doc.babylonjs.com/how_to/shader_material
  29070. * @param name Define the name of the material in the scene
  29071. * @param scene Define the scene the material belongs to
  29072. * @param shaderPath Defines the route to the shader code in one of three ways:
  29073. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  29074. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  29075. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  29076. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  29077. * @param options Define the options used to create the shader
  29078. */
  29079. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  29080. /**
  29081. * Gets the shader path used to define the shader code
  29082. * It can be modified to trigger a new compilation
  29083. */
  29084. get shaderPath(): any;
  29085. /**
  29086. * Sets the shader path used to define the shader code
  29087. * It can be modified to trigger a new compilation
  29088. */
  29089. set shaderPath(shaderPath: any);
  29090. /**
  29091. * Gets the options used to compile the shader.
  29092. * They can be modified to trigger a new compilation
  29093. */
  29094. get options(): IShaderMaterialOptions;
  29095. /**
  29096. * Gets the current class name of the material e.g. "ShaderMaterial"
  29097. * Mainly use in serialization.
  29098. * @returns the class name
  29099. */
  29100. getClassName(): string;
  29101. /**
  29102. * Specifies if the material will require alpha blending
  29103. * @returns a boolean specifying if alpha blending is needed
  29104. */
  29105. needAlphaBlending(): boolean;
  29106. /**
  29107. * Specifies if this material should be rendered in alpha test mode
  29108. * @returns a boolean specifying if an alpha test is needed.
  29109. */
  29110. needAlphaTesting(): boolean;
  29111. private _checkUniform;
  29112. /**
  29113. * Set a texture in the shader.
  29114. * @param name Define the name of the uniform samplers as defined in the shader
  29115. * @param texture Define the texture to bind to this sampler
  29116. * @return the material itself allowing "fluent" like uniform updates
  29117. */
  29118. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  29119. /**
  29120. * Set a texture array in the shader.
  29121. * @param name Define the name of the uniform sampler array as defined in the shader
  29122. * @param textures Define the list of textures to bind to this sampler
  29123. * @return the material itself allowing "fluent" like uniform updates
  29124. */
  29125. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  29126. /**
  29127. * Set a float in the shader.
  29128. * @param name Define the name of the uniform as defined in the shader
  29129. * @param value Define the value to give to the uniform
  29130. * @return the material itself allowing "fluent" like uniform updates
  29131. */
  29132. setFloat(name: string, value: number): ShaderMaterial;
  29133. /**
  29134. * Set a int in the shader.
  29135. * @param name Define the name of the uniform as defined in the shader
  29136. * @param value Define the value to give to the uniform
  29137. * @return the material itself allowing "fluent" like uniform updates
  29138. */
  29139. setInt(name: string, value: number): ShaderMaterial;
  29140. /**
  29141. * Set an array of floats in the shader.
  29142. * @param name Define the name of the uniform as defined in the shader
  29143. * @param value Define the value to give to the uniform
  29144. * @return the material itself allowing "fluent" like uniform updates
  29145. */
  29146. setFloats(name: string, value: number[]): ShaderMaterial;
  29147. /**
  29148. * Set a vec3 in the shader from a Color3.
  29149. * @param name Define the name of the uniform as defined in the shader
  29150. * @param value Define the value to give to the uniform
  29151. * @return the material itself allowing "fluent" like uniform updates
  29152. */
  29153. setColor3(name: string, value: Color3): ShaderMaterial;
  29154. /**
  29155. * Set a vec3 array in the shader from a Color3 array.
  29156. * @param name Define the name of the uniform as defined in the shader
  29157. * @param value Define the value to give to the uniform
  29158. * @return the material itself allowing "fluent" like uniform updates
  29159. */
  29160. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  29161. /**
  29162. * Set a vec4 in the shader from a Color4.
  29163. * @param name Define the name of the uniform as defined in the shader
  29164. * @param value Define the value to give to the uniform
  29165. * @return the material itself allowing "fluent" like uniform updates
  29166. */
  29167. setColor4(name: string, value: Color4): ShaderMaterial;
  29168. /**
  29169. * Set a vec4 array in the shader from a Color4 array.
  29170. * @param name Define the name of the uniform as defined in the shader
  29171. * @param value Define the value to give to the uniform
  29172. * @return the material itself allowing "fluent" like uniform updates
  29173. */
  29174. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  29175. /**
  29176. * Set a vec2 in the shader from a Vector2.
  29177. * @param name Define the name of the uniform as defined in the shader
  29178. * @param value Define the value to give to the uniform
  29179. * @return the material itself allowing "fluent" like uniform updates
  29180. */
  29181. setVector2(name: string, value: Vector2): ShaderMaterial;
  29182. /**
  29183. * Set a vec3 in the shader from a Vector3.
  29184. * @param name Define the name of the uniform as defined in the shader
  29185. * @param value Define the value to give to the uniform
  29186. * @return the material itself allowing "fluent" like uniform updates
  29187. */
  29188. setVector3(name: string, value: Vector3): ShaderMaterial;
  29189. /**
  29190. * Set a vec4 in the shader from a Vector4.
  29191. * @param name Define the name of the uniform as defined in the shader
  29192. * @param value Define the value to give to the uniform
  29193. * @return the material itself allowing "fluent" like uniform updates
  29194. */
  29195. setVector4(name: string, value: Vector4): ShaderMaterial;
  29196. /**
  29197. * Set a mat4 in the shader from a Matrix.
  29198. * @param name Define the name of the uniform as defined in the shader
  29199. * @param value Define the value to give to the uniform
  29200. * @return the material itself allowing "fluent" like uniform updates
  29201. */
  29202. setMatrix(name: string, value: Matrix): ShaderMaterial;
  29203. /**
  29204. * Set a float32Array in the shader from a matrix array.
  29205. * @param name Define the name of the uniform as defined in the shader
  29206. * @param value Define the value to give to the uniform
  29207. * @return the material itself allowing "fluent" like uniform updates
  29208. */
  29209. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  29210. /**
  29211. * Set a mat3 in the shader from a Float32Array.
  29212. * @param name Define the name of the uniform as defined in the shader
  29213. * @param value Define the value to give to the uniform
  29214. * @return the material itself allowing "fluent" like uniform updates
  29215. */
  29216. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  29217. /**
  29218. * Set a mat2 in the shader from a Float32Array.
  29219. * @param name Define the name of the uniform as defined in the shader
  29220. * @param value Define the value to give to the uniform
  29221. * @return the material itself allowing "fluent" like uniform updates
  29222. */
  29223. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  29224. /**
  29225. * Set a vec2 array in the shader from a number array.
  29226. * @param name Define the name of the uniform as defined in the shader
  29227. * @param value Define the value to give to the uniform
  29228. * @return the material itself allowing "fluent" like uniform updates
  29229. */
  29230. setArray2(name: string, value: number[]): ShaderMaterial;
  29231. /**
  29232. * Set a vec3 array in the shader from a number array.
  29233. * @param name Define the name of the uniform as defined in the shader
  29234. * @param value Define the value to give to the uniform
  29235. * @return the material itself allowing "fluent" like uniform updates
  29236. */
  29237. setArray3(name: string, value: number[]): ShaderMaterial;
  29238. /**
  29239. * Set a vec4 array in the shader from a number array.
  29240. * @param name Define the name of the uniform as defined in the shader
  29241. * @param value Define the value to give to the uniform
  29242. * @return the material itself allowing "fluent" like uniform updates
  29243. */
  29244. setArray4(name: string, value: number[]): ShaderMaterial;
  29245. private _checkCache;
  29246. /**
  29247. * Specifies that the submesh is ready to be used
  29248. * @param mesh defines the mesh to check
  29249. * @param subMesh defines which submesh to check
  29250. * @param useInstances specifies that instances should be used
  29251. * @returns a boolean indicating that the submesh is ready or not
  29252. */
  29253. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  29254. /**
  29255. * Checks if the material is ready to render the requested mesh
  29256. * @param mesh Define the mesh to render
  29257. * @param useInstances Define whether or not the material is used with instances
  29258. * @returns true if ready, otherwise false
  29259. */
  29260. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  29261. /**
  29262. * Binds the world matrix to the material
  29263. * @param world defines the world transformation matrix
  29264. * @param effectOverride - If provided, use this effect instead of internal effect
  29265. */
  29266. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  29267. /**
  29268. * Binds the submesh to this material by preparing the effect and shader to draw
  29269. * @param world defines the world transformation matrix
  29270. * @param mesh defines the mesh containing the submesh
  29271. * @param subMesh defines the submesh to bind the material to
  29272. */
  29273. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  29274. /**
  29275. * Binds the material to the mesh
  29276. * @param world defines the world transformation matrix
  29277. * @param mesh defines the mesh to bind the material to
  29278. * @param effectOverride - If provided, use this effect instead of internal effect
  29279. */
  29280. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  29281. protected _afterBind(mesh?: Mesh, effect?: Nullable<Effect>): void;
  29282. /**
  29283. * Gets the active textures from the material
  29284. * @returns an array of textures
  29285. */
  29286. getActiveTextures(): BaseTexture[];
  29287. /**
  29288. * Specifies if the material uses a texture
  29289. * @param texture defines the texture to check against the material
  29290. * @returns a boolean specifying if the material uses the texture
  29291. */
  29292. hasTexture(texture: BaseTexture): boolean;
  29293. /**
  29294. * Makes a duplicate of the material, and gives it a new name
  29295. * @param name defines the new name for the duplicated material
  29296. * @returns the cloned material
  29297. */
  29298. clone(name: string): ShaderMaterial;
  29299. /**
  29300. * Disposes the material
  29301. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  29302. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  29303. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  29304. */
  29305. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  29306. /**
  29307. * Serializes this material in a JSON representation
  29308. * @returns the serialized material object
  29309. */
  29310. serialize(): any;
  29311. /**
  29312. * Creates a shader material from parsed shader material data
  29313. * @param source defines the JSON representation of the material
  29314. * @param scene defines the hosting scene
  29315. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  29316. * @returns a new material
  29317. */
  29318. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  29319. /**
  29320. * Creates a new ShaderMaterial from a snippet saved in a remote file
  29321. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  29322. * @param url defines the url to load from
  29323. * @param scene defines the hosting scene
  29324. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  29325. * @returns a promise that will resolve to the new ShaderMaterial
  29326. */
  29327. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  29328. /**
  29329. * Creates a ShaderMaterial from a snippet saved by the Inspector
  29330. * @param snippetId defines the snippet to load
  29331. * @param scene defines the hosting scene
  29332. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  29333. * @returns a promise that will resolve to the new ShaderMaterial
  29334. */
  29335. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  29336. }
  29337. }
  29338. declare module BABYLON {
  29339. /** @hidden */
  29340. export var colorPixelShader: {
  29341. name: string;
  29342. shader: string;
  29343. };
  29344. }
  29345. declare module BABYLON {
  29346. /** @hidden */
  29347. export var colorVertexShader: {
  29348. name: string;
  29349. shader: string;
  29350. };
  29351. }
  29352. declare module BABYLON {
  29353. /**
  29354. * Line mesh
  29355. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  29356. */
  29357. export class LinesMesh extends Mesh {
  29358. /**
  29359. * If vertex color should be applied to the mesh
  29360. */
  29361. readonly useVertexColor?: boolean | undefined;
  29362. /**
  29363. * If vertex alpha should be applied to the mesh
  29364. */
  29365. readonly useVertexAlpha?: boolean | undefined;
  29366. /**
  29367. * Color of the line (Default: White)
  29368. */
  29369. color: Color3;
  29370. /**
  29371. * Alpha of the line (Default: 1)
  29372. */
  29373. alpha: number;
  29374. /**
  29375. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  29376. * This margin is expressed in world space coordinates, so its value may vary.
  29377. * Default value is 0.1
  29378. */
  29379. intersectionThreshold: number;
  29380. private _colorShader;
  29381. private color4;
  29382. /**
  29383. * Creates a new LinesMesh
  29384. * @param name defines the name
  29385. * @param scene defines the hosting scene
  29386. * @param parent defines the parent mesh if any
  29387. * @param source defines the optional source LinesMesh used to clone data from
  29388. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  29389. * When false, achieved by calling a clone(), also passing False.
  29390. * This will make creation of children, recursive.
  29391. * @param useVertexColor defines if this LinesMesh supports vertex color
  29392. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  29393. */
  29394. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  29395. /**
  29396. * If vertex color should be applied to the mesh
  29397. */
  29398. useVertexColor?: boolean | undefined,
  29399. /**
  29400. * If vertex alpha should be applied to the mesh
  29401. */
  29402. useVertexAlpha?: boolean | undefined);
  29403. private _addClipPlaneDefine;
  29404. private _removeClipPlaneDefine;
  29405. isReady(): boolean;
  29406. /**
  29407. * Returns the string "LineMesh"
  29408. */
  29409. getClassName(): string;
  29410. /**
  29411. * @hidden
  29412. */
  29413. get material(): Material;
  29414. /**
  29415. * @hidden
  29416. */
  29417. set material(value: Material);
  29418. /**
  29419. * @hidden
  29420. */
  29421. get checkCollisions(): boolean;
  29422. set checkCollisions(value: boolean);
  29423. /** @hidden */
  29424. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  29425. /** @hidden */
  29426. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  29427. /**
  29428. * Disposes of the line mesh
  29429. * @param doNotRecurse If children should be disposed
  29430. */
  29431. dispose(doNotRecurse?: boolean): void;
  29432. /**
  29433. * Returns a new LineMesh object cloned from the current one.
  29434. */
  29435. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  29436. /**
  29437. * Creates a new InstancedLinesMesh object from the mesh model.
  29438. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  29439. * @param name defines the name of the new instance
  29440. * @returns a new InstancedLinesMesh
  29441. */
  29442. createInstance(name: string): InstancedLinesMesh;
  29443. }
  29444. /**
  29445. * Creates an instance based on a source LinesMesh
  29446. */
  29447. export class InstancedLinesMesh extends InstancedMesh {
  29448. /**
  29449. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  29450. * This margin is expressed in world space coordinates, so its value may vary.
  29451. * Initialized with the intersectionThreshold value of the source LinesMesh
  29452. */
  29453. intersectionThreshold: number;
  29454. constructor(name: string, source: LinesMesh);
  29455. /**
  29456. * Returns the string "InstancedLinesMesh".
  29457. */
  29458. getClassName(): string;
  29459. }
  29460. }
  29461. declare module BABYLON {
  29462. /** @hidden */
  29463. export var linePixelShader: {
  29464. name: string;
  29465. shader: string;
  29466. };
  29467. }
  29468. declare module BABYLON {
  29469. /** @hidden */
  29470. export var lineVertexShader: {
  29471. name: string;
  29472. shader: string;
  29473. };
  29474. }
  29475. declare module BABYLON {
  29476. interface Scene {
  29477. /** @hidden */
  29478. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  29479. }
  29480. interface AbstractMesh {
  29481. /**
  29482. * Gets the edgesRenderer associated with the mesh
  29483. */
  29484. edgesRenderer: Nullable<EdgesRenderer>;
  29485. }
  29486. interface LinesMesh {
  29487. /**
  29488. * Enables the edge rendering mode on the mesh.
  29489. * This mode makes the mesh edges visible
  29490. * @param epsilon defines the maximal distance between two angles to detect a face
  29491. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29492. * @returns the currentAbstractMesh
  29493. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29494. */
  29495. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  29496. }
  29497. interface InstancedLinesMesh {
  29498. /**
  29499. * Enables the edge rendering mode on the mesh.
  29500. * This mode makes the mesh edges visible
  29501. * @param epsilon defines the maximal distance between two angles to detect a face
  29502. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29503. * @returns the current InstancedLinesMesh
  29504. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29505. */
  29506. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  29507. }
  29508. /**
  29509. * Defines the minimum contract an Edges renderer should follow.
  29510. */
  29511. export interface IEdgesRenderer extends IDisposable {
  29512. /**
  29513. * Gets or sets a boolean indicating if the edgesRenderer is active
  29514. */
  29515. isEnabled: boolean;
  29516. /**
  29517. * Renders the edges of the attached mesh,
  29518. */
  29519. render(): void;
  29520. /**
  29521. * Checks whether or not the edges renderer is ready to render.
  29522. * @return true if ready, otherwise false.
  29523. */
  29524. isReady(): boolean;
  29525. /**
  29526. * List of instances to render in case the source mesh has instances
  29527. */
  29528. customInstances: SmartArray<Matrix>;
  29529. }
  29530. /**
  29531. * Defines the additional options of the edges renderer
  29532. */
  29533. export interface IEdgesRendererOptions {
  29534. /**
  29535. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  29536. * If not defined, the default value is true
  29537. */
  29538. useAlternateEdgeFinder?: boolean;
  29539. /**
  29540. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  29541. * If not defined, the default value is true.
  29542. * 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)
  29543. * This option is used only if useAlternateEdgeFinder = true
  29544. */
  29545. useFastVertexMerger?: boolean;
  29546. /**
  29547. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit within which vertices are considered to be equal.
  29548. * The default value is 1e-6
  29549. * This option is used only if useAlternateEdgeFinder = true
  29550. */
  29551. epsilonVertexMerge?: number;
  29552. /**
  29553. * 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
  29554. * 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.
  29555. * This option is used only if useAlternateEdgeFinder = true
  29556. */
  29557. applyTessellation?: boolean;
  29558. /**
  29559. * 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
  29560. * The default value is 1e-6
  29561. * This option is used only if useAlternateEdgeFinder = true
  29562. */
  29563. epsilonVertexAligned?: number;
  29564. }
  29565. /**
  29566. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  29567. */
  29568. export class EdgesRenderer implements IEdgesRenderer {
  29569. /**
  29570. * Define the size of the edges with an orthographic camera
  29571. */
  29572. edgesWidthScalerForOrthographic: number;
  29573. /**
  29574. * Define the size of the edges with a perspective camera
  29575. */
  29576. edgesWidthScalerForPerspective: number;
  29577. protected _source: AbstractMesh;
  29578. protected _linesPositions: number[];
  29579. protected _linesNormals: number[];
  29580. protected _linesIndices: number[];
  29581. protected _epsilon: number;
  29582. protected _indicesCount: number;
  29583. protected _lineShader: ShaderMaterial;
  29584. protected _ib: DataBuffer;
  29585. protected _buffers: {
  29586. [key: string]: Nullable<VertexBuffer>;
  29587. };
  29588. protected _buffersForInstances: {
  29589. [key: string]: Nullable<VertexBuffer>;
  29590. };
  29591. protected _checkVerticesInsteadOfIndices: boolean;
  29592. protected _options: Nullable<IEdgesRendererOptions>;
  29593. private _meshRebuildObserver;
  29594. private _meshDisposeObserver;
  29595. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  29596. isEnabled: boolean;
  29597. /** Gets the vertices generated by the edge renderer */
  29598. get linesPositions(): Immutable<Array<number>>;
  29599. /** Gets the normals generated by the edge renderer */
  29600. get linesNormals(): Immutable<Array<number>>;
  29601. /** Gets the indices generated by the edge renderer */
  29602. get linesIndices(): Immutable<Array<number>>;
  29603. /**
  29604. * List of instances to render in case the source mesh has instances
  29605. */
  29606. customInstances: SmartArray<Matrix>;
  29607. private static GetShader;
  29608. /**
  29609. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  29610. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  29611. * @param source Mesh used to create edges
  29612. * @param epsilon sum of angles in adjacency to check for edge
  29613. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  29614. * @param generateEdgesLines - should generate Lines or only prepare resources.
  29615. * @param options The options to apply when generating the edges
  29616. */
  29617. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  29618. protected _prepareRessources(): void;
  29619. /** @hidden */
  29620. _rebuild(): void;
  29621. /**
  29622. * Releases the required resources for the edges renderer
  29623. */
  29624. dispose(): void;
  29625. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  29626. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  29627. /**
  29628. * Checks if the pair of p0 and p1 is en edge
  29629. * @param faceIndex
  29630. * @param edge
  29631. * @param faceNormals
  29632. * @param p0
  29633. * @param p1
  29634. * @private
  29635. */
  29636. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  29637. /**
  29638. * push line into the position, normal and index buffer
  29639. * @protected
  29640. */
  29641. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  29642. /**
  29643. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  29644. */
  29645. private _tessellateTriangle;
  29646. private _generateEdgesLinesAlternate;
  29647. /**
  29648. * Generates lines edges from adjacencjes
  29649. * @private
  29650. */
  29651. _generateEdgesLines(): void;
  29652. /**
  29653. * Checks whether or not the edges renderer is ready to render.
  29654. * @return true if ready, otherwise false.
  29655. */
  29656. isReady(): boolean;
  29657. /**
  29658. * Renders the edges of the attached mesh,
  29659. */
  29660. render(): void;
  29661. }
  29662. /**
  29663. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  29664. */
  29665. export class LineEdgesRenderer extends EdgesRenderer {
  29666. /**
  29667. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  29668. * @param source LineMesh used to generate edges
  29669. * @param epsilon not important (specified angle for edge detection)
  29670. * @param checkVerticesInsteadOfIndices not important for LineMesh
  29671. */
  29672. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  29673. /**
  29674. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  29675. */
  29676. _generateEdgesLines(): void;
  29677. }
  29678. }
  29679. declare module BABYLON {
  29680. /**
  29681. * This represents the object necessary to create a rendering group.
  29682. * This is exclusively used and created by the rendering manager.
  29683. * To modify the behavior, you use the available helpers in your scene or meshes.
  29684. * @hidden
  29685. */
  29686. export class RenderingGroup {
  29687. index: number;
  29688. private static _zeroVector;
  29689. private _scene;
  29690. private _opaqueSubMeshes;
  29691. private _transparentSubMeshes;
  29692. private _alphaTestSubMeshes;
  29693. private _depthOnlySubMeshes;
  29694. private _particleSystems;
  29695. private _spriteManagers;
  29696. private _opaqueSortCompareFn;
  29697. private _alphaTestSortCompareFn;
  29698. private _transparentSortCompareFn;
  29699. private _renderOpaque;
  29700. private _renderAlphaTest;
  29701. private _renderTransparent;
  29702. /** @hidden */
  29703. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  29704. onBeforeTransparentRendering: () => void;
  29705. /**
  29706. * Set the opaque sort comparison function.
  29707. * If null the sub meshes will be render in the order they were created
  29708. */
  29709. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  29710. /**
  29711. * Set the alpha test sort comparison function.
  29712. * If null the sub meshes will be render in the order they were created
  29713. */
  29714. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  29715. /**
  29716. * Set the transparent sort comparison function.
  29717. * If null the sub meshes will be render in the order they were created
  29718. */
  29719. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  29720. /**
  29721. * Creates a new rendering group.
  29722. * @param index The rendering group index
  29723. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  29724. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  29725. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  29726. */
  29727. 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>);
  29728. /**
  29729. * Render all the sub meshes contained in the group.
  29730. * @param customRenderFunction Used to override the default render behaviour of the group.
  29731. * @returns true if rendered some submeshes.
  29732. */
  29733. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  29734. /**
  29735. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  29736. * @param subMeshes The submeshes to render
  29737. */
  29738. private renderOpaqueSorted;
  29739. /**
  29740. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  29741. * @param subMeshes The submeshes to render
  29742. */
  29743. private renderAlphaTestSorted;
  29744. /**
  29745. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  29746. * @param subMeshes The submeshes to render
  29747. */
  29748. private renderTransparentSorted;
  29749. /**
  29750. * Renders the submeshes in a specified order.
  29751. * @param subMeshes The submeshes to sort before render
  29752. * @param sortCompareFn The comparison function use to sort
  29753. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  29754. * @param transparent Specifies to activate blending if true
  29755. */
  29756. private static renderSorted;
  29757. /**
  29758. * Renders the submeshes in the order they were dispatched (no sort applied).
  29759. * @param subMeshes The submeshes to render
  29760. */
  29761. private static renderUnsorted;
  29762. /**
  29763. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29764. * are rendered back to front if in the same alpha index.
  29765. *
  29766. * @param a The first submesh
  29767. * @param b The second submesh
  29768. * @returns The result of the comparison
  29769. */
  29770. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  29771. /**
  29772. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29773. * are rendered back to front.
  29774. *
  29775. * @param a The first submesh
  29776. * @param b The second submesh
  29777. * @returns The result of the comparison
  29778. */
  29779. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  29780. /**
  29781. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29782. * are rendered front to back (prevent overdraw).
  29783. *
  29784. * @param a The first submesh
  29785. * @param b The second submesh
  29786. * @returns The result of the comparison
  29787. */
  29788. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  29789. /**
  29790. * Resets the different lists of submeshes to prepare a new frame.
  29791. */
  29792. prepare(): void;
  29793. dispose(): void;
  29794. /**
  29795. * Inserts the submesh in its correct queue depending on its material.
  29796. * @param subMesh The submesh to dispatch
  29797. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  29798. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  29799. */
  29800. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  29801. dispatchSprites(spriteManager: ISpriteManager): void;
  29802. dispatchParticles(particleSystem: IParticleSystem): void;
  29803. private _renderParticles;
  29804. private _renderSprites;
  29805. }
  29806. }
  29807. declare module BABYLON {
  29808. /**
  29809. * Interface describing the different options available in the rendering manager
  29810. * regarding Auto Clear between groups.
  29811. */
  29812. export interface IRenderingManagerAutoClearSetup {
  29813. /**
  29814. * Defines whether or not autoclear is enable.
  29815. */
  29816. autoClear: boolean;
  29817. /**
  29818. * Defines whether or not to autoclear the depth buffer.
  29819. */
  29820. depth: boolean;
  29821. /**
  29822. * Defines whether or not to autoclear the stencil buffer.
  29823. */
  29824. stencil: boolean;
  29825. }
  29826. /**
  29827. * This class is used by the onRenderingGroupObservable
  29828. */
  29829. export class RenderingGroupInfo {
  29830. /**
  29831. * The Scene that being rendered
  29832. */
  29833. scene: Scene;
  29834. /**
  29835. * The camera currently used for the rendering pass
  29836. */
  29837. camera: Nullable<Camera>;
  29838. /**
  29839. * The ID of the renderingGroup being processed
  29840. */
  29841. renderingGroupId: number;
  29842. }
  29843. /**
  29844. * This is the manager responsible of all the rendering for meshes sprites and particles.
  29845. * It is enable to manage the different groups as well as the different necessary sort functions.
  29846. * This should not be used directly aside of the few static configurations
  29847. */
  29848. export class RenderingManager {
  29849. /**
  29850. * The max id used for rendering groups (not included)
  29851. */
  29852. static MAX_RENDERINGGROUPS: number;
  29853. /**
  29854. * The min id used for rendering groups (included)
  29855. */
  29856. static MIN_RENDERINGGROUPS: number;
  29857. /**
  29858. * Used to globally prevent autoclearing scenes.
  29859. */
  29860. static AUTOCLEAR: boolean;
  29861. /**
  29862. * @hidden
  29863. */
  29864. _useSceneAutoClearSetup: boolean;
  29865. private _scene;
  29866. private _renderingGroups;
  29867. private _depthStencilBufferAlreadyCleaned;
  29868. private _autoClearDepthStencil;
  29869. private _customOpaqueSortCompareFn;
  29870. private _customAlphaTestSortCompareFn;
  29871. private _customTransparentSortCompareFn;
  29872. private _renderingGroupInfo;
  29873. /**
  29874. * Instantiates a new rendering group for a particular scene
  29875. * @param scene Defines the scene the groups belongs to
  29876. */
  29877. constructor(scene: Scene);
  29878. private _clearDepthStencilBuffer;
  29879. /**
  29880. * Renders the entire managed groups. This is used by the scene or the different render targets.
  29881. * @hidden
  29882. */
  29883. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  29884. /**
  29885. * Resets the different information of the group to prepare a new frame
  29886. * @hidden
  29887. */
  29888. reset(): void;
  29889. /**
  29890. * Dispose and release the group and its associated resources.
  29891. * @hidden
  29892. */
  29893. dispose(): void;
  29894. /**
  29895. * Clear the info related to rendering groups preventing retention points during dispose.
  29896. */
  29897. freeRenderingGroups(): void;
  29898. private _prepareRenderingGroup;
  29899. /**
  29900. * Add a sprite manager to the rendering manager in order to render it this frame.
  29901. * @param spriteManager Define the sprite manager to render
  29902. */
  29903. dispatchSprites(spriteManager: ISpriteManager): void;
  29904. /**
  29905. * Add a particle system to the rendering manager in order to render it this frame.
  29906. * @param particleSystem Define the particle system to render
  29907. */
  29908. dispatchParticles(particleSystem: IParticleSystem): void;
  29909. /**
  29910. * Add a submesh to the manager in order to render it this frame
  29911. * @param subMesh The submesh to dispatch
  29912. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  29913. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  29914. */
  29915. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  29916. /**
  29917. * Overrides the default sort function applied in the rendering group to prepare the meshes.
  29918. * This allowed control for front to back rendering or reversely depending of the special needs.
  29919. *
  29920. * @param renderingGroupId The rendering group id corresponding to its index
  29921. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  29922. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  29923. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  29924. */
  29925. 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;
  29926. /**
  29927. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  29928. *
  29929. * @param renderingGroupId The rendering group id corresponding to its index
  29930. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  29931. * @param depth Automatically clears depth between groups if true and autoClear is true.
  29932. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  29933. */
  29934. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  29935. /**
  29936. * Gets the current auto clear configuration for one rendering group of the rendering
  29937. * manager.
  29938. * @param index the rendering group index to get the information for
  29939. * @returns The auto clear setup for the requested rendering group
  29940. */
  29941. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  29942. }
  29943. }
  29944. declare module BABYLON {
  29945. /**
  29946. * Defines the options associated with the creation of a custom shader for a shadow generator.
  29947. */
  29948. export interface ICustomShaderOptions {
  29949. /**
  29950. * Gets or sets the custom shader name to use
  29951. */
  29952. shaderName: string;
  29953. /**
  29954. * The list of attribute names used in the shader
  29955. */
  29956. attributes?: string[];
  29957. /**
  29958. * The list of uniform names used in the shader
  29959. */
  29960. uniforms?: string[];
  29961. /**
  29962. * The list of sampler names used in the shader
  29963. */
  29964. samplers?: string[];
  29965. /**
  29966. * The list of defines used in the shader
  29967. */
  29968. defines?: string[];
  29969. }
  29970. /**
  29971. * Interface to implement to create a shadow generator compatible with BJS.
  29972. */
  29973. export interface IShadowGenerator {
  29974. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  29975. id: string;
  29976. /**
  29977. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  29978. * @returns The render target texture if present otherwise, null
  29979. */
  29980. getShadowMap(): Nullable<RenderTargetTexture>;
  29981. /**
  29982. * Determine whether the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  29983. * @param subMesh The submesh we want to render in the shadow map
  29984. * @param useInstances Defines whether will draw in the map using instances
  29985. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  29986. * @returns true if ready otherwise, false
  29987. */
  29988. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  29989. /**
  29990. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  29991. * @param defines Defines of the material we want to update
  29992. * @param lightIndex Index of the light in the enabled light list of the material
  29993. */
  29994. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  29995. /**
  29996. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  29997. * defined in the generator but impacting the effect).
  29998. * It implies the uniforms available on the materials are the standard BJS ones.
  29999. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  30000. * @param effect The effect we are binding the information for
  30001. */
  30002. bindShadowLight(lightIndex: string, effect: Effect): void;
  30003. /**
  30004. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  30005. * (eq to shadow projection matrix * light transform matrix)
  30006. * @returns The transform matrix used to create the shadow map
  30007. */
  30008. getTransformMatrix(): Matrix;
  30009. /**
  30010. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  30011. * Cube and 2D textures for instance.
  30012. */
  30013. recreateShadowMap(): void;
  30014. /**
  30015. * Forces all the attached effect to compile to enable rendering only once ready vs. lazily compiling effects.
  30016. * @param onCompiled Callback triggered at the and of the effects compilation
  30017. * @param options Sets of optional options forcing the compilation with different modes
  30018. */
  30019. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  30020. useInstances: boolean;
  30021. }>): void;
  30022. /**
  30023. * Forces all the attached effect to compile to enable rendering only once ready vs. lazily compiling effects.
  30024. * @param options Sets of optional options forcing the compilation with different modes
  30025. * @returns A promise that resolves when the compilation completes
  30026. */
  30027. forceCompilationAsync(options?: Partial<{
  30028. useInstances: boolean;
  30029. }>): Promise<void>;
  30030. /**
  30031. * Serializes the shadow generator setup to a json object.
  30032. * @returns The serialized JSON object
  30033. */
  30034. serialize(): any;
  30035. /**
  30036. * Disposes the Shadow map and related Textures and effects.
  30037. */
  30038. dispose(): void;
  30039. }
  30040. /**
  30041. * Default implementation IShadowGenerator.
  30042. * This is the main object responsible of generating shadows in the framework.
  30043. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  30044. */
  30045. export class ShadowGenerator implements IShadowGenerator {
  30046. private static _Counter;
  30047. /**
  30048. * Name of the shadow generator class
  30049. */
  30050. static CLASSNAME: string;
  30051. /**
  30052. * Shadow generator mode None: no filtering applied.
  30053. */
  30054. static readonly FILTER_NONE: number;
  30055. /**
  30056. * Shadow generator mode ESM: Exponential Shadow Mapping.
  30057. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  30058. */
  30059. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  30060. /**
  30061. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  30062. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  30063. */
  30064. static readonly FILTER_POISSONSAMPLING: number;
  30065. /**
  30066. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  30067. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  30068. */
  30069. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  30070. /**
  30071. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  30072. * edge artifacts on steep falloff.
  30073. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  30074. */
  30075. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  30076. /**
  30077. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  30078. * edge artifacts on steep falloff.
  30079. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  30080. */
  30081. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  30082. /**
  30083. * Shadow generator mode PCF: Percentage Closer Filtering
  30084. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  30085. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  30086. */
  30087. static readonly FILTER_PCF: number;
  30088. /**
  30089. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  30090. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  30091. * Contact Hardening
  30092. */
  30093. static readonly FILTER_PCSS: number;
  30094. /**
  30095. * Reserved for PCF and PCSS
  30096. * Highest Quality.
  30097. *
  30098. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  30099. *
  30100. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  30101. */
  30102. static readonly QUALITY_HIGH: number;
  30103. /**
  30104. * Reserved for PCF and PCSS
  30105. * Good tradeoff for quality/perf cross devices
  30106. *
  30107. * Execute PCF on a 3*3 kernel.
  30108. *
  30109. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  30110. */
  30111. static readonly QUALITY_MEDIUM: number;
  30112. /**
  30113. * Reserved for PCF and PCSS
  30114. * The lowest quality but the fastest.
  30115. *
  30116. * Execute PCF on a 1*1 kernel.
  30117. *
  30118. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  30119. */
  30120. static readonly QUALITY_LOW: number;
  30121. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  30122. id: string;
  30123. /** Gets or sets the custom shader name to use */
  30124. customShaderOptions: ICustomShaderOptions;
  30125. /** Gets or sets a custom function to allow/disallow rendering a sub mesh in the shadow map */
  30126. customAllowRendering: (subMesh: SubMesh) => boolean;
  30127. /**
  30128. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  30129. */
  30130. onBeforeShadowMapRenderObservable: Observable<Effect>;
  30131. /**
  30132. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  30133. */
  30134. onAfterShadowMapRenderObservable: Observable<Effect>;
  30135. /**
  30136. * Observable triggered before a mesh is rendered in the shadow map.
  30137. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  30138. */
  30139. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  30140. /**
  30141. * Observable triggered after a mesh is rendered in the shadow map.
  30142. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  30143. */
  30144. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  30145. protected _bias: number;
  30146. /**
  30147. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  30148. */
  30149. get bias(): number;
  30150. /**
  30151. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  30152. */
  30153. set bias(bias: number);
  30154. protected _normalBias: number;
  30155. /**
  30156. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportional to the light/normal angle).
  30157. */
  30158. get normalBias(): number;
  30159. /**
  30160. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportional to the light/normal angle).
  30161. */
  30162. set normalBias(normalBias: number);
  30163. protected _blurBoxOffset: number;
  30164. /**
  30165. * Gets the blur box offset: offset applied during the blur pass.
  30166. * Only useful if useKernelBlur = false
  30167. */
  30168. get blurBoxOffset(): number;
  30169. /**
  30170. * Sets the blur box offset: offset applied during the blur pass.
  30171. * Only useful if useKernelBlur = false
  30172. */
  30173. set blurBoxOffset(value: number);
  30174. protected _blurScale: number;
  30175. /**
  30176. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  30177. * 2 means half of the size.
  30178. */
  30179. get blurScale(): number;
  30180. /**
  30181. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  30182. * 2 means half of the size.
  30183. */
  30184. set blurScale(value: number);
  30185. protected _blurKernel: number;
  30186. /**
  30187. * Gets the blur kernel: kernel size of the blur pass.
  30188. * Only useful if useKernelBlur = true
  30189. */
  30190. get blurKernel(): number;
  30191. /**
  30192. * Sets the blur kernel: kernel size of the blur pass.
  30193. * Only useful if useKernelBlur = true
  30194. */
  30195. set blurKernel(value: number);
  30196. protected _useKernelBlur: boolean;
  30197. /**
  30198. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  30199. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  30200. */
  30201. get useKernelBlur(): boolean;
  30202. /**
  30203. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  30204. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  30205. */
  30206. set useKernelBlur(value: boolean);
  30207. protected _depthScale: number;
  30208. /**
  30209. * Gets the depth scale used in ESM mode.
  30210. */
  30211. get depthScale(): number;
  30212. /**
  30213. * Sets the depth scale used in ESM mode.
  30214. * This can override the scale stored on the light.
  30215. */
  30216. set depthScale(value: number);
  30217. protected _validateFilter(filter: number): number;
  30218. protected _filter: number;
  30219. /**
  30220. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  30221. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  30222. */
  30223. get filter(): number;
  30224. /**
  30225. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  30226. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  30227. */
  30228. set filter(value: number);
  30229. /**
  30230. * Gets if the current filter is set to Poisson Sampling.
  30231. */
  30232. get usePoissonSampling(): boolean;
  30233. /**
  30234. * Sets the current filter to Poisson Sampling.
  30235. */
  30236. set usePoissonSampling(value: boolean);
  30237. /**
  30238. * Gets if the current filter is set to ESM.
  30239. */
  30240. get useExponentialShadowMap(): boolean;
  30241. /**
  30242. * Sets the current filter is to ESM.
  30243. */
  30244. set useExponentialShadowMap(value: boolean);
  30245. /**
  30246. * Gets if the current filter is set to filtered ESM.
  30247. */
  30248. get useBlurExponentialShadowMap(): boolean;
  30249. /**
  30250. * Gets if the current filter is set to filtered ESM.
  30251. */
  30252. set useBlurExponentialShadowMap(value: boolean);
  30253. /**
  30254. * Gets if the current filter is set to "close ESM" (using the inverse of the
  30255. * exponential to prevent steep falloff artifacts).
  30256. */
  30257. get useCloseExponentialShadowMap(): boolean;
  30258. /**
  30259. * Sets the current filter to "close ESM" (using the inverse of the
  30260. * exponential to prevent steep falloff artifacts).
  30261. */
  30262. set useCloseExponentialShadowMap(value: boolean);
  30263. /**
  30264. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  30265. * exponential to prevent steep falloff artifacts).
  30266. */
  30267. get useBlurCloseExponentialShadowMap(): boolean;
  30268. /**
  30269. * Sets the current filter to filtered "close ESM" (using the inverse of the
  30270. * exponential to prevent steep falloff artifacts).
  30271. */
  30272. set useBlurCloseExponentialShadowMap(value: boolean);
  30273. /**
  30274. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  30275. */
  30276. get usePercentageCloserFiltering(): boolean;
  30277. /**
  30278. * Sets the current filter to "PCF" (percentage closer filtering).
  30279. */
  30280. set usePercentageCloserFiltering(value: boolean);
  30281. protected _filteringQuality: number;
  30282. /**
  30283. * Gets the PCF or PCSS Quality.
  30284. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  30285. */
  30286. get filteringQuality(): number;
  30287. /**
  30288. * Sets the PCF or PCSS Quality.
  30289. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  30290. */
  30291. set filteringQuality(filteringQuality: number);
  30292. /**
  30293. * Gets if the current filter is set to "PCSS" (contact hardening).
  30294. */
  30295. get useContactHardeningShadow(): boolean;
  30296. /**
  30297. * Sets the current filter to "PCSS" (contact hardening).
  30298. */
  30299. set useContactHardeningShadow(value: boolean);
  30300. protected _contactHardeningLightSizeUVRatio: number;
  30301. /**
  30302. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  30303. * Using a ratio helps keeping shape stability independently of the map size.
  30304. *
  30305. * It does not account for the light projection as it was having too much
  30306. * instability during the light setup or during light position changes.
  30307. *
  30308. * Only valid if useContactHardeningShadow is true.
  30309. */
  30310. get contactHardeningLightSizeUVRatio(): number;
  30311. /**
  30312. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  30313. * Using a ratio helps keeping shape stability independently of the map size.
  30314. *
  30315. * It does not account for the light projection as it was having too much
  30316. * instability during the light setup or during light position changes.
  30317. *
  30318. * Only valid if useContactHardeningShadow is true.
  30319. */
  30320. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  30321. protected _darkness: number;
  30322. /** Gets or sets the actual darkness of a shadow */
  30323. get darkness(): number;
  30324. set darkness(value: number);
  30325. /**
  30326. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  30327. * 0 means strongest and 1 would means no shadow.
  30328. * @returns the darkness.
  30329. */
  30330. getDarkness(): number;
  30331. /**
  30332. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  30333. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  30334. * @returns the shadow generator allowing fluent coding.
  30335. */
  30336. setDarkness(darkness: number): ShadowGenerator;
  30337. protected _transparencyShadow: boolean;
  30338. /** Gets or sets the ability to have transparent shadow */
  30339. get transparencyShadow(): boolean;
  30340. set transparencyShadow(value: boolean);
  30341. /**
  30342. * Sets the ability to have transparent shadow (boolean).
  30343. * @param transparent True if transparent else False
  30344. * @returns the shadow generator allowing fluent coding
  30345. */
  30346. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  30347. /**
  30348. * Enables or disables shadows with varying strength based on the transparency
  30349. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  30350. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  30351. * mesh.visibility * alphaTexture.a
  30352. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  30353. */
  30354. enableSoftTransparentShadow: boolean;
  30355. protected _shadowMap: Nullable<RenderTargetTexture>;
  30356. protected _shadowMap2: Nullable<RenderTargetTexture>;
  30357. /**
  30358. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  30359. * @returns The render target texture if present otherwise, null
  30360. */
  30361. getShadowMap(): Nullable<RenderTargetTexture>;
  30362. /**
  30363. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  30364. * @returns The render target texture if the shadow map is present otherwise, null
  30365. */
  30366. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  30367. /**
  30368. * Gets the class name of that object
  30369. * @returns "ShadowGenerator"
  30370. */
  30371. getClassName(): string;
  30372. /**
  30373. * Helper function to add a mesh and its descendants to the list of shadow casters.
  30374. * @param mesh Mesh to add
  30375. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  30376. * @returns the Shadow Generator itself
  30377. */
  30378. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  30379. /**
  30380. * Helper function to remove a mesh and its descendants from the list of shadow casters
  30381. * @param mesh Mesh to remove
  30382. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  30383. * @returns the Shadow Generator itself
  30384. */
  30385. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  30386. /**
  30387. * Controls the extent to which the shadows fade out at the edge of the frustum
  30388. */
  30389. frustumEdgeFalloff: number;
  30390. protected _light: IShadowLight;
  30391. /**
  30392. * Returns the associated light object.
  30393. * @returns the light generating the shadow
  30394. */
  30395. getLight(): IShadowLight;
  30396. /**
  30397. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  30398. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  30399. * It might on the other hand introduce peter panning.
  30400. */
  30401. forceBackFacesOnly: boolean;
  30402. protected _scene: Scene;
  30403. protected _lightDirection: Vector3;
  30404. protected _viewMatrix: Matrix;
  30405. protected _projectionMatrix: Matrix;
  30406. protected _transformMatrix: Matrix;
  30407. protected _cachedPosition: Vector3;
  30408. protected _cachedDirection: Vector3;
  30409. protected _cachedDefines: string;
  30410. protected _currentRenderID: number;
  30411. protected _boxBlurPostprocess: Nullable<PostProcess>;
  30412. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  30413. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  30414. protected _blurPostProcesses: PostProcess[];
  30415. protected _mapSize: number;
  30416. protected _currentFaceIndex: number;
  30417. protected _currentFaceIndexCache: number;
  30418. protected _textureType: number;
  30419. protected _defaultTextureMatrix: Matrix;
  30420. protected _storedUniqueId: Nullable<number>;
  30421. protected _nameForCustomEffect: string;
  30422. /** @hidden */
  30423. static _SceneComponentInitialization: (scene: Scene) => void;
  30424. /**
  30425. * Gets or sets the size of the texture what stores the shadows
  30426. */
  30427. get mapSize(): number;
  30428. set mapSize(size: number);
  30429. /**
  30430. * Creates a ShadowGenerator object.
  30431. * A ShadowGenerator is the required tool to use the shadows.
  30432. * Each light casting shadows needs to use its own ShadowGenerator.
  30433. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  30434. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  30435. * @param light The light object generating the shadows.
  30436. * @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.
  30437. */
  30438. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  30439. protected _initializeGenerator(): void;
  30440. protected _createTargetRenderTexture(): void;
  30441. protected _initializeShadowMap(): void;
  30442. protected _initializeBlurRTTAndPostProcesses(): void;
  30443. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  30444. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  30445. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  30446. protected _applyFilterValues(): void;
  30447. /**
  30448. * Forces all the attached effect to compile to enable rendering only once ready vs. lazily compiling effects.
  30449. * @param onCompiled Callback triggered at the and of the effects compilation
  30450. * @param options Sets of optional options forcing the compilation with different modes
  30451. */
  30452. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  30453. useInstances: boolean;
  30454. }>): void;
  30455. /**
  30456. * Forces all the attached effect to compile to enable rendering only once ready vs. lazily compiling effects.
  30457. * @param options Sets of optional options forcing the compilation with different modes
  30458. * @returns A promise that resolves when the compilation completes
  30459. */
  30460. forceCompilationAsync(options?: Partial<{
  30461. useInstances: boolean;
  30462. }>): Promise<void>;
  30463. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  30464. private _prepareShadowDefines;
  30465. /**
  30466. * Determine whether the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  30467. * @param subMesh The submesh we want to render in the shadow map
  30468. * @param useInstances Defines whether will draw in the map using instances
  30469. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  30470. * @returns true if ready otherwise, false
  30471. */
  30472. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  30473. /**
  30474. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  30475. * @param defines Defines of the material we want to update
  30476. * @param lightIndex Index of the light in the enabled light list of the material
  30477. */
  30478. prepareDefines(defines: any, lightIndex: number): void;
  30479. /**
  30480. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  30481. * defined in the generator but impacting the effect).
  30482. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  30483. * @param effect The effect we are binding the information for
  30484. */
  30485. bindShadowLight(lightIndex: string, effect: Effect): void;
  30486. /**
  30487. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  30488. * (eq to shadow projection matrix * light transform matrix)
  30489. * @returns The transform matrix used to create the shadow map
  30490. */
  30491. getTransformMatrix(): Matrix;
  30492. /**
  30493. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  30494. * Cube and 2D textures for instance.
  30495. */
  30496. recreateShadowMap(): void;
  30497. protected _disposeBlurPostProcesses(): void;
  30498. protected _disposeRTTandPostProcesses(): void;
  30499. /**
  30500. * Disposes the ShadowGenerator.
  30501. * Returns nothing.
  30502. */
  30503. dispose(): void;
  30504. /**
  30505. * Serializes the shadow generator setup to a json object.
  30506. * @returns The serialized JSON object
  30507. */
  30508. serialize(): any;
  30509. /**
  30510. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  30511. * @param parsedShadowGenerator The JSON object to parse
  30512. * @param scene The scene to create the shadow map for
  30513. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  30514. * @returns The parsed shadow generator
  30515. */
  30516. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  30517. }
  30518. }
  30519. declare module BABYLON {
  30520. /**
  30521. * Options to be used when creating a shadow depth material
  30522. */
  30523. export interface IIOptionShadowDepthMaterial {
  30524. /** Variables in the vertex shader code that need to have their names remapped.
  30525. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  30526. * "var_name" should be either: worldPos or vNormalW
  30527. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  30528. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  30529. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  30530. */
  30531. remappedVariables?: string[];
  30532. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  30533. standalone?: boolean;
  30534. }
  30535. /**
  30536. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  30537. */
  30538. export class ShadowDepthWrapper {
  30539. private _scene;
  30540. private _options?;
  30541. private _baseMaterial;
  30542. private _onEffectCreatedObserver;
  30543. private _subMeshToEffect;
  30544. private _subMeshToDepthEffect;
  30545. private _meshes;
  30546. /** @hidden */
  30547. _matriceNames: any;
  30548. /** Gets the standalone status of the wrapper */
  30549. get standalone(): boolean;
  30550. /** Gets the base material the wrapper is built upon */
  30551. get baseMaterial(): Material;
  30552. /**
  30553. * Instantiate a new shadow depth wrapper.
  30554. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  30555. * generate the shadow depth map. For more information, please refer to the documentation:
  30556. * https://doc.babylonjs.com/babylon101/shadows
  30557. * @param baseMaterial Material to wrap
  30558. * @param scene Define the scene the material belongs to
  30559. * @param options Options used to create the wrapper
  30560. */
  30561. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  30562. /**
  30563. * Gets the effect to use to generate the depth map
  30564. * @param subMesh subMesh to get the effect for
  30565. * @param shadowGenerator shadow generator to get the effect for
  30566. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  30567. */
  30568. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  30569. /**
  30570. * Specifies that the submesh is ready to be used for depth rendering
  30571. * @param subMesh submesh to check
  30572. * @param defines the list of defines to take into account when checking the effect
  30573. * @param shadowGenerator combined with subMesh, it defines the effect to check
  30574. * @param useInstances specifies that instances should be used
  30575. * @returns a boolean indicating that the submesh is ready or not
  30576. */
  30577. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  30578. /**
  30579. * Disposes the resources
  30580. */
  30581. dispose(): void;
  30582. private _makeEffect;
  30583. }
  30584. }
  30585. declare module BABYLON {
  30586. /**
  30587. * Options for compiling materials.
  30588. */
  30589. export interface IMaterialCompilationOptions {
  30590. /**
  30591. * Defines whether clip planes are enabled.
  30592. */
  30593. clipPlane: boolean;
  30594. /**
  30595. * Defines whether instances are enabled.
  30596. */
  30597. useInstances: boolean;
  30598. }
  30599. /**
  30600. * Options passed when calling customShaderNameResolve
  30601. */
  30602. export interface ICustomShaderNameResolveOptions {
  30603. /**
  30604. * 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
  30605. */
  30606. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  30607. }
  30608. /**
  30609. * Base class for the main features of a material in Babylon.js
  30610. */
  30611. export class Material implements IAnimatable {
  30612. /**
  30613. * Returns the triangle fill mode
  30614. */
  30615. static readonly TriangleFillMode: number;
  30616. /**
  30617. * Returns the wireframe mode
  30618. */
  30619. static readonly WireFrameFillMode: number;
  30620. /**
  30621. * Returns the point fill mode
  30622. */
  30623. static readonly PointFillMode: number;
  30624. /**
  30625. * Returns the point list draw mode
  30626. */
  30627. static readonly PointListDrawMode: number;
  30628. /**
  30629. * Returns the line list draw mode
  30630. */
  30631. static readonly LineListDrawMode: number;
  30632. /**
  30633. * Returns the line loop draw mode
  30634. */
  30635. static readonly LineLoopDrawMode: number;
  30636. /**
  30637. * Returns the line strip draw mode
  30638. */
  30639. static readonly LineStripDrawMode: number;
  30640. /**
  30641. * Returns the triangle strip draw mode
  30642. */
  30643. static readonly TriangleStripDrawMode: number;
  30644. /**
  30645. * Returns the triangle fan draw mode
  30646. */
  30647. static readonly TriangleFanDrawMode: number;
  30648. /**
  30649. * Stores the clock-wise side orientation
  30650. */
  30651. static readonly ClockWiseSideOrientation: number;
  30652. /**
  30653. * Stores the counter clock-wise side orientation
  30654. */
  30655. static readonly CounterClockWiseSideOrientation: number;
  30656. /**
  30657. * The dirty texture flag value
  30658. */
  30659. static readonly TextureDirtyFlag: number;
  30660. /**
  30661. * The dirty light flag value
  30662. */
  30663. static readonly LightDirtyFlag: number;
  30664. /**
  30665. * The dirty fresnel flag value
  30666. */
  30667. static readonly FresnelDirtyFlag: number;
  30668. /**
  30669. * The dirty attribute flag value
  30670. */
  30671. static readonly AttributesDirtyFlag: number;
  30672. /**
  30673. * The dirty misc flag value
  30674. */
  30675. static readonly MiscDirtyFlag: number;
  30676. /**
  30677. * The dirty prepass flag value
  30678. */
  30679. static readonly PrePassDirtyFlag: number;
  30680. /**
  30681. * The all dirty flag value
  30682. */
  30683. static readonly AllDirtyFlag: number;
  30684. /**
  30685. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  30686. */
  30687. static readonly MATERIAL_OPAQUE: number;
  30688. /**
  30689. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  30690. */
  30691. static readonly MATERIAL_ALPHATEST: number;
  30692. /**
  30693. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  30694. */
  30695. static readonly MATERIAL_ALPHABLEND: number;
  30696. /**
  30697. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  30698. * They are also discarded below the alpha cutoff threshold to improve performances.
  30699. */
  30700. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  30701. /**
  30702. * The Whiteout method is used to blend normals.
  30703. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  30704. */
  30705. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  30706. /**
  30707. * The Reoriented Normal Mapping method is used to blend normals.
  30708. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  30709. */
  30710. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  30711. /**
  30712. * Custom callback helping to override the default shader used in the material.
  30713. */
  30714. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  30715. /**
  30716. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  30717. */
  30718. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  30719. /**
  30720. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  30721. * This means that the material can keep using a previous shader while a new one is being compiled.
  30722. * This is mostly used when shader parallel compilation is supported (true by default)
  30723. */
  30724. allowShaderHotSwapping: boolean;
  30725. /**
  30726. * The ID of the material
  30727. */
  30728. id: string;
  30729. /**
  30730. * Gets or sets the unique id of the material
  30731. */
  30732. uniqueId: number;
  30733. /**
  30734. * The name of the material
  30735. */
  30736. name: string;
  30737. /**
  30738. * Gets or sets user defined metadata
  30739. */
  30740. metadata: any;
  30741. /**
  30742. * For internal use only. Please do not use.
  30743. */
  30744. reservedDataStore: any;
  30745. /**
  30746. * Specifies if the ready state should be checked on each call
  30747. */
  30748. checkReadyOnEveryCall: boolean;
  30749. /**
  30750. * Specifies if the ready state should be checked once
  30751. */
  30752. checkReadyOnlyOnce: boolean;
  30753. /**
  30754. * The state of the material
  30755. */
  30756. state: string;
  30757. /**
  30758. * If the material can be rendered to several textures with MRT extension
  30759. */
  30760. get canRenderToMRT(): boolean;
  30761. /**
  30762. * The alpha value of the material
  30763. */
  30764. protected _alpha: number;
  30765. /**
  30766. * List of inspectable custom properties (used by the Inspector)
  30767. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  30768. */
  30769. inspectableCustomProperties: IInspectable[];
  30770. /**
  30771. * Sets the alpha value of the material
  30772. */
  30773. set alpha(value: number);
  30774. /**
  30775. * Gets the alpha value of the material
  30776. */
  30777. get alpha(): number;
  30778. /**
  30779. * Specifies if back face culling is enabled
  30780. */
  30781. protected _backFaceCulling: boolean;
  30782. /**
  30783. * Sets the back-face culling state
  30784. */
  30785. set backFaceCulling(value: boolean);
  30786. /**
  30787. * Gets the back-face culling state
  30788. */
  30789. get backFaceCulling(): boolean;
  30790. /**
  30791. * Stores the value for side orientation
  30792. */
  30793. sideOrientation: number;
  30794. /**
  30795. * Callback triggered when the material is compiled
  30796. */
  30797. onCompiled: Nullable<(effect: Effect) => void>;
  30798. /**
  30799. * Callback triggered when an error occurs
  30800. */
  30801. onError: Nullable<(effect: Effect, errors: string) => void>;
  30802. /**
  30803. * Callback triggered to get the render target textures
  30804. */
  30805. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  30806. /**
  30807. * Gets a boolean indicating that current material needs to register RTT
  30808. */
  30809. get hasRenderTargetTextures(): boolean;
  30810. /**
  30811. * Specifies if the material should be serialized
  30812. */
  30813. doNotSerialize: boolean;
  30814. /**
  30815. * @hidden
  30816. */
  30817. _storeEffectOnSubMeshes: boolean;
  30818. /**
  30819. * Stores the animations for the material
  30820. */
  30821. animations: Nullable<Array<Animation>>;
  30822. /**
  30823. * An event triggered when the material is disposed
  30824. */
  30825. onDisposeObservable: Observable<Material>;
  30826. /**
  30827. * An observer which watches for dispose events
  30828. */
  30829. private _onDisposeObserver;
  30830. private _onUnBindObservable;
  30831. /**
  30832. * Called during a dispose event
  30833. */
  30834. set onDispose(callback: () => void);
  30835. private _onBindObservable;
  30836. /**
  30837. * An event triggered when the material is bound
  30838. */
  30839. get onBindObservable(): Observable<AbstractMesh>;
  30840. /**
  30841. * An observer which watches for bind events
  30842. */
  30843. private _onBindObserver;
  30844. /**
  30845. * Called during a bind event
  30846. */
  30847. set onBind(callback: (Mesh: AbstractMesh) => void);
  30848. /**
  30849. * An event triggered when the material is unbound
  30850. */
  30851. get onUnBindObservable(): Observable<Material>;
  30852. protected _onEffectCreatedObservable: Nullable<Observable<{
  30853. effect: Effect;
  30854. subMesh: Nullable<SubMesh>;
  30855. }>>;
  30856. /**
  30857. * An event triggered when the effect is (re)created
  30858. */
  30859. get onEffectCreatedObservable(): Observable<{
  30860. effect: Effect;
  30861. subMesh: Nullable<SubMesh>;
  30862. }>;
  30863. /**
  30864. * Stores the value of the alpha mode
  30865. */
  30866. private _alphaMode;
  30867. /**
  30868. * Sets the value of the alpha mode.
  30869. *
  30870. * | Value | Type | Description |
  30871. * | --- | --- | --- |
  30872. * | 0 | ALPHA_DISABLE | |
  30873. * | 1 | ALPHA_ADD | |
  30874. * | 2 | ALPHA_COMBINE | |
  30875. * | 3 | ALPHA_SUBTRACT | |
  30876. * | 4 | ALPHA_MULTIPLY | |
  30877. * | 5 | ALPHA_MAXIMIZED | |
  30878. * | 6 | ALPHA_ONEONE | |
  30879. * | 7 | ALPHA_PREMULTIPLIED | |
  30880. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  30881. * | 9 | ALPHA_INTERPOLATE | |
  30882. * | 10 | ALPHA_SCREENMODE | |
  30883. *
  30884. */
  30885. set alphaMode(value: number);
  30886. /**
  30887. * Gets the value of the alpha mode
  30888. */
  30889. get alphaMode(): number;
  30890. /**
  30891. * Stores the state of the need depth pre-pass value
  30892. */
  30893. private _needDepthPrePass;
  30894. /**
  30895. * Sets the need depth pre-pass value
  30896. */
  30897. set needDepthPrePass(value: boolean);
  30898. /**
  30899. * Gets the depth pre-pass value
  30900. */
  30901. get needDepthPrePass(): boolean;
  30902. /**
  30903. * Can this material render to prepass
  30904. */
  30905. get isPrePassCapable(): boolean;
  30906. /**
  30907. * Specifies if depth writing should be disabled
  30908. */
  30909. disableDepthWrite: boolean;
  30910. /**
  30911. * Specifies if color writing should be disabled
  30912. */
  30913. disableColorWrite: boolean;
  30914. /**
  30915. * Specifies if depth writing should be forced
  30916. */
  30917. forceDepthWrite: boolean;
  30918. /**
  30919. * Specifies the depth function that should be used. 0 means the default engine function
  30920. */
  30921. depthFunction: number;
  30922. /**
  30923. * Specifies if there should be a separate pass for culling
  30924. */
  30925. separateCullingPass: boolean;
  30926. /**
  30927. * Stores the state specifying if fog should be enabled
  30928. */
  30929. private _fogEnabled;
  30930. /**
  30931. * Sets the state for enabling fog
  30932. */
  30933. set fogEnabled(value: boolean);
  30934. /**
  30935. * Gets the value of the fog enabled state
  30936. */
  30937. get fogEnabled(): boolean;
  30938. /**
  30939. * Stores the size of points
  30940. */
  30941. pointSize: number;
  30942. /**
  30943. * Stores the z offset value
  30944. */
  30945. zOffset: number;
  30946. get wireframe(): boolean;
  30947. /**
  30948. * Sets the state of wireframe mode
  30949. */
  30950. set wireframe(value: boolean);
  30951. /**
  30952. * Gets the value specifying if point clouds are enabled
  30953. */
  30954. get pointsCloud(): boolean;
  30955. /**
  30956. * Sets the state of point cloud mode
  30957. */
  30958. set pointsCloud(value: boolean);
  30959. /**
  30960. * Gets the material fill mode
  30961. */
  30962. get fillMode(): number;
  30963. /**
  30964. * Sets the material fill mode
  30965. */
  30966. set fillMode(value: number);
  30967. /**
  30968. * @hidden
  30969. * Stores the effects for the material
  30970. */
  30971. _effect: Nullable<Effect>;
  30972. /**
  30973. * Specifies if uniform buffers should be used
  30974. */
  30975. private _useUBO;
  30976. /**
  30977. * Stores a reference to the scene
  30978. */
  30979. private _scene;
  30980. private _needToBindSceneUbo;
  30981. /**
  30982. * Stores the fill mode state
  30983. */
  30984. private _fillMode;
  30985. /**
  30986. * Specifies if the depth write state should be cached
  30987. */
  30988. private _cachedDepthWriteState;
  30989. /**
  30990. * Specifies if the color write state should be cached
  30991. */
  30992. private _cachedColorWriteState;
  30993. /**
  30994. * Specifies if the depth function state should be cached
  30995. */
  30996. private _cachedDepthFunctionState;
  30997. /**
  30998. * Stores the uniform buffer
  30999. */
  31000. protected _uniformBuffer: UniformBuffer;
  31001. /** @hidden */
  31002. _indexInSceneMaterialArray: number;
  31003. /** @hidden */
  31004. meshMap: Nullable<{
  31005. [id: string]: AbstractMesh | undefined;
  31006. }>;
  31007. /**
  31008. * Creates a material instance
  31009. * @param name defines the name of the material
  31010. * @param scene defines the scene to reference
  31011. * @param doNotAdd specifies if the material should be added to the scene
  31012. */
  31013. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  31014. /**
  31015. * Returns a string representation of the current material
  31016. * @param fullDetails defines a boolean indicating which levels of logging is desired
  31017. * @returns a string with material information
  31018. */
  31019. toString(fullDetails?: boolean): string;
  31020. /**
  31021. * Gets the class name of the material
  31022. * @returns a string with the class name of the material
  31023. */
  31024. getClassName(): string;
  31025. /**
  31026. * Specifies if updates for the material been locked
  31027. */
  31028. get isFrozen(): boolean;
  31029. /**
  31030. * Locks updates for the material
  31031. */
  31032. freeze(): void;
  31033. /**
  31034. * Unlocks updates for the material
  31035. */
  31036. unfreeze(): void;
  31037. /**
  31038. * Specifies if the material is ready to be used
  31039. * @param mesh defines the mesh to check
  31040. * @param useInstances specifies if instances should be used
  31041. * @returns a boolean indicating if the material is ready to be used
  31042. */
  31043. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  31044. /**
  31045. * Specifies that the submesh is ready to be used
  31046. * @param mesh defines the mesh to check
  31047. * @param subMesh defines which submesh to check
  31048. * @param useInstances specifies that instances should be used
  31049. * @returns a boolean indicating that the submesh is ready or not
  31050. */
  31051. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  31052. /**
  31053. * Returns the material effect
  31054. * @returns the effect associated with the material
  31055. */
  31056. getEffect(): Nullable<Effect>;
  31057. /**
  31058. * Returns the current scene
  31059. * @returns a Scene
  31060. */
  31061. getScene(): Scene;
  31062. /**
  31063. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  31064. */
  31065. protected _forceAlphaTest: boolean;
  31066. /**
  31067. * The transparency mode of the material.
  31068. */
  31069. protected _transparencyMode: Nullable<number>;
  31070. /**
  31071. * Gets the current transparency mode.
  31072. */
  31073. get transparencyMode(): Nullable<number>;
  31074. /**
  31075. * Sets the transparency mode of the material.
  31076. *
  31077. * | Value | Type | Description |
  31078. * | ----- | ----------------------------------- | ----------- |
  31079. * | 0 | OPAQUE | |
  31080. * | 1 | ALPHATEST | |
  31081. * | 2 | ALPHABLEND | |
  31082. * | 3 | ALPHATESTANDBLEND | |
  31083. *
  31084. */
  31085. set transparencyMode(value: Nullable<number>);
  31086. /**
  31087. * Returns true if alpha blending should be disabled.
  31088. */
  31089. protected get _disableAlphaBlending(): boolean;
  31090. /**
  31091. * Specifies whether or not this material should be rendered in alpha blend mode.
  31092. * @returns a boolean specifying if alpha blending is needed
  31093. */
  31094. needAlphaBlending(): boolean;
  31095. /**
  31096. * Specifies if the mesh will require alpha blending
  31097. * @param mesh defines the mesh to check
  31098. * @returns a boolean specifying if alpha blending is needed for the mesh
  31099. */
  31100. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  31101. /**
  31102. * Specifies whether or not this material should be rendered in alpha test mode.
  31103. * @returns a boolean specifying if an alpha test is needed.
  31104. */
  31105. needAlphaTesting(): boolean;
  31106. /**
  31107. * Specifies if material alpha testing should be turned on for the mesh
  31108. * @param mesh defines the mesh to check
  31109. */
  31110. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  31111. /**
  31112. * Gets the texture used for the alpha test
  31113. * @returns the texture to use for alpha testing
  31114. */
  31115. getAlphaTestTexture(): Nullable<BaseTexture>;
  31116. /**
  31117. * Marks the material to indicate that it needs to be re-calculated
  31118. */
  31119. markDirty(): void;
  31120. /** @hidden */
  31121. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  31122. /**
  31123. * Binds the material to the mesh
  31124. * @param world defines the world transformation matrix
  31125. * @param mesh defines the mesh to bind the material to
  31126. */
  31127. bind(world: Matrix, mesh?: Mesh): void;
  31128. /**
  31129. * Binds the submesh to the material
  31130. * @param world defines the world transformation matrix
  31131. * @param mesh defines the mesh containing the submesh
  31132. * @param subMesh defines the submesh to bind the material to
  31133. */
  31134. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  31135. /**
  31136. * Binds the world matrix to the material
  31137. * @param world defines the world transformation matrix
  31138. */
  31139. bindOnlyWorldMatrix(world: Matrix): void;
  31140. /**
  31141. * Binds the view matrix to the effect
  31142. * @param effect defines the effect to bind the view matrix to
  31143. */
  31144. bindView(effect: Effect): void;
  31145. /**
  31146. * Binds the view projection and projection matrices to the effect
  31147. * @param effect defines the effect to bind the view projection and projection matrices to
  31148. */
  31149. bindViewProjection(effect: Effect): void;
  31150. /**
  31151. * Binds the view matrix to the effect
  31152. * @param effect defines the effect to bind the view matrix to
  31153. * @param variableName name of the shader variable that will hold the eye position
  31154. */
  31155. bindEyePosition(effect: Effect, variableName?: string): void;
  31156. /**
  31157. * Processes to execute after binding the material to a mesh
  31158. * @param mesh defines the rendered mesh
  31159. */
  31160. protected _afterBind(mesh?: Mesh, effect?: Nullable<Effect>): void;
  31161. /**
  31162. * Unbinds the material from the mesh
  31163. */
  31164. unbind(): void;
  31165. /**
  31166. * Gets the active textures from the material
  31167. * @returns an array of textures
  31168. */
  31169. getActiveTextures(): BaseTexture[];
  31170. /**
  31171. * Specifies if the material uses a texture
  31172. * @param texture defines the texture to check against the material
  31173. * @returns a boolean specifying if the material uses the texture
  31174. */
  31175. hasTexture(texture: BaseTexture): boolean;
  31176. /**
  31177. * Makes a duplicate of the material, and gives it a new name
  31178. * @param name defines the new name for the duplicated material
  31179. * @returns the cloned material
  31180. */
  31181. clone(name: string): Nullable<Material>;
  31182. /**
  31183. * Gets the meshes bound to the material
  31184. * @returns an array of meshes bound to the material
  31185. */
  31186. getBindedMeshes(): AbstractMesh[];
  31187. /**
  31188. * Force shader compilation
  31189. * @param mesh defines the mesh associated with this material
  31190. * @param onCompiled defines a function to execute once the material is compiled
  31191. * @param options defines the options to configure the compilation
  31192. * @param onError defines a function to execute if the material fails compiling
  31193. */
  31194. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  31195. /**
  31196. * Force shader compilation
  31197. * @param mesh defines the mesh that will use this material
  31198. * @param options defines additional options for compiling the shaders
  31199. * @returns a promise that resolves when the compilation completes
  31200. */
  31201. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  31202. private static readonly _AllDirtyCallBack;
  31203. private static readonly _ImageProcessingDirtyCallBack;
  31204. private static readonly _TextureDirtyCallBack;
  31205. private static readonly _FresnelDirtyCallBack;
  31206. private static readonly _MiscDirtyCallBack;
  31207. private static readonly _PrePassDirtyCallBack;
  31208. private static readonly _LightsDirtyCallBack;
  31209. private static readonly _AttributeDirtyCallBack;
  31210. private static _FresnelAndMiscDirtyCallBack;
  31211. private static _TextureAndMiscDirtyCallBack;
  31212. private static readonly _DirtyCallbackArray;
  31213. private static readonly _RunDirtyCallBacks;
  31214. /**
  31215. * Marks a define in the material to indicate that it needs to be re-computed
  31216. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  31217. */
  31218. markAsDirty(flag: number): void;
  31219. /**
  31220. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  31221. * @param func defines a function which checks material defines against the submeshes
  31222. */
  31223. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  31224. /**
  31225. * Indicates that the scene should check if the rendering now needs a prepass
  31226. */
  31227. protected _markScenePrePassDirty(): void;
  31228. /**
  31229. * Indicates that we need to re-calculated for all submeshes
  31230. */
  31231. protected _markAllSubMeshesAsAllDirty(): void;
  31232. /**
  31233. * Indicates that image processing needs to be re-calculated for all submeshes
  31234. */
  31235. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  31236. /**
  31237. * Indicates that textures need to be re-calculated for all submeshes
  31238. */
  31239. protected _markAllSubMeshesAsTexturesDirty(): void;
  31240. /**
  31241. * Indicates that fresnel needs to be re-calculated for all submeshes
  31242. */
  31243. protected _markAllSubMeshesAsFresnelDirty(): void;
  31244. /**
  31245. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  31246. */
  31247. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  31248. /**
  31249. * Indicates that lights need to be re-calculated for all submeshes
  31250. */
  31251. protected _markAllSubMeshesAsLightsDirty(): void;
  31252. /**
  31253. * Indicates that attributes need to be re-calculated for all submeshes
  31254. */
  31255. protected _markAllSubMeshesAsAttributesDirty(): void;
  31256. /**
  31257. * Indicates that misc needs to be re-calculated for all submeshes
  31258. */
  31259. protected _markAllSubMeshesAsMiscDirty(): void;
  31260. /**
  31261. * Indicates that prepass needs to be re-calculated for all submeshes
  31262. */
  31263. protected _markAllSubMeshesAsPrePassDirty(): void;
  31264. /**
  31265. * Indicates that textures and misc need to be re-calculated for all submeshes
  31266. */
  31267. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  31268. /**
  31269. * Sets the required values to the prepass renderer.
  31270. * @param prePassRenderer defines the prepass renderer to setup.
  31271. * @returns true if the pre pass is needed.
  31272. */
  31273. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  31274. /**
  31275. * Disposes the material
  31276. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  31277. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  31278. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  31279. */
  31280. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  31281. /** @hidden */
  31282. private releaseVertexArrayObject;
  31283. /**
  31284. * Serializes this material
  31285. * @returns the serialized material object
  31286. */
  31287. serialize(): any;
  31288. /**
  31289. * Creates a material from parsed material data
  31290. * @param parsedMaterial defines parsed material data
  31291. * @param scene defines the hosting scene
  31292. * @param rootUrl defines the root URL to use to load textures
  31293. * @returns a new material
  31294. */
  31295. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  31296. }
  31297. }
  31298. declare module BABYLON {
  31299. /**
  31300. * A multi-material is used to apply different materials to different parts of the same object without the need of
  31301. * separate meshes. This can be use to improve performances.
  31302. * @see https://doc.babylonjs.com/how_to/multi_materials
  31303. */
  31304. export class MultiMaterial extends Material {
  31305. private _subMaterials;
  31306. /**
  31307. * Gets or Sets the list of Materials used within the multi material.
  31308. * They need to be ordered according to the submeshes order in the associated mesh
  31309. */
  31310. get subMaterials(): Nullable<Material>[];
  31311. set subMaterials(value: Nullable<Material>[]);
  31312. /**
  31313. * Function used to align with Node.getChildren()
  31314. * @returns the list of Materials used within the multi material
  31315. */
  31316. getChildren(): Nullable<Material>[];
  31317. /**
  31318. * Instantiates a new Multi Material
  31319. * A multi-material is used to apply different materials to different parts of the same object without the need of
  31320. * separate meshes. This can be use to improve performances.
  31321. * @see https://doc.babylonjs.com/how_to/multi_materials
  31322. * @param name Define the name in the scene
  31323. * @param scene Define the scene the material belongs to
  31324. */
  31325. constructor(name: string, scene: Scene);
  31326. private _hookArray;
  31327. /**
  31328. * Get one of the submaterial by its index in the submaterials array
  31329. * @param index The index to look the sub material at
  31330. * @returns The Material if the index has been defined
  31331. */
  31332. getSubMaterial(index: number): Nullable<Material>;
  31333. /**
  31334. * Get the list of active textures for the whole sub materials list.
  31335. * @returns All the textures that will be used during the rendering
  31336. */
  31337. getActiveTextures(): BaseTexture[];
  31338. /**
  31339. * Specifies if any sub-materials of this multi-material use a given texture.
  31340. * @param texture Defines the texture to check against this multi-material's sub-materials.
  31341. * @returns A boolean specifying if any sub-material of this multi-material uses the texture.
  31342. */
  31343. hasTexture(texture: BaseTexture): boolean;
  31344. /**
  31345. * Gets the current class name of the material e.g. "MultiMaterial"
  31346. * Mainly use in serialization.
  31347. * @returns the class name
  31348. */
  31349. getClassName(): string;
  31350. /**
  31351. * Checks if the material is ready to render the requested sub mesh
  31352. * @param mesh Define the mesh the submesh belongs to
  31353. * @param subMesh Define the sub mesh to look readiness for
  31354. * @param useInstances Define whether or not the material is used with instances
  31355. * @returns true if ready, otherwise false
  31356. */
  31357. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  31358. /**
  31359. * Clones the current material and its related sub materials
  31360. * @param name Define the name of the newly cloned material
  31361. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  31362. * @returns the cloned material
  31363. */
  31364. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  31365. /**
  31366. * Serializes the materials into a JSON representation.
  31367. * @returns the JSON representation
  31368. */
  31369. serialize(): any;
  31370. /**
  31371. * Dispose the material and release its associated resources
  31372. * @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)
  31373. * @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)
  31374. * @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)
  31375. */
  31376. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  31377. /**
  31378. * Creates a MultiMaterial from parsed MultiMaterial data.
  31379. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  31380. * @param scene defines the hosting scene
  31381. * @returns a new MultiMaterial
  31382. */
  31383. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  31384. }
  31385. }
  31386. declare module BABYLON {
  31387. /** @hidden */
  31388. export interface ICustomEffect {
  31389. effect: Effect;
  31390. defines: string;
  31391. }
  31392. /**
  31393. * Defines a subdivision inside a mesh
  31394. */
  31395. export class SubMesh implements ICullable {
  31396. /** the material index to use */
  31397. materialIndex: number;
  31398. /** vertex index start */
  31399. verticesStart: number;
  31400. /** vertices count */
  31401. verticesCount: number;
  31402. /** index start */
  31403. indexStart: number;
  31404. /** indices count */
  31405. indexCount: number;
  31406. /** @hidden */
  31407. _materialDefines: Nullable<MaterialDefines>;
  31408. /** @hidden */
  31409. _materialEffect: Nullable<Effect>;
  31410. /** @hidden */
  31411. _effectOverride: Nullable<Effect>;
  31412. private _customEffects;
  31413. /**
  31414. * Gets material defines used by the effect associated to the sub mesh
  31415. */
  31416. get materialDefines(): Nullable<MaterialDefines>;
  31417. /**
  31418. * Sets material defines used by the effect associated to the sub mesh
  31419. */
  31420. set materialDefines(defines: Nullable<MaterialDefines>);
  31421. /** @hidden */
  31422. _getCustomEffect(name: string, createIfNotExisting?: boolean): Nullable<ICustomEffect>;
  31423. /** @hidden */
  31424. _removeCustomEffect(name: string): void;
  31425. /**
  31426. * Gets associated effect
  31427. */
  31428. get effect(): Nullable<Effect>;
  31429. /**
  31430. * Sets associated effect (effect used to render this submesh)
  31431. * @param effect defines the effect to associate with
  31432. * @param defines defines the set of defines used to compile this effect
  31433. */
  31434. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  31435. /** @hidden */
  31436. _linesIndexCount: number;
  31437. private _mesh;
  31438. private _renderingMesh;
  31439. private _boundingInfo;
  31440. private _linesIndexBuffer;
  31441. /** @hidden */
  31442. _lastColliderWorldVertices: Nullable<Vector3[]>;
  31443. /** @hidden */
  31444. _trianglePlanes: Plane[];
  31445. /** @hidden */
  31446. _lastColliderTransformMatrix: Nullable<Matrix>;
  31447. /** @hidden */
  31448. _renderId: number;
  31449. /** @hidden */
  31450. _alphaIndex: number;
  31451. /** @hidden */
  31452. _distanceToCamera: number;
  31453. /** @hidden */
  31454. _id: number;
  31455. private _currentMaterial;
  31456. /**
  31457. * Add a new submesh to a mesh
  31458. * @param materialIndex defines the material index to use
  31459. * @param verticesStart defines vertex index start
  31460. * @param verticesCount defines vertices count
  31461. * @param indexStart defines index start
  31462. * @param indexCount defines indices count
  31463. * @param mesh defines the parent mesh
  31464. * @param renderingMesh defines an optional rendering mesh
  31465. * @param createBoundingBox defines if bounding box should be created for this submesh
  31466. * @returns the new submesh
  31467. */
  31468. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  31469. /**
  31470. * Creates a new submesh
  31471. * @param materialIndex defines the material index to use
  31472. * @param verticesStart defines vertex index start
  31473. * @param verticesCount defines vertices count
  31474. * @param indexStart defines index start
  31475. * @param indexCount defines indices count
  31476. * @param mesh defines the parent mesh
  31477. * @param renderingMesh defines an optional rendering mesh
  31478. * @param createBoundingBox defines if bounding box should be created for this submesh
  31479. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  31480. */
  31481. constructor(
  31482. /** the material index to use */
  31483. materialIndex: number,
  31484. /** vertex index start */
  31485. verticesStart: number,
  31486. /** vertices count */
  31487. verticesCount: number,
  31488. /** index start */
  31489. indexStart: number,
  31490. /** indices count */
  31491. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  31492. /**
  31493. * Returns true if this submesh covers the entire parent mesh
  31494. * @ignorenaming
  31495. */
  31496. get IsGlobal(): boolean;
  31497. /**
  31498. * Returns the submesh BoundingInfo object
  31499. * @returns current bounding info (or mesh's one if the submesh is global)
  31500. */
  31501. getBoundingInfo(): BoundingInfo;
  31502. /**
  31503. * Sets the submesh BoundingInfo
  31504. * @param boundingInfo defines the new bounding info to use
  31505. * @returns the SubMesh
  31506. */
  31507. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  31508. /**
  31509. * Returns the mesh of the current submesh
  31510. * @return the parent mesh
  31511. */
  31512. getMesh(): AbstractMesh;
  31513. /**
  31514. * Returns the rendering mesh of the submesh
  31515. * @returns the rendering mesh (could be different from parent mesh)
  31516. */
  31517. getRenderingMesh(): Mesh;
  31518. /**
  31519. * Returns the replacement mesh of the submesh
  31520. * @returns the replacement mesh (could be different from parent mesh)
  31521. */
  31522. getReplacementMesh(): Nullable<AbstractMesh>;
  31523. /**
  31524. * Returns the effective mesh of the submesh
  31525. * @returns the effective mesh (could be different from parent mesh)
  31526. */
  31527. getEffectiveMesh(): AbstractMesh;
  31528. /**
  31529. * Returns the submesh material
  31530. * @returns null or the current material
  31531. */
  31532. getMaterial(): Nullable<Material>;
  31533. private _IsMultiMaterial;
  31534. /**
  31535. * Sets a new updated BoundingInfo object to the submesh
  31536. * @param data defines an optional position array to use to determine the bounding info
  31537. * @returns the SubMesh
  31538. */
  31539. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  31540. /** @hidden */
  31541. _checkCollision(collider: Collider): boolean;
  31542. /**
  31543. * Updates the submesh BoundingInfo
  31544. * @param world defines the world matrix to use to update the bounding info
  31545. * @returns the submesh
  31546. */
  31547. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  31548. /**
  31549. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  31550. * @param frustumPlanes defines the frustum planes
  31551. * @returns true if the submesh is intersecting with the frustum
  31552. */
  31553. isInFrustum(frustumPlanes: Plane[]): boolean;
  31554. /**
  31555. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  31556. * @param frustumPlanes defines the frustum planes
  31557. * @returns true if the submesh is inside the frustum
  31558. */
  31559. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  31560. /**
  31561. * Renders the submesh
  31562. * @param enableAlphaMode defines if alpha needs to be used
  31563. * @returns the submesh
  31564. */
  31565. render(enableAlphaMode: boolean): SubMesh;
  31566. /**
  31567. * @hidden
  31568. */
  31569. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  31570. /**
  31571. * Checks if the submesh intersects with a ray
  31572. * @param ray defines the ray to test
  31573. * @returns true is the passed ray intersects the submesh bounding box
  31574. */
  31575. canIntersects(ray: Ray): boolean;
  31576. /**
  31577. * Intersects current submesh with a ray
  31578. * @param ray defines the ray to test
  31579. * @param positions defines mesh's positions array
  31580. * @param indices defines mesh's indices array
  31581. * @param fastCheck defines if the first intersection will be used (and not the closest)
  31582. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  31583. * @returns intersection info or null if no intersection
  31584. */
  31585. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  31586. /** @hidden */
  31587. private _intersectLines;
  31588. /** @hidden */
  31589. private _intersectUnIndexedLines;
  31590. /** @hidden */
  31591. private _intersectTriangles;
  31592. /** @hidden */
  31593. private _intersectUnIndexedTriangles;
  31594. /** @hidden */
  31595. _rebuild(): void;
  31596. /**
  31597. * Creates a new submesh from the passed mesh
  31598. * @param newMesh defines the new hosting mesh
  31599. * @param newRenderingMesh defines an optional rendering mesh
  31600. * @returns the new submesh
  31601. */
  31602. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  31603. /**
  31604. * Release associated resources
  31605. */
  31606. dispose(): void;
  31607. /**
  31608. * Gets the class name
  31609. * @returns the string "SubMesh".
  31610. */
  31611. getClassName(): string;
  31612. /**
  31613. * Creates a new submesh from indices data
  31614. * @param materialIndex the index of the main mesh material
  31615. * @param startIndex the index where to start the copy in the mesh indices array
  31616. * @param indexCount the number of indices to copy then from the startIndex
  31617. * @param mesh the main mesh to create the submesh from
  31618. * @param renderingMesh the optional rendering mesh
  31619. * @returns a new submesh
  31620. */
  31621. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  31622. }
  31623. }
  31624. declare module BABYLON {
  31625. /**
  31626. * Class used to represent data loading progression
  31627. */
  31628. export class SceneLoaderFlags {
  31629. private static _ForceFullSceneLoadingForIncremental;
  31630. private static _ShowLoadingScreen;
  31631. private static _CleanBoneMatrixWeights;
  31632. private static _loggingLevel;
  31633. /**
  31634. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  31635. */
  31636. static get ForceFullSceneLoadingForIncremental(): boolean;
  31637. static set ForceFullSceneLoadingForIncremental(value: boolean);
  31638. /**
  31639. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  31640. */
  31641. static get ShowLoadingScreen(): boolean;
  31642. static set ShowLoadingScreen(value: boolean);
  31643. /**
  31644. * Defines the current logging level (while loading the scene)
  31645. * @ignorenaming
  31646. */
  31647. static get loggingLevel(): number;
  31648. static set loggingLevel(value: number);
  31649. /**
  31650. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  31651. */
  31652. static get CleanBoneMatrixWeights(): boolean;
  31653. static set CleanBoneMatrixWeights(value: boolean);
  31654. }
  31655. }
  31656. declare module BABYLON {
  31657. /**
  31658. * Class used to store geometry data (vertex buffers + index buffer)
  31659. */
  31660. export class Geometry implements IGetSetVerticesData {
  31661. /**
  31662. * Gets or sets the ID of the geometry
  31663. */
  31664. id: string;
  31665. /**
  31666. * Gets or sets the unique ID of the geometry
  31667. */
  31668. uniqueId: number;
  31669. /**
  31670. * Gets the delay loading state of the geometry (none by default which means not delayed)
  31671. */
  31672. delayLoadState: number;
  31673. /**
  31674. * Gets the file containing the data to load when running in delay load state
  31675. */
  31676. delayLoadingFile: Nullable<string>;
  31677. /**
  31678. * Callback called when the geometry is updated
  31679. */
  31680. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  31681. private _scene;
  31682. private _engine;
  31683. private _meshes;
  31684. private _totalVertices;
  31685. /** @hidden */
  31686. _indices: IndicesArray;
  31687. /** @hidden */
  31688. _vertexBuffers: {
  31689. [key: string]: VertexBuffer;
  31690. };
  31691. private _isDisposed;
  31692. private _extend;
  31693. private _boundingBias;
  31694. /** @hidden */
  31695. _delayInfo: Array<string>;
  31696. private _indexBuffer;
  31697. private _indexBufferIsUpdatable;
  31698. /** @hidden */
  31699. _boundingInfo: Nullable<BoundingInfo>;
  31700. /** @hidden */
  31701. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  31702. /** @hidden */
  31703. _softwareSkinningFrameId: number;
  31704. private _vertexArrayObjects;
  31705. private _updatable;
  31706. /** @hidden */
  31707. _positions: Nullable<Vector3[]>;
  31708. private _positionsCache;
  31709. /**
  31710. * 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
  31711. */
  31712. get boundingBias(): Vector2;
  31713. /**
  31714. * 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
  31715. */
  31716. set boundingBias(value: Vector2);
  31717. /**
  31718. * Static function used to attach a new empty geometry to a mesh
  31719. * @param mesh defines the mesh to attach the geometry to
  31720. * @returns the new Geometry
  31721. */
  31722. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  31723. /** Get the list of meshes using this geometry */
  31724. get meshes(): Mesh[];
  31725. /**
  31726. * 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
  31727. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  31728. */
  31729. useBoundingInfoFromGeometry: boolean;
  31730. /**
  31731. * Creates a new geometry
  31732. * @param id defines the unique ID
  31733. * @param scene defines the hosting scene
  31734. * @param vertexData defines the VertexData used to get geometry data
  31735. * @param updatable defines if geometry must be updatable (false by default)
  31736. * @param mesh defines the mesh that will be associated with the geometry
  31737. */
  31738. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  31739. /**
  31740. * Gets the current extend of the geometry
  31741. */
  31742. get extend(): {
  31743. minimum: Vector3;
  31744. maximum: Vector3;
  31745. };
  31746. /**
  31747. * Gets the hosting scene
  31748. * @returns the hosting Scene
  31749. */
  31750. getScene(): Scene;
  31751. /**
  31752. * Gets the hosting engine
  31753. * @returns the hosting Engine
  31754. */
  31755. getEngine(): Engine;
  31756. /**
  31757. * Defines if the geometry is ready to use
  31758. * @returns true if the geometry is ready to be used
  31759. */
  31760. isReady(): boolean;
  31761. /**
  31762. * Gets a value indicating that the geometry should not be serialized
  31763. */
  31764. get doNotSerialize(): boolean;
  31765. /** @hidden */
  31766. _rebuild(): void;
  31767. /**
  31768. * Affects all geometry data in one call
  31769. * @param vertexData defines the geometry data
  31770. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  31771. */
  31772. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  31773. /**
  31774. * Set specific vertex data
  31775. * @param kind defines the data kind (Position, normal, etc...)
  31776. * @param data defines the vertex data to use
  31777. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  31778. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  31779. */
  31780. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  31781. /**
  31782. * Removes a specific vertex data
  31783. * @param kind defines the data kind (Position, normal, etc...)
  31784. */
  31785. removeVerticesData(kind: string): void;
  31786. /**
  31787. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  31788. * @param buffer defines the vertex buffer to use
  31789. * @param totalVertices defines the total number of vertices for position kind (could be null)
  31790. */
  31791. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  31792. /**
  31793. * Update a specific vertex buffer
  31794. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  31795. * It will do nothing if the buffer is not updatable
  31796. * @param kind defines the data kind (Position, normal, etc...)
  31797. * @param data defines the data to use
  31798. * @param offset defines the offset in the target buffer where to store the data
  31799. * @param useBytes set to true if the offset is in bytes
  31800. */
  31801. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  31802. /**
  31803. * Update a specific vertex buffer
  31804. * This function will create a new buffer if the current one is not updatable
  31805. * @param kind defines the data kind (Position, normal, etc...)
  31806. * @param data defines the data to use
  31807. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  31808. */
  31809. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  31810. private _updateBoundingInfo;
  31811. /** @hidden */
  31812. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>, overrideVertexBuffers?: {
  31813. [kind: string]: Nullable<VertexBuffer>;
  31814. }, overrideVertexArrayObjects?: {
  31815. [key: string]: WebGLVertexArrayObject;
  31816. }): void;
  31817. /**
  31818. * Gets total number of vertices
  31819. * @returns the total number of vertices
  31820. */
  31821. getTotalVertices(): number;
  31822. /**
  31823. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  31824. * @param kind defines the data kind (Position, normal, etc...)
  31825. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31826. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31827. * @returns a float array containing vertex data
  31828. */
  31829. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  31830. /**
  31831. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  31832. * @param kind defines the data kind (Position, normal, etc...)
  31833. * @returns true if the vertex buffer with the specified kind is updatable
  31834. */
  31835. isVertexBufferUpdatable(kind: string): boolean;
  31836. /**
  31837. * Gets a specific vertex buffer
  31838. * @param kind defines the data kind (Position, normal, etc...)
  31839. * @returns a VertexBuffer
  31840. */
  31841. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  31842. /**
  31843. * Returns all vertex buffers
  31844. * @return an object holding all vertex buffers indexed by kind
  31845. */
  31846. getVertexBuffers(): Nullable<{
  31847. [key: string]: VertexBuffer;
  31848. }>;
  31849. /**
  31850. * Gets a boolean indicating if specific vertex buffer is present
  31851. * @param kind defines the data kind (Position, normal, etc...)
  31852. * @returns true if data is present
  31853. */
  31854. isVerticesDataPresent(kind: string): boolean;
  31855. /**
  31856. * Gets a list of all attached data kinds (Position, normal, etc...)
  31857. * @returns a list of string containing all kinds
  31858. */
  31859. getVerticesDataKinds(): string[];
  31860. /**
  31861. * Update index buffer
  31862. * @param indices defines the indices to store in the index buffer
  31863. * @param offset defines the offset in the target buffer where to store the data
  31864. * @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)
  31865. */
  31866. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  31867. /**
  31868. * Creates a new index buffer
  31869. * @param indices defines the indices to store in the index buffer
  31870. * @param totalVertices defines the total number of vertices (could be null)
  31871. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  31872. */
  31873. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  31874. /**
  31875. * Return the total number of indices
  31876. * @returns the total number of indices
  31877. */
  31878. getTotalIndices(): number;
  31879. /**
  31880. * Gets the index buffer array
  31881. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31882. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31883. * @returns the index buffer array
  31884. */
  31885. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  31886. /**
  31887. * Gets the index buffer
  31888. * @return the index buffer
  31889. */
  31890. getIndexBuffer(): Nullable<DataBuffer>;
  31891. /** @hidden */
  31892. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  31893. /**
  31894. * Release the associated resources for a specific mesh
  31895. * @param mesh defines the source mesh
  31896. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  31897. */
  31898. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  31899. /**
  31900. * Apply current geometry to a given mesh
  31901. * @param mesh defines the mesh to apply geometry to
  31902. */
  31903. applyToMesh(mesh: Mesh): void;
  31904. private _updateExtend;
  31905. private _applyToMesh;
  31906. private notifyUpdate;
  31907. /**
  31908. * Load the geometry if it was flagged as delay loaded
  31909. * @param scene defines the hosting scene
  31910. * @param onLoaded defines a callback called when the geometry is loaded
  31911. */
  31912. load(scene: Scene, onLoaded?: () => void): void;
  31913. private _queueLoad;
  31914. /**
  31915. * Invert the geometry to move from a right handed system to a left handed one.
  31916. */
  31917. toLeftHanded(): void;
  31918. /** @hidden */
  31919. _resetPointsArrayCache(): void;
  31920. /** @hidden */
  31921. _generatePointsArray(): boolean;
  31922. /**
  31923. * Gets a value indicating if the geometry is disposed
  31924. * @returns true if the geometry was disposed
  31925. */
  31926. isDisposed(): boolean;
  31927. private _disposeVertexArrayObjects;
  31928. /**
  31929. * Free all associated resources
  31930. */
  31931. dispose(): void;
  31932. /**
  31933. * Clone the current geometry into a new geometry
  31934. * @param id defines the unique ID of the new geometry
  31935. * @returns a new geometry object
  31936. */
  31937. copy(id: string): Geometry;
  31938. /**
  31939. * Serialize the current geometry info (and not the vertices data) into a JSON object
  31940. * @return a JSON representation of the current geometry data (without the vertices data)
  31941. */
  31942. serialize(): any;
  31943. private toNumberArray;
  31944. /**
  31945. * Serialize all vertices data into a JSON object
  31946. * @returns a JSON representation of the current geometry data
  31947. */
  31948. serializeVerticeData(): any;
  31949. /**
  31950. * Extracts a clone of a mesh geometry
  31951. * @param mesh defines the source mesh
  31952. * @param id defines the unique ID of the new geometry object
  31953. * @returns the new geometry object
  31954. */
  31955. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  31956. /**
  31957. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  31958. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31959. * Be aware Math.random() could cause collisions, but:
  31960. * "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"
  31961. * @returns a string containing a new GUID
  31962. */
  31963. static RandomId(): string;
  31964. /** @hidden */
  31965. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  31966. private static _CleanMatricesWeights;
  31967. /**
  31968. * Create a new geometry from persisted data (Using .babylon file format)
  31969. * @param parsedVertexData defines the persisted data
  31970. * @param scene defines the hosting scene
  31971. * @param rootUrl defines the root url to use to load assets (like delayed data)
  31972. * @returns the new geometry object
  31973. */
  31974. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  31975. }
  31976. }
  31977. declare module BABYLON {
  31978. /**
  31979. * Defines a target to use with MorphTargetManager
  31980. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  31981. */
  31982. export class MorphTarget implements IAnimatable {
  31983. /** defines the name of the target */
  31984. name: string;
  31985. /**
  31986. * Gets or sets the list of animations
  31987. */
  31988. animations: Animation[];
  31989. private _scene;
  31990. private _positions;
  31991. private _normals;
  31992. private _tangents;
  31993. private _uvs;
  31994. private _influence;
  31995. private _uniqueId;
  31996. /**
  31997. * Observable raised when the influence changes
  31998. */
  31999. onInfluenceChanged: Observable<boolean>;
  32000. /** @hidden */
  32001. _onDataLayoutChanged: Observable<void>;
  32002. /**
  32003. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  32004. */
  32005. get influence(): number;
  32006. set influence(influence: number);
  32007. /**
  32008. * Gets or sets the id of the morph Target
  32009. */
  32010. id: string;
  32011. private _animationPropertiesOverride;
  32012. /**
  32013. * Gets or sets the animation properties override
  32014. */
  32015. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  32016. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  32017. /**
  32018. * Creates a new MorphTarget
  32019. * @param name defines the name of the target
  32020. * @param influence defines the influence to use
  32021. * @param scene defines the scene the morphtarget belongs to
  32022. */
  32023. constructor(
  32024. /** defines the name of the target */
  32025. name: string, influence?: number, scene?: Nullable<Scene>);
  32026. /**
  32027. * Gets the unique ID of this manager
  32028. */
  32029. get uniqueId(): number;
  32030. /**
  32031. * Gets a boolean defining if the target contains position data
  32032. */
  32033. get hasPositions(): boolean;
  32034. /**
  32035. * Gets a boolean defining if the target contains normal data
  32036. */
  32037. get hasNormals(): boolean;
  32038. /**
  32039. * Gets a boolean defining if the target contains tangent data
  32040. */
  32041. get hasTangents(): boolean;
  32042. /**
  32043. * Gets a boolean defining if the target contains texture coordinates data
  32044. */
  32045. get hasUVs(): boolean;
  32046. /**
  32047. * Affects position data to this target
  32048. * @param data defines the position data to use
  32049. */
  32050. setPositions(data: Nullable<FloatArray>): void;
  32051. /**
  32052. * Gets the position data stored in this target
  32053. * @returns a FloatArray containing the position data (or null if not present)
  32054. */
  32055. getPositions(): Nullable<FloatArray>;
  32056. /**
  32057. * Affects normal data to this target
  32058. * @param data defines the normal data to use
  32059. */
  32060. setNormals(data: Nullable<FloatArray>): void;
  32061. /**
  32062. * Gets the normal data stored in this target
  32063. * @returns a FloatArray containing the normal data (or null if not present)
  32064. */
  32065. getNormals(): Nullable<FloatArray>;
  32066. /**
  32067. * Affects tangent data to this target
  32068. * @param data defines the tangent data to use
  32069. */
  32070. setTangents(data: Nullable<FloatArray>): void;
  32071. /**
  32072. * Gets the tangent data stored in this target
  32073. * @returns a FloatArray containing the tangent data (or null if not present)
  32074. */
  32075. getTangents(): Nullable<FloatArray>;
  32076. /**
  32077. * Affects texture coordinates data to this target
  32078. * @param data defines the texture coordinates data to use
  32079. */
  32080. setUVs(data: Nullable<FloatArray>): void;
  32081. /**
  32082. * Gets the texture coordinates data stored in this target
  32083. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  32084. */
  32085. getUVs(): Nullable<FloatArray>;
  32086. /**
  32087. * Clone the current target
  32088. * @returns a new MorphTarget
  32089. */
  32090. clone(): MorphTarget;
  32091. /**
  32092. * Serializes the current target into a Serialization object
  32093. * @returns the serialized object
  32094. */
  32095. serialize(): any;
  32096. /**
  32097. * Returns the string "MorphTarget"
  32098. * @returns "MorphTarget"
  32099. */
  32100. getClassName(): string;
  32101. /**
  32102. * Creates a new target from serialized data
  32103. * @param serializationObject defines the serialized data to use
  32104. * @returns a new MorphTarget
  32105. */
  32106. static Parse(serializationObject: any): MorphTarget;
  32107. /**
  32108. * Creates a MorphTarget from mesh data
  32109. * @param mesh defines the source mesh
  32110. * @param name defines the name to use for the new target
  32111. * @param influence defines the influence to attach to the target
  32112. * @returns a new MorphTarget
  32113. */
  32114. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  32115. }
  32116. }
  32117. declare module BABYLON {
  32118. /**
  32119. * Class used to store 2D array textures containing user data
  32120. */
  32121. export class RawTexture2DArray extends Texture {
  32122. /** Gets or sets the texture format to use */
  32123. format: number;
  32124. private _depth;
  32125. /**
  32126. * Gets the number of layers of the texture
  32127. */
  32128. get depth(): number;
  32129. /**
  32130. * Create a new RawTexture2DArray
  32131. * @param data defines the data of the texture
  32132. * @param width defines the width of the texture
  32133. * @param height defines the height of the texture
  32134. * @param depth defines the number of layers of the texture
  32135. * @param format defines the texture format to use
  32136. * @param scene defines the hosting scene
  32137. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  32138. * @param invertY defines if texture must be stored with Y axis inverted
  32139. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  32140. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  32141. */
  32142. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  32143. /** Gets or sets the texture format to use */
  32144. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  32145. /**
  32146. * Update the texture with new data
  32147. * @param data defines the data to store in the texture
  32148. */
  32149. update(data: ArrayBufferView): void;
  32150. /**
  32151. * Creates a RGBA texture from some data.
  32152. * @param data Define the texture data
  32153. * @param width Define the width of the texture
  32154. * @param height Define the height of the texture
  32155. * @param depth defines the number of layers of the texture
  32156. * @param scene defines the scene the texture will belong to
  32157. * @param generateMipMaps Define whether or not to create mip maps for the texture
  32158. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  32159. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  32160. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  32161. * @returns the RGBA texture
  32162. */
  32163. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, depth: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture2DArray;
  32164. }
  32165. }
  32166. declare module BABYLON {
  32167. /**
  32168. * This class is used to deform meshes using morphing between different targets
  32169. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  32170. */
  32171. export class MorphTargetManager implements IDisposable {
  32172. private _targets;
  32173. private _targetInfluenceChangedObservers;
  32174. private _targetDataLayoutChangedObservers;
  32175. private _activeTargets;
  32176. private _scene;
  32177. private _influences;
  32178. private _supportsNormals;
  32179. private _supportsTangents;
  32180. private _supportsUVs;
  32181. private _vertexCount;
  32182. private _textureVertexStride;
  32183. private _textureWidth;
  32184. private _textureHeight;
  32185. private _uniqueId;
  32186. private _tempInfluences;
  32187. private _canUseTextureForTargets;
  32188. /** @hidden */
  32189. _targetStoreTexture: Nullable<RawTexture2DArray>;
  32190. /**
  32191. * Gets or sets a boolean indicating if normals must be morphed
  32192. */
  32193. enableNormalMorphing: boolean;
  32194. /**
  32195. * Gets or sets a boolean indicating if tangents must be morphed
  32196. */
  32197. enableTangentMorphing: boolean;
  32198. /**
  32199. * Gets or sets a boolean indicating if UV must be morphed
  32200. */
  32201. enableUVMorphing: boolean;
  32202. /**
  32203. * Creates a new MorphTargetManager
  32204. * @param scene defines the current scene
  32205. */
  32206. constructor(scene?: Nullable<Scene>);
  32207. /**
  32208. * Gets the unique ID of this manager
  32209. */
  32210. get uniqueId(): number;
  32211. /**
  32212. * Gets the number of vertices handled by this manager
  32213. */
  32214. get vertexCount(): number;
  32215. /**
  32216. * Gets a boolean indicating if this manager supports morphing of normals
  32217. */
  32218. get supportsNormals(): boolean;
  32219. /**
  32220. * Gets a boolean indicating if this manager supports morphing of tangents
  32221. */
  32222. get supportsTangents(): boolean;
  32223. /**
  32224. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  32225. */
  32226. get supportsUVs(): boolean;
  32227. /**
  32228. * Gets the number of targets stored in this manager
  32229. */
  32230. get numTargets(): number;
  32231. /**
  32232. * Gets the number of influencers (ie. the number of targets with influences > 0)
  32233. */
  32234. get numInfluencers(): number;
  32235. /**
  32236. * Gets the list of influences (one per target)
  32237. */
  32238. get influences(): Float32Array;
  32239. private _useTextureToStoreTargets;
  32240. /**
  32241. * Gets or sets a boolean indicating that targets should be stored as a texture instead of using vertex attributes (default is true).
  32242. * Please note that this option is not available if the hardware does not support it
  32243. */
  32244. get useTextureToStoreTargets(): boolean;
  32245. set useTextureToStoreTargets(value: boolean);
  32246. /**
  32247. * Gets a boolean indicating that the targets are stored into a texture (instead of as attributes)
  32248. */
  32249. get isUsingTextureForTargets(): boolean;
  32250. /**
  32251. * Gets the active target at specified index. An active target is a target with an influence > 0
  32252. * @param index defines the index to check
  32253. * @returns the requested target
  32254. */
  32255. getActiveTarget(index: number): MorphTarget;
  32256. /**
  32257. * Gets the target at specified index
  32258. * @param index defines the index to check
  32259. * @returns the requested target
  32260. */
  32261. getTarget(index: number): MorphTarget;
  32262. /**
  32263. * Add a new target to this manager
  32264. * @param target defines the target to add
  32265. */
  32266. addTarget(target: MorphTarget): void;
  32267. /**
  32268. * Removes a target from the manager
  32269. * @param target defines the target to remove
  32270. */
  32271. removeTarget(target: MorphTarget): void;
  32272. /** @hidden */
  32273. _bind(effect: Effect): void;
  32274. /**
  32275. * Clone the current manager
  32276. * @returns a new MorphTargetManager
  32277. */
  32278. clone(): MorphTargetManager;
  32279. /**
  32280. * Serializes the current manager into a Serialization object
  32281. * @returns the serialized object
  32282. */
  32283. serialize(): any;
  32284. private _syncActiveTargets;
  32285. /**
  32286. * Synchronize the targets with all the meshes using this morph target manager
  32287. */
  32288. synchronize(): void;
  32289. /**
  32290. * Release all resources
  32291. */
  32292. dispose(): void;
  32293. /**
  32294. * Creates a new MorphTargetManager from serialized data
  32295. * @param serializationObject defines the serialized data
  32296. * @param scene defines the hosting scene
  32297. * @returns the new MorphTargetManager
  32298. */
  32299. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  32300. }
  32301. }
  32302. declare module BABYLON {
  32303. /**
  32304. * Class used to represent a specific level of detail of a mesh
  32305. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32306. */
  32307. export class MeshLODLevel {
  32308. /** Defines the distance where this level should start being displayed */
  32309. distance: number;
  32310. /** Defines the mesh to use to render this level */
  32311. mesh: Nullable<Mesh>;
  32312. /**
  32313. * Creates a new LOD level
  32314. * @param distance defines the distance where this level should star being displayed
  32315. * @param mesh defines the mesh to use to render this level
  32316. */
  32317. constructor(
  32318. /** Defines the distance where this level should start being displayed */
  32319. distance: number,
  32320. /** Defines the mesh to use to render this level */
  32321. mesh: Nullable<Mesh>);
  32322. }
  32323. }
  32324. declare module BABYLON {
  32325. /**
  32326. * Helper class used to generate a canvas to manipulate images
  32327. */
  32328. export class CanvasGenerator {
  32329. /**
  32330. * Create a new canvas (or offscreen canvas depending on the context)
  32331. * @param width defines the expected width
  32332. * @param height defines the expected height
  32333. * @return a new canvas or offscreen canvas
  32334. */
  32335. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  32336. }
  32337. }
  32338. declare module BABYLON {
  32339. /**
  32340. * Mesh representing the ground
  32341. */
  32342. export class GroundMesh extends Mesh {
  32343. /** If octree should be generated */
  32344. generateOctree: boolean;
  32345. private _heightQuads;
  32346. /** @hidden */
  32347. _subdivisionsX: number;
  32348. /** @hidden */
  32349. _subdivisionsY: number;
  32350. /** @hidden */
  32351. _width: number;
  32352. /** @hidden */
  32353. _height: number;
  32354. /** @hidden */
  32355. _minX: number;
  32356. /** @hidden */
  32357. _maxX: number;
  32358. /** @hidden */
  32359. _minZ: number;
  32360. /** @hidden */
  32361. _maxZ: number;
  32362. constructor(name: string, scene: Scene);
  32363. /**
  32364. * "GroundMesh"
  32365. * @returns "GroundMesh"
  32366. */
  32367. getClassName(): string;
  32368. /**
  32369. * The minimum of x and y subdivisions
  32370. */
  32371. get subdivisions(): number;
  32372. /**
  32373. * X subdivisions
  32374. */
  32375. get subdivisionsX(): number;
  32376. /**
  32377. * Y subdivisions
  32378. */
  32379. get subdivisionsY(): number;
  32380. /**
  32381. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  32382. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  32383. * @param chunksCount the number of subdivisions for x and y
  32384. * @param octreeBlocksSize (Default: 32)
  32385. */
  32386. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  32387. /**
  32388. * Returns a height (y) value in the World system :
  32389. * the ground altitude at the coordinates (x, z) expressed in the World system.
  32390. * @param x x coordinate
  32391. * @param z z coordinate
  32392. * @returns the ground y position if (x, z) are outside the ground surface.
  32393. */
  32394. getHeightAtCoordinates(x: number, z: number): number;
  32395. /**
  32396. * Returns a normalized vector (Vector3) orthogonal to the ground
  32397. * at the ground coordinates (x, z) expressed in the World system.
  32398. * @param x x coordinate
  32399. * @param z z coordinate
  32400. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  32401. */
  32402. getNormalAtCoordinates(x: number, z: number): Vector3;
  32403. /**
  32404. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  32405. * at the ground coordinates (x, z) expressed in the World system.
  32406. * Doesn't update the reference Vector3 if (x, z) are outside the ground surface.
  32407. * @param x x coordinate
  32408. * @param z z coordinate
  32409. * @param ref vector to store the result
  32410. * @returns the GroundMesh.
  32411. */
  32412. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  32413. /**
  32414. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  32415. * if the ground has been updated.
  32416. * This can be used in the render loop.
  32417. * @returns the GroundMesh.
  32418. */
  32419. updateCoordinateHeights(): GroundMesh;
  32420. private _getFacetAt;
  32421. private _initHeightQuads;
  32422. private _computeHeightQuads;
  32423. /**
  32424. * Serializes this ground mesh
  32425. * @param serializationObject object to write serialization to
  32426. */
  32427. serialize(serializationObject: any): void;
  32428. /**
  32429. * Parses a serialized ground mesh
  32430. * @param parsedMesh the serialized mesh
  32431. * @param scene the scene to create the ground mesh in
  32432. * @returns the created ground mesh
  32433. */
  32434. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  32435. }
  32436. }
  32437. declare module BABYLON {
  32438. /**
  32439. * Interface for Physics-Joint data
  32440. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32441. */
  32442. export interface PhysicsJointData {
  32443. /**
  32444. * The main pivot of the joint
  32445. */
  32446. mainPivot?: Vector3;
  32447. /**
  32448. * The connected pivot of the joint
  32449. */
  32450. connectedPivot?: Vector3;
  32451. /**
  32452. * The main axis of the joint
  32453. */
  32454. mainAxis?: Vector3;
  32455. /**
  32456. * The connected axis of the joint
  32457. */
  32458. connectedAxis?: Vector3;
  32459. /**
  32460. * The collision of the joint
  32461. */
  32462. collision?: boolean;
  32463. /**
  32464. * Native Oimo/Cannon/Energy data
  32465. */
  32466. nativeParams?: any;
  32467. }
  32468. /**
  32469. * This is a holder class for the physics joint created by the physics plugin
  32470. * It holds a set of functions to control the underlying joint
  32471. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32472. */
  32473. export class PhysicsJoint {
  32474. /**
  32475. * The type of the physics joint
  32476. */
  32477. type: number;
  32478. /**
  32479. * The data for the physics joint
  32480. */
  32481. jointData: PhysicsJointData;
  32482. private _physicsJoint;
  32483. protected _physicsPlugin: IPhysicsEnginePlugin;
  32484. /**
  32485. * Initializes the physics joint
  32486. * @param type The type of the physics joint
  32487. * @param jointData The data for the physics joint
  32488. */
  32489. constructor(
  32490. /**
  32491. * The type of the physics joint
  32492. */
  32493. type: number,
  32494. /**
  32495. * The data for the physics joint
  32496. */
  32497. jointData: PhysicsJointData);
  32498. /**
  32499. * Gets the physics joint
  32500. */
  32501. get physicsJoint(): any;
  32502. /**
  32503. * Sets the physics joint
  32504. */
  32505. set physicsJoint(newJoint: any);
  32506. /**
  32507. * Sets the physics plugin
  32508. */
  32509. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  32510. /**
  32511. * Execute a function that is physics-plugin specific.
  32512. * @param {Function} func the function that will be executed.
  32513. * It accepts two parameters: the physics world and the physics joint
  32514. */
  32515. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  32516. /**
  32517. * Distance-Joint type
  32518. */
  32519. static DistanceJoint: number;
  32520. /**
  32521. * Hinge-Joint type
  32522. */
  32523. static HingeJoint: number;
  32524. /**
  32525. * Ball-and-Socket joint type
  32526. */
  32527. static BallAndSocketJoint: number;
  32528. /**
  32529. * Wheel-Joint type
  32530. */
  32531. static WheelJoint: number;
  32532. /**
  32533. * Slider-Joint type
  32534. */
  32535. static SliderJoint: number;
  32536. /**
  32537. * Prismatic-Joint type
  32538. */
  32539. static PrismaticJoint: number;
  32540. /**
  32541. * Universal-Joint type
  32542. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  32543. */
  32544. static UniversalJoint: number;
  32545. /**
  32546. * Hinge-Joint 2 type
  32547. */
  32548. static Hinge2Joint: number;
  32549. /**
  32550. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  32551. */
  32552. static PointToPointJoint: number;
  32553. /**
  32554. * Spring-Joint type
  32555. */
  32556. static SpringJoint: number;
  32557. /**
  32558. * Lock-Joint type
  32559. */
  32560. static LockJoint: number;
  32561. }
  32562. /**
  32563. * A class representing a physics distance joint
  32564. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32565. */
  32566. export class DistanceJoint extends PhysicsJoint {
  32567. /**
  32568. *
  32569. * @param jointData The data for the Distance-Joint
  32570. */
  32571. constructor(jointData: DistanceJointData);
  32572. /**
  32573. * Update the predefined distance.
  32574. * @param maxDistance The maximum preferred distance
  32575. * @param minDistance The minimum preferred distance
  32576. */
  32577. updateDistance(maxDistance: number, minDistance?: number): void;
  32578. }
  32579. /**
  32580. * Represents a Motor-Enabled Joint
  32581. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32582. */
  32583. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  32584. /**
  32585. * Initializes the Motor-Enabled Joint
  32586. * @param type The type of the joint
  32587. * @param jointData The physical joint data for the joint
  32588. */
  32589. constructor(type: number, jointData: PhysicsJointData);
  32590. /**
  32591. * Set the motor values.
  32592. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32593. * @param force the force to apply
  32594. * @param maxForce max force for this motor.
  32595. */
  32596. setMotor(force?: number, maxForce?: number): void;
  32597. /**
  32598. * Set the motor's limits.
  32599. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32600. * @param upperLimit The upper limit of the motor
  32601. * @param lowerLimit The lower limit of the motor
  32602. */
  32603. setLimit(upperLimit: number, lowerLimit?: number): void;
  32604. }
  32605. /**
  32606. * This class represents a single physics Hinge-Joint
  32607. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32608. */
  32609. export class HingeJoint extends MotorEnabledJoint {
  32610. /**
  32611. * Initializes the Hinge-Joint
  32612. * @param jointData The joint data for the Hinge-Joint
  32613. */
  32614. constructor(jointData: PhysicsJointData);
  32615. /**
  32616. * Set the motor values.
  32617. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32618. * @param {number} force the force to apply
  32619. * @param {number} maxForce max force for this motor.
  32620. */
  32621. setMotor(force?: number, maxForce?: number): void;
  32622. /**
  32623. * Set the motor's limits.
  32624. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32625. * @param upperLimit The upper limit of the motor
  32626. * @param lowerLimit The lower limit of the motor
  32627. */
  32628. setLimit(upperLimit: number, lowerLimit?: number): void;
  32629. }
  32630. /**
  32631. * This class represents a dual hinge physics joint (same as wheel joint)
  32632. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32633. */
  32634. export class Hinge2Joint extends MotorEnabledJoint {
  32635. /**
  32636. * Initializes the Hinge2-Joint
  32637. * @param jointData The joint data for the Hinge2-Joint
  32638. */
  32639. constructor(jointData: PhysicsJointData);
  32640. /**
  32641. * Set the motor values.
  32642. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32643. * @param {number} targetSpeed the speed the motor is to reach
  32644. * @param {number} maxForce max force for this motor.
  32645. * @param {motorIndex} the motor's index, 0 or 1.
  32646. */
  32647. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  32648. /**
  32649. * Set the motor limits.
  32650. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32651. * @param {number} upperLimit the upper limit
  32652. * @param {number} lowerLimit lower limit
  32653. * @param {motorIndex} the motor's index, 0 or 1.
  32654. */
  32655. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32656. }
  32657. /**
  32658. * Interface for a motor enabled joint
  32659. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32660. */
  32661. export interface IMotorEnabledJoint {
  32662. /**
  32663. * Physics joint
  32664. */
  32665. physicsJoint: any;
  32666. /**
  32667. * Sets the motor of the motor-enabled joint
  32668. * @param force The force of the motor
  32669. * @param maxForce The maximum force of the motor
  32670. * @param motorIndex The index of the motor
  32671. */
  32672. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  32673. /**
  32674. * Sets the limit of the motor
  32675. * @param upperLimit The upper limit of the motor
  32676. * @param lowerLimit The lower limit of the motor
  32677. * @param motorIndex The index of the motor
  32678. */
  32679. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32680. }
  32681. /**
  32682. * Joint data for a Distance-Joint
  32683. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32684. */
  32685. export interface DistanceJointData extends PhysicsJointData {
  32686. /**
  32687. * Max distance the 2 joint objects can be apart
  32688. */
  32689. maxDistance: number;
  32690. }
  32691. /**
  32692. * Joint data from a spring joint
  32693. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32694. */
  32695. export interface SpringJointData extends PhysicsJointData {
  32696. /**
  32697. * Length of the spring
  32698. */
  32699. length: number;
  32700. /**
  32701. * Stiffness of the spring
  32702. */
  32703. stiffness: number;
  32704. /**
  32705. * Damping of the spring
  32706. */
  32707. damping: number;
  32708. /** this callback will be called when applying the force to the impostors. */
  32709. forceApplicationCallback: () => void;
  32710. }
  32711. }
  32712. declare module BABYLON {
  32713. /**
  32714. * Holds the data for the raycast result
  32715. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32716. */
  32717. export class PhysicsRaycastResult {
  32718. private _hasHit;
  32719. private _hitDistance;
  32720. private _hitNormalWorld;
  32721. private _hitPointWorld;
  32722. private _rayFromWorld;
  32723. private _rayToWorld;
  32724. /**
  32725. * Gets if there was a hit
  32726. */
  32727. get hasHit(): boolean;
  32728. /**
  32729. * Gets the distance from the hit
  32730. */
  32731. get hitDistance(): number;
  32732. /**
  32733. * Gets the hit normal/direction in the world
  32734. */
  32735. get hitNormalWorld(): Vector3;
  32736. /**
  32737. * Gets the hit point in the world
  32738. */
  32739. get hitPointWorld(): Vector3;
  32740. /**
  32741. * Gets the ray "start point" of the ray in the world
  32742. */
  32743. get rayFromWorld(): Vector3;
  32744. /**
  32745. * Gets the ray "end point" of the ray in the world
  32746. */
  32747. get rayToWorld(): Vector3;
  32748. /**
  32749. * Sets the hit data (normal & point in world space)
  32750. * @param hitNormalWorld defines the normal in world space
  32751. * @param hitPointWorld defines the point in world space
  32752. */
  32753. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  32754. /**
  32755. * Sets the distance from the start point to the hit point
  32756. * @param distance
  32757. */
  32758. setHitDistance(distance: number): void;
  32759. /**
  32760. * Calculates the distance manually
  32761. */
  32762. calculateHitDistance(): void;
  32763. /**
  32764. * Resets all the values to default
  32765. * @param from The from point on world space
  32766. * @param to The to point on world space
  32767. */
  32768. reset(from?: Vector3, to?: Vector3): void;
  32769. }
  32770. /**
  32771. * Interface for the size containing width and height
  32772. */
  32773. interface IXYZ {
  32774. /**
  32775. * X
  32776. */
  32777. x: number;
  32778. /**
  32779. * Y
  32780. */
  32781. y: number;
  32782. /**
  32783. * Z
  32784. */
  32785. z: number;
  32786. }
  32787. }
  32788. declare module BABYLON {
  32789. /**
  32790. * Interface used to describe a physics joint
  32791. */
  32792. export interface PhysicsImpostorJoint {
  32793. /** Defines the main impostor to which the joint is linked */
  32794. mainImpostor: PhysicsImpostor;
  32795. /** Defines the impostor that is connected to the main impostor using this joint */
  32796. connectedImpostor: PhysicsImpostor;
  32797. /** Defines the joint itself */
  32798. joint: PhysicsJoint;
  32799. }
  32800. /** @hidden */
  32801. export interface IPhysicsEnginePlugin {
  32802. world: any;
  32803. name: string;
  32804. setGravity(gravity: Vector3): void;
  32805. setTimeStep(timeStep: number): void;
  32806. getTimeStep(): number;
  32807. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  32808. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32809. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32810. generatePhysicsBody(impostor: PhysicsImpostor): void;
  32811. removePhysicsBody(impostor: PhysicsImpostor): void;
  32812. generateJoint(joint: PhysicsImpostorJoint): void;
  32813. removeJoint(joint: PhysicsImpostorJoint): void;
  32814. isSupported(): boolean;
  32815. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  32816. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  32817. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32818. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32819. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32820. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32821. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  32822. getBodyMass(impostor: PhysicsImpostor): number;
  32823. getBodyFriction(impostor: PhysicsImpostor): number;
  32824. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  32825. getBodyRestitution(impostor: PhysicsImpostor): number;
  32826. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  32827. getBodyPressure?(impostor: PhysicsImpostor): number;
  32828. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  32829. getBodyStiffness?(impostor: PhysicsImpostor): number;
  32830. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  32831. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  32832. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  32833. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  32834. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  32835. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  32836. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  32837. sleepBody(impostor: PhysicsImpostor): void;
  32838. wakeUpBody(impostor: PhysicsImpostor): void;
  32839. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  32840. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  32841. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  32842. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32843. getRadius(impostor: PhysicsImpostor): number;
  32844. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  32845. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  32846. dispose(): void;
  32847. }
  32848. /**
  32849. * Interface used to define a physics engine
  32850. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32851. */
  32852. export interface IPhysicsEngine {
  32853. /**
  32854. * Gets the gravity vector used by the simulation
  32855. */
  32856. gravity: Vector3;
  32857. /**
  32858. * Sets the gravity vector used by the simulation
  32859. * @param gravity defines the gravity vector to use
  32860. */
  32861. setGravity(gravity: Vector3): void;
  32862. /**
  32863. * Set the time step of the physics engine.
  32864. * Default is 1/60.
  32865. * To slow it down, enter 1/600 for example.
  32866. * To speed it up, 1/30
  32867. * @param newTimeStep the new timestep to apply to this world.
  32868. */
  32869. setTimeStep(newTimeStep: number): void;
  32870. /**
  32871. * Get the time step of the physics engine.
  32872. * @returns the current time step
  32873. */
  32874. getTimeStep(): number;
  32875. /**
  32876. * Set the sub time step of the physics engine.
  32877. * Default is 0 meaning there is no sub steps
  32878. * To increase physics resolution precision, set a small value (like 1 ms)
  32879. * @param subTimeStep defines the new sub timestep used for physics resolution.
  32880. */
  32881. setSubTimeStep(subTimeStep: number): void;
  32882. /**
  32883. * Get the sub time step of the physics engine.
  32884. * @returns the current sub time step
  32885. */
  32886. getSubTimeStep(): number;
  32887. /**
  32888. * Release all resources
  32889. */
  32890. dispose(): void;
  32891. /**
  32892. * Gets the name of the current physics plugin
  32893. * @returns the name of the plugin
  32894. */
  32895. getPhysicsPluginName(): string;
  32896. /**
  32897. * Adding a new impostor for the impostor tracking.
  32898. * This will be done by the impostor itself.
  32899. * @param impostor the impostor to add
  32900. */
  32901. addImpostor(impostor: PhysicsImpostor): void;
  32902. /**
  32903. * Remove an impostor from the engine.
  32904. * This impostor and its mesh will not longer be updated by the physics engine.
  32905. * @param impostor the impostor to remove
  32906. */
  32907. removeImpostor(impostor: PhysicsImpostor): void;
  32908. /**
  32909. * Add a joint to the physics engine
  32910. * @param mainImpostor defines the main impostor to which the joint is added.
  32911. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  32912. * @param joint defines the joint that will connect both impostors.
  32913. */
  32914. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32915. /**
  32916. * Removes a joint from the simulation
  32917. * @param mainImpostor defines the impostor used with the joint
  32918. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  32919. * @param joint defines the joint to remove
  32920. */
  32921. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32922. /**
  32923. * Gets the current plugin used to run the simulation
  32924. * @returns current plugin
  32925. */
  32926. getPhysicsPlugin(): IPhysicsEnginePlugin;
  32927. /**
  32928. * Gets the list of physic impostors
  32929. * @returns an array of PhysicsImpostor
  32930. */
  32931. getImpostors(): Array<PhysicsImpostor>;
  32932. /**
  32933. * Gets the impostor for a physics enabled object
  32934. * @param object defines the object impersonated by the impostor
  32935. * @returns the PhysicsImpostor or null if not found
  32936. */
  32937. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32938. /**
  32939. * Gets the impostor for a physics body object
  32940. * @param body defines physics body used by the impostor
  32941. * @returns the PhysicsImpostor or null if not found
  32942. */
  32943. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  32944. /**
  32945. * Does a raycast in the physics world
  32946. * @param from when should the ray start?
  32947. * @param to when should the ray end?
  32948. * @returns PhysicsRaycastResult
  32949. */
  32950. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  32951. /**
  32952. * Called by the scene. No need to call it.
  32953. * @param delta defines the timespan between frames
  32954. */
  32955. _step(delta: number): void;
  32956. }
  32957. }
  32958. declare module BABYLON {
  32959. /**
  32960. * The interface for the physics imposter parameters
  32961. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32962. */
  32963. export interface PhysicsImpostorParameters {
  32964. /**
  32965. * The mass of the physics imposter
  32966. */
  32967. mass: number;
  32968. /**
  32969. * The friction of the physics imposter
  32970. */
  32971. friction?: number;
  32972. /**
  32973. * The coefficient of restitution of the physics imposter
  32974. */
  32975. restitution?: number;
  32976. /**
  32977. * The native options of the physics imposter
  32978. */
  32979. nativeOptions?: any;
  32980. /**
  32981. * Specifies if the parent should be ignored
  32982. */
  32983. ignoreParent?: boolean;
  32984. /**
  32985. * Specifies if bi-directional transformations should be disabled
  32986. */
  32987. disableBidirectionalTransformation?: boolean;
  32988. /**
  32989. * The pressure inside the physics imposter, soft object only
  32990. */
  32991. pressure?: number;
  32992. /**
  32993. * The stiffness the physics imposter, soft object only
  32994. */
  32995. stiffness?: number;
  32996. /**
  32997. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  32998. */
  32999. velocityIterations?: number;
  33000. /**
  33001. * The number of iterations used in maintaining consistent vertex positions, soft object only
  33002. */
  33003. positionIterations?: number;
  33004. /**
  33005. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  33006. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  33007. * Add to fix multiple points
  33008. */
  33009. fixedPoints?: number;
  33010. /**
  33011. * The collision margin around a soft object
  33012. */
  33013. margin?: number;
  33014. /**
  33015. * The collision margin around a soft object
  33016. */
  33017. damping?: number;
  33018. /**
  33019. * The path for a rope based on an extrusion
  33020. */
  33021. path?: any;
  33022. /**
  33023. * The shape of an extrusion used for a rope based on an extrusion
  33024. */
  33025. shape?: any;
  33026. }
  33027. /**
  33028. * Interface for a physics-enabled object
  33029. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33030. */
  33031. export interface IPhysicsEnabledObject {
  33032. /**
  33033. * The position of the physics-enabled object
  33034. */
  33035. position: Vector3;
  33036. /**
  33037. * The rotation of the physics-enabled object
  33038. */
  33039. rotationQuaternion: Nullable<Quaternion>;
  33040. /**
  33041. * The scale of the physics-enabled object
  33042. */
  33043. scaling: Vector3;
  33044. /**
  33045. * The rotation of the physics-enabled object
  33046. */
  33047. rotation?: Vector3;
  33048. /**
  33049. * The parent of the physics-enabled object
  33050. */
  33051. parent?: any;
  33052. /**
  33053. * The bounding info of the physics-enabled object
  33054. * @returns The bounding info of the physics-enabled object
  33055. */
  33056. getBoundingInfo(): BoundingInfo;
  33057. /**
  33058. * Computes the world matrix
  33059. * @param force Specifies if the world matrix should be computed by force
  33060. * @returns A world matrix
  33061. */
  33062. computeWorldMatrix(force: boolean): Matrix;
  33063. /**
  33064. * Gets the world matrix
  33065. * @returns A world matrix
  33066. */
  33067. getWorldMatrix?(): Matrix;
  33068. /**
  33069. * Gets the child meshes
  33070. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  33071. * @returns An array of abstract meshes
  33072. */
  33073. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  33074. /**
  33075. * Gets the vertex data
  33076. * @param kind The type of vertex data
  33077. * @returns A nullable array of numbers, or a float32 array
  33078. */
  33079. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  33080. /**
  33081. * Gets the indices from the mesh
  33082. * @returns A nullable array of index arrays
  33083. */
  33084. getIndices?(): Nullable<IndicesArray>;
  33085. /**
  33086. * Gets the scene from the mesh
  33087. * @returns the indices array or null
  33088. */
  33089. getScene?(): Scene;
  33090. /**
  33091. * Gets the absolute position from the mesh
  33092. * @returns the absolute position
  33093. */
  33094. getAbsolutePosition(): Vector3;
  33095. /**
  33096. * Gets the absolute pivot point from the mesh
  33097. * @returns the absolute pivot point
  33098. */
  33099. getAbsolutePivotPoint(): Vector3;
  33100. /**
  33101. * Rotates the mesh
  33102. * @param axis The axis of rotation
  33103. * @param amount The amount of rotation
  33104. * @param space The space of the rotation
  33105. * @returns The rotation transform node
  33106. */
  33107. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  33108. /**
  33109. * Translates the mesh
  33110. * @param axis The axis of translation
  33111. * @param distance The distance of translation
  33112. * @param space The space of the translation
  33113. * @returns The transform node
  33114. */
  33115. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  33116. /**
  33117. * Sets the absolute position of the mesh
  33118. * @param absolutePosition The absolute position of the mesh
  33119. * @returns The transform node
  33120. */
  33121. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  33122. /**
  33123. * Gets the class name of the mesh
  33124. * @returns The class name
  33125. */
  33126. getClassName(): string;
  33127. }
  33128. /**
  33129. * Represents a physics imposter
  33130. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33131. */
  33132. export class PhysicsImpostor {
  33133. /**
  33134. * The physics-enabled object used as the physics imposter
  33135. */
  33136. object: IPhysicsEnabledObject;
  33137. /**
  33138. * The type of the physics imposter
  33139. */
  33140. type: number;
  33141. private _options;
  33142. private _scene?;
  33143. /**
  33144. * The default object size of the imposter
  33145. */
  33146. static DEFAULT_OBJECT_SIZE: Vector3;
  33147. /**
  33148. * The identity quaternion of the imposter
  33149. */
  33150. static IDENTITY_QUATERNION: Quaternion;
  33151. /** @hidden */
  33152. _pluginData: any;
  33153. private _physicsEngine;
  33154. private _physicsBody;
  33155. private _bodyUpdateRequired;
  33156. private _onBeforePhysicsStepCallbacks;
  33157. private _onAfterPhysicsStepCallbacks;
  33158. /** @hidden */
  33159. _onPhysicsCollideCallbacks: Array<{
  33160. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void;
  33161. otherImpostors: Array<PhysicsImpostor>;
  33162. }>;
  33163. private _deltaPosition;
  33164. private _deltaRotation;
  33165. private _deltaRotationConjugated;
  33166. /** @hidden */
  33167. _isFromLine: boolean;
  33168. private _parent;
  33169. private _isDisposed;
  33170. private static _tmpVecs;
  33171. private static _tmpQuat;
  33172. /**
  33173. * Specifies if the physics imposter is disposed
  33174. */
  33175. get isDisposed(): boolean;
  33176. /**
  33177. * Gets the mass of the physics imposter
  33178. */
  33179. get mass(): number;
  33180. set mass(value: number);
  33181. /**
  33182. * Gets the coefficient of friction
  33183. */
  33184. get friction(): number;
  33185. /**
  33186. * Sets the coefficient of friction
  33187. */
  33188. set friction(value: number);
  33189. /**
  33190. * Gets the coefficient of restitution
  33191. */
  33192. get restitution(): number;
  33193. /**
  33194. * Sets the coefficient of restitution
  33195. */
  33196. set restitution(value: number);
  33197. /**
  33198. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  33199. */
  33200. get pressure(): number;
  33201. /**
  33202. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  33203. */
  33204. set pressure(value: number);
  33205. /**
  33206. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  33207. */
  33208. get stiffness(): number;
  33209. /**
  33210. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  33211. */
  33212. set stiffness(value: number);
  33213. /**
  33214. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  33215. */
  33216. get velocityIterations(): number;
  33217. /**
  33218. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  33219. */
  33220. set velocityIterations(value: number);
  33221. /**
  33222. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  33223. */
  33224. get positionIterations(): number;
  33225. /**
  33226. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  33227. */
  33228. set positionIterations(value: number);
  33229. /**
  33230. * The unique id of the physics imposter
  33231. * set by the physics engine when adding this impostor to the array
  33232. */
  33233. uniqueId: number;
  33234. /**
  33235. * @hidden
  33236. */
  33237. soft: boolean;
  33238. /**
  33239. * @hidden
  33240. */
  33241. segments: number;
  33242. private _joints;
  33243. /**
  33244. * Initializes the physics imposter
  33245. * @param object The physics-enabled object used as the physics imposter
  33246. * @param type The type of the physics imposter
  33247. * @param _options The options for the physics imposter
  33248. * @param _scene The Babylon scene
  33249. */
  33250. constructor(
  33251. /**
  33252. * The physics-enabled object used as the physics imposter
  33253. */
  33254. object: IPhysicsEnabledObject,
  33255. /**
  33256. * The type of the physics imposter
  33257. */
  33258. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  33259. /**
  33260. * This function will completely initialize this impostor.
  33261. * It will create a new body - but only if this mesh has no parent.
  33262. * If it has, this impostor will not be used other than to define the impostor
  33263. * of the child mesh.
  33264. * @hidden
  33265. */
  33266. _init(): void;
  33267. private _getPhysicsParent;
  33268. /**
  33269. * Should a new body be generated.
  33270. * @returns boolean specifying if body initialization is required
  33271. */
  33272. isBodyInitRequired(): boolean;
  33273. /**
  33274. * Sets the updated scaling
  33275. * @param updated Specifies if the scaling is updated
  33276. */
  33277. setScalingUpdated(): void;
  33278. /**
  33279. * Force a regeneration of this or the parent's impostor's body.
  33280. * Use under cautious - This will remove all joints already implemented.
  33281. */
  33282. forceUpdate(): void;
  33283. /**
  33284. * Gets the body that holds this impostor. Either its own, or its parent.
  33285. */
  33286. get physicsBody(): any;
  33287. /**
  33288. * Get the parent of the physics imposter
  33289. * @returns Physics imposter or null
  33290. */
  33291. get parent(): Nullable<PhysicsImpostor>;
  33292. /**
  33293. * Sets the parent of the physics imposter
  33294. */
  33295. set parent(value: Nullable<PhysicsImpostor>);
  33296. /**
  33297. * Set the physics body. Used mainly by the physics engine/plugin
  33298. */
  33299. set physicsBody(physicsBody: any);
  33300. /**
  33301. * Resets the update flags
  33302. */
  33303. resetUpdateFlags(): void;
  33304. /**
  33305. * Gets the object extend size
  33306. * @returns the object extend size
  33307. */
  33308. getObjectExtendSize(): Vector3;
  33309. /**
  33310. * Gets the object center
  33311. * @returns The object center
  33312. */
  33313. getObjectCenter(): Vector3;
  33314. /**
  33315. * Get a specific parameter from the options parameters
  33316. * @param paramName The object parameter name
  33317. * @returns The object parameter
  33318. */
  33319. getParam(paramName: string): any;
  33320. /**
  33321. * Sets a specific parameter in the options given to the physics plugin
  33322. * @param paramName The parameter name
  33323. * @param value The value of the parameter
  33324. */
  33325. setParam(paramName: string, value: number): void;
  33326. /**
  33327. * Specifically change the body's mass option. Won't recreate the physics body object
  33328. * @param mass The mass of the physics imposter
  33329. */
  33330. setMass(mass: number): void;
  33331. /**
  33332. * Gets the linear velocity
  33333. * @returns linear velocity or null
  33334. */
  33335. getLinearVelocity(): Nullable<Vector3>;
  33336. /**
  33337. * Sets the linear velocity
  33338. * @param velocity linear velocity or null
  33339. */
  33340. setLinearVelocity(velocity: Nullable<Vector3>): void;
  33341. /**
  33342. * Gets the angular velocity
  33343. * @returns angular velocity or null
  33344. */
  33345. getAngularVelocity(): Nullable<Vector3>;
  33346. /**
  33347. * Sets the angular velocity
  33348. * @param velocity The velocity or null
  33349. */
  33350. setAngularVelocity(velocity: Nullable<Vector3>): void;
  33351. /**
  33352. * Execute a function with the physics plugin native code
  33353. * Provide a function the will have two variables - the world object and the physics body object
  33354. * @param func The function to execute with the physics plugin native code
  33355. */
  33356. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  33357. /**
  33358. * Register a function that will be executed before the physics world is stepping forward
  33359. * @param func The function to execute before the physics world is stepped forward
  33360. */
  33361. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33362. /**
  33363. * Unregister a function that will be executed before the physics world is stepping forward
  33364. * @param func The function to execute before the physics world is stepped forward
  33365. */
  33366. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33367. /**
  33368. * Register a function that will be executed after the physics step
  33369. * @param func The function to execute after physics step
  33370. */
  33371. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33372. /**
  33373. * Unregisters a function that will be executed after the physics step
  33374. * @param func The function to execute after physics step
  33375. */
  33376. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33377. /**
  33378. * register a function that will be executed when this impostor collides against a different body
  33379. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  33380. * @param func Callback that is executed on collision
  33381. */
  33382. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  33383. /**
  33384. * Unregisters the physics imposter on contact
  33385. * @param collideAgainst The physics object to collide against
  33386. * @param func Callback to execute on collision
  33387. */
  33388. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  33389. private _tmpQuat;
  33390. private _tmpQuat2;
  33391. /**
  33392. * Get the parent rotation
  33393. * @returns The parent rotation
  33394. */
  33395. getParentsRotation(): Quaternion;
  33396. /**
  33397. * this function is executed by the physics engine.
  33398. */
  33399. beforeStep: () => void;
  33400. /**
  33401. * this function is executed by the physics engine
  33402. */
  33403. afterStep: () => void;
  33404. /**
  33405. * Legacy collision detection event support
  33406. */
  33407. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  33408. /**
  33409. * event and body object due to cannon's event-based architecture.
  33410. */
  33411. onCollide: (e: {
  33412. body: any;
  33413. point: Nullable<Vector3>;
  33414. }) => void;
  33415. /**
  33416. * Apply a force
  33417. * @param force The force to apply
  33418. * @param contactPoint The contact point for the force
  33419. * @returns The physics imposter
  33420. */
  33421. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  33422. /**
  33423. * Apply an impulse
  33424. * @param force The impulse force
  33425. * @param contactPoint The contact point for the impulse force
  33426. * @returns The physics imposter
  33427. */
  33428. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  33429. /**
  33430. * A help function to create a joint
  33431. * @param otherImpostor A physics imposter used to create a joint
  33432. * @param jointType The type of joint
  33433. * @param jointData The data for the joint
  33434. * @returns The physics imposter
  33435. */
  33436. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  33437. /**
  33438. * Add a joint to this impostor with a different impostor
  33439. * @param otherImpostor A physics imposter used to add a joint
  33440. * @param joint The joint to add
  33441. * @returns The physics imposter
  33442. */
  33443. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  33444. /**
  33445. * Add an anchor to a cloth impostor
  33446. * @param otherImpostor rigid impostor to anchor to
  33447. * @param width ratio across width from 0 to 1
  33448. * @param height ratio up height from 0 to 1
  33449. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little stretch
  33450. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  33451. * @returns impostor the soft imposter
  33452. */
  33453. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  33454. /**
  33455. * Add a hook to a rope impostor
  33456. * @param otherImpostor rigid impostor to anchor to
  33457. * @param length ratio across rope from 0 to 1
  33458. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little stretch
  33459. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  33460. * @returns impostor the rope imposter
  33461. */
  33462. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  33463. /**
  33464. * Will keep this body still, in a sleep mode.
  33465. * @returns the physics imposter
  33466. */
  33467. sleep(): PhysicsImpostor;
  33468. /**
  33469. * Wake the body up.
  33470. * @returns The physics imposter
  33471. */
  33472. wakeUp(): PhysicsImpostor;
  33473. /**
  33474. * Clones the physics imposter
  33475. * @param newObject The physics imposter clones to this physics-enabled object
  33476. * @returns A nullable physics imposter
  33477. */
  33478. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  33479. /**
  33480. * Disposes the physics imposter
  33481. */
  33482. dispose(): void;
  33483. /**
  33484. * Sets the delta position
  33485. * @param position The delta position amount
  33486. */
  33487. setDeltaPosition(position: Vector3): void;
  33488. /**
  33489. * Sets the delta rotation
  33490. * @param rotation The delta rotation amount
  33491. */
  33492. setDeltaRotation(rotation: Quaternion): void;
  33493. /**
  33494. * Gets the box size of the physics imposter and stores the result in the input parameter
  33495. * @param result Stores the box size
  33496. * @returns The physics imposter
  33497. */
  33498. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  33499. /**
  33500. * Gets the radius of the physics imposter
  33501. * @returns Radius of the physics imposter
  33502. */
  33503. getRadius(): number;
  33504. /**
  33505. * Sync a bone with this impostor
  33506. * @param bone The bone to sync to the impostor.
  33507. * @param boneMesh The mesh that the bone is influencing.
  33508. * @param jointPivot The pivot of the joint / bone in local space.
  33509. * @param distToJoint Optional distance from the impostor to the joint.
  33510. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  33511. */
  33512. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  33513. /**
  33514. * Sync impostor to a bone
  33515. * @param bone The bone that the impostor will be synced to.
  33516. * @param boneMesh The mesh that the bone is influencing.
  33517. * @param jointPivot The pivot of the joint / bone in local space.
  33518. * @param distToJoint Optional distance from the impostor to the joint.
  33519. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  33520. * @param boneAxis Optional vector3 axis the bone is aligned with
  33521. */
  33522. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  33523. /**
  33524. * No-Imposter type
  33525. */
  33526. static NoImpostor: number;
  33527. /**
  33528. * Sphere-Imposter type
  33529. */
  33530. static SphereImpostor: number;
  33531. /**
  33532. * Box-Imposter type
  33533. */
  33534. static BoxImpostor: number;
  33535. /**
  33536. * Plane-Imposter type
  33537. */
  33538. static PlaneImpostor: number;
  33539. /**
  33540. * Mesh-imposter type
  33541. */
  33542. static MeshImpostor: number;
  33543. /**
  33544. * Capsule-Impostor type (Ammo.js plugin only)
  33545. */
  33546. static CapsuleImpostor: number;
  33547. /**
  33548. * Cylinder-Imposter type
  33549. */
  33550. static CylinderImpostor: number;
  33551. /**
  33552. * Particle-Imposter type
  33553. */
  33554. static ParticleImpostor: number;
  33555. /**
  33556. * Heightmap-Imposter type
  33557. */
  33558. static HeightmapImpostor: number;
  33559. /**
  33560. * ConvexHull-Impostor type (Ammo.js plugin only)
  33561. */
  33562. static ConvexHullImpostor: number;
  33563. /**
  33564. * Custom-Imposter type (Ammo.js plugin only)
  33565. */
  33566. static CustomImpostor: number;
  33567. /**
  33568. * Rope-Imposter type
  33569. */
  33570. static RopeImpostor: number;
  33571. /**
  33572. * Cloth-Imposter type
  33573. */
  33574. static ClothImpostor: number;
  33575. /**
  33576. * Softbody-Imposter type
  33577. */
  33578. static SoftbodyImpostor: number;
  33579. }
  33580. }
  33581. declare module BABYLON {
  33582. /**
  33583. * @hidden
  33584. **/
  33585. export class _CreationDataStorage {
  33586. closePath?: boolean;
  33587. closeArray?: boolean;
  33588. idx: number[];
  33589. dashSize: number;
  33590. gapSize: number;
  33591. path3D: Path3D;
  33592. pathArray: Vector3[][];
  33593. arc: number;
  33594. radius: number;
  33595. cap: number;
  33596. tessellation: number;
  33597. }
  33598. /**
  33599. * @hidden
  33600. **/
  33601. class _InstanceDataStorage {
  33602. visibleInstances: any;
  33603. batchCache: _InstancesBatch;
  33604. instancesBufferSize: number;
  33605. instancesBuffer: Nullable<Buffer>;
  33606. instancesData: Float32Array;
  33607. overridenInstanceCount: number;
  33608. isFrozen: boolean;
  33609. previousBatch: Nullable<_InstancesBatch>;
  33610. hardwareInstancedRendering: boolean;
  33611. sideOrientation: number;
  33612. manualUpdate: boolean;
  33613. previousRenderId: number;
  33614. }
  33615. /**
  33616. * @hidden
  33617. **/
  33618. export class _InstancesBatch {
  33619. mustReturn: boolean;
  33620. visibleInstances: Nullable<InstancedMesh[]>[];
  33621. renderSelf: boolean[];
  33622. hardwareInstancedRendering: boolean[];
  33623. }
  33624. /**
  33625. * @hidden
  33626. **/
  33627. class _ThinInstanceDataStorage {
  33628. instancesCount: number;
  33629. matrixBuffer: Nullable<Buffer>;
  33630. matrixBufferSize: number;
  33631. matrixData: Nullable<Float32Array>;
  33632. boundingVectors: Array<Vector3>;
  33633. worldMatrices: Nullable<Matrix[]>;
  33634. }
  33635. /**
  33636. * Class used to represent renderable models
  33637. */
  33638. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  33639. /**
  33640. * Mesh side orientation : usually the external or front surface
  33641. */
  33642. static readonly FRONTSIDE: number;
  33643. /**
  33644. * Mesh side orientation : usually the internal or back surface
  33645. */
  33646. static readonly BACKSIDE: number;
  33647. /**
  33648. * Mesh side orientation : both internal and external or front and back surfaces
  33649. */
  33650. static readonly DOUBLESIDE: number;
  33651. /**
  33652. * Mesh side orientation : by default, `FRONTSIDE`
  33653. */
  33654. static readonly DEFAULTSIDE: number;
  33655. /**
  33656. * Mesh cap setting : no cap
  33657. */
  33658. static readonly NO_CAP: number;
  33659. /**
  33660. * Mesh cap setting : one cap at the beginning of the mesh
  33661. */
  33662. static readonly CAP_START: number;
  33663. /**
  33664. * Mesh cap setting : one cap at the end of the mesh
  33665. */
  33666. static readonly CAP_END: number;
  33667. /**
  33668. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  33669. */
  33670. static readonly CAP_ALL: number;
  33671. /**
  33672. * Mesh pattern setting : no flip or rotate
  33673. */
  33674. static readonly NO_FLIP: number;
  33675. /**
  33676. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  33677. */
  33678. static readonly FLIP_TILE: number;
  33679. /**
  33680. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  33681. */
  33682. static readonly ROTATE_TILE: number;
  33683. /**
  33684. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  33685. */
  33686. static readonly FLIP_ROW: number;
  33687. /**
  33688. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  33689. */
  33690. static readonly ROTATE_ROW: number;
  33691. /**
  33692. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  33693. */
  33694. static readonly FLIP_N_ROTATE_TILE: number;
  33695. /**
  33696. * Mesh pattern setting : rotate pattern and rotate
  33697. */
  33698. static readonly FLIP_N_ROTATE_ROW: number;
  33699. /**
  33700. * Mesh tile positioning : part tiles same on left/right or top/bottom
  33701. */
  33702. static readonly CENTER: number;
  33703. /**
  33704. * Mesh tile positioning : part tiles on left
  33705. */
  33706. static readonly LEFT: number;
  33707. /**
  33708. * Mesh tile positioning : part tiles on right
  33709. */
  33710. static readonly RIGHT: number;
  33711. /**
  33712. * Mesh tile positioning : part tiles on top
  33713. */
  33714. static readonly TOP: number;
  33715. /**
  33716. * Mesh tile positioning : part tiles on bottom
  33717. */
  33718. static readonly BOTTOM: number;
  33719. /**
  33720. * Gets the default side orientation.
  33721. * @param orientation the orientation to value to attempt to get
  33722. * @returns the default orientation
  33723. * @hidden
  33724. */
  33725. static _GetDefaultSideOrientation(orientation?: number): number;
  33726. private _internalMeshDataInfo;
  33727. get computeBonesUsingShaders(): boolean;
  33728. set computeBonesUsingShaders(value: boolean);
  33729. /**
  33730. * An event triggered before rendering the mesh
  33731. */
  33732. get onBeforeRenderObservable(): Observable<Mesh>;
  33733. /**
  33734. * An event triggered before binding the mesh
  33735. */
  33736. get onBeforeBindObservable(): Observable<Mesh>;
  33737. /**
  33738. * An event triggered after rendering the mesh
  33739. */
  33740. get onAfterRenderObservable(): Observable<Mesh>;
  33741. /**
  33742. * An event triggeredbetween rendering pass wneh using separateCullingPass = true
  33743. */
  33744. get onBetweenPassObservable(): Observable<Mesh>;
  33745. /**
  33746. * An event triggered before drawing the mesh
  33747. */
  33748. get onBeforeDrawObservable(): Observable<Mesh>;
  33749. private _onBeforeDrawObserver;
  33750. /**
  33751. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  33752. */
  33753. set onBeforeDraw(callback: () => void);
  33754. get hasInstances(): boolean;
  33755. get hasThinInstances(): boolean;
  33756. /**
  33757. * Gets the delay loading state of the mesh (when delay loading is turned on)
  33758. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  33759. */
  33760. delayLoadState: number;
  33761. /**
  33762. * Gets the list of instances created from this mesh
  33763. * it is not supposed to be modified manually.
  33764. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  33765. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  33766. */
  33767. instances: InstancedMesh[];
  33768. /**
  33769. * Gets the file containing delay loading data for this mesh
  33770. */
  33771. delayLoadingFile: string;
  33772. /** @hidden */
  33773. _binaryInfo: any;
  33774. /**
  33775. * User defined function used to change how LOD level selection is done
  33776. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33777. */
  33778. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  33779. /**
  33780. * Gets or sets the morph target manager
  33781. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  33782. */
  33783. get morphTargetManager(): Nullable<MorphTargetManager>;
  33784. set morphTargetManager(value: Nullable<MorphTargetManager>);
  33785. /** @hidden */
  33786. _creationDataStorage: Nullable<_CreationDataStorage>;
  33787. /** @hidden */
  33788. _geometry: Nullable<Geometry>;
  33789. /** @hidden */
  33790. _delayInfo: Array<string>;
  33791. /** @hidden */
  33792. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  33793. /** @hidden */
  33794. _instanceDataStorage: _InstanceDataStorage;
  33795. /** @hidden */
  33796. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  33797. private _effectiveMaterial;
  33798. /** @hidden */
  33799. _shouldGenerateFlatShading: boolean;
  33800. /** @hidden */
  33801. _originalBuilderSideOrientation: number;
  33802. /**
  33803. * Use this property to change the original side orientation defined at construction time
  33804. */
  33805. overrideMaterialSideOrientation: Nullable<number>;
  33806. /**
  33807. * Gets or sets a boolean indicating whether to render ignoring the active camera's max z setting. (false by default)
  33808. * Note this will reduce performance when set to true.
  33809. */
  33810. ignoreCameraMaxZ: boolean;
  33811. /**
  33812. * Gets the source mesh (the one used to clone this one from)
  33813. */
  33814. get source(): Nullable<Mesh>;
  33815. /**
  33816. * Gets the list of clones of this mesh
  33817. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  33818. * Note that useClonedMeshMap=true is the default setting
  33819. */
  33820. get cloneMeshMap(): Nullable<{
  33821. [id: string]: Mesh | undefined;
  33822. }>;
  33823. /**
  33824. * Gets or sets a boolean indicating that this mesh does not use index buffer
  33825. */
  33826. get isUnIndexed(): boolean;
  33827. set isUnIndexed(value: boolean);
  33828. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  33829. get worldMatrixInstancedBuffer(): Float32Array;
  33830. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  33831. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  33832. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  33833. /**
  33834. * @constructor
  33835. * @param name The value used by scene.getMeshByName() to do a lookup.
  33836. * @param scene The scene to add this mesh to.
  33837. * @param parent The parent of this mesh, if it has one
  33838. * @param source An optional Mesh from which geometry is shared, cloned.
  33839. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  33840. * When false, achieved by calling a clone(), also passing False.
  33841. * This will make creation of children, recursive.
  33842. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  33843. */
  33844. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  33845. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  33846. doNotInstantiate: boolean;
  33847. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  33848. /**
  33849. * Gets the class name
  33850. * @returns the string "Mesh".
  33851. */
  33852. getClassName(): string;
  33853. /** @hidden */
  33854. get _isMesh(): boolean;
  33855. /**
  33856. * Returns a description of this mesh
  33857. * @param fullDetails define if full details about this mesh must be used
  33858. * @returns a descriptive string representing this mesh
  33859. */
  33860. toString(fullDetails?: boolean): string;
  33861. /** @hidden */
  33862. _unBindEffect(): void;
  33863. /**
  33864. * Gets a boolean indicating if this mesh has LOD
  33865. */
  33866. get hasLODLevels(): boolean;
  33867. /**
  33868. * Gets the list of MeshLODLevel associated with the current mesh
  33869. * @returns an array of MeshLODLevel
  33870. */
  33871. getLODLevels(): MeshLODLevel[];
  33872. private _sortLODLevels;
  33873. /**
  33874. * Add a mesh as LOD level triggered at the given distance.
  33875. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33876. * @param distance The distance from the center of the object to show this level
  33877. * @param mesh The mesh to be added as LOD level (can be null)
  33878. * @return This mesh (for chaining)
  33879. */
  33880. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  33881. /**
  33882. * Returns the LOD level mesh at the passed distance or null if not found.
  33883. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33884. * @param distance The distance from the center of the object to show this level
  33885. * @returns a Mesh or `null`
  33886. */
  33887. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  33888. /**
  33889. * Remove a mesh from the LOD array
  33890. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33891. * @param mesh defines the mesh to be removed
  33892. * @return This mesh (for chaining)
  33893. */
  33894. removeLODLevel(mesh: Mesh): Mesh;
  33895. /**
  33896. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  33897. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33898. * @param camera defines the camera to use to compute distance
  33899. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  33900. * @return This mesh (for chaining)
  33901. */
  33902. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  33903. /**
  33904. * Gets the mesh internal Geometry object
  33905. */
  33906. get geometry(): Nullable<Geometry>;
  33907. /**
  33908. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  33909. * @returns the total number of vertices
  33910. */
  33911. getTotalVertices(): number;
  33912. /**
  33913. * Returns the content of an associated vertex buffer
  33914. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33915. * - VertexBuffer.PositionKind
  33916. * - VertexBuffer.UVKind
  33917. * - VertexBuffer.UV2Kind
  33918. * - VertexBuffer.UV3Kind
  33919. * - VertexBuffer.UV4Kind
  33920. * - VertexBuffer.UV5Kind
  33921. * - VertexBuffer.UV6Kind
  33922. * - VertexBuffer.ColorKind
  33923. * - VertexBuffer.MatricesIndicesKind
  33924. * - VertexBuffer.MatricesIndicesExtraKind
  33925. * - VertexBuffer.MatricesWeightsKind
  33926. * - VertexBuffer.MatricesWeightsExtraKind
  33927. * @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
  33928. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  33929. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  33930. */
  33931. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  33932. /**
  33933. * Returns the mesh VertexBuffer object from the requested `kind`
  33934. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33935. * - VertexBuffer.PositionKind
  33936. * - VertexBuffer.NormalKind
  33937. * - VertexBuffer.UVKind
  33938. * - VertexBuffer.UV2Kind
  33939. * - VertexBuffer.UV3Kind
  33940. * - VertexBuffer.UV4Kind
  33941. * - VertexBuffer.UV5Kind
  33942. * - VertexBuffer.UV6Kind
  33943. * - VertexBuffer.ColorKind
  33944. * - VertexBuffer.MatricesIndicesKind
  33945. * - VertexBuffer.MatricesIndicesExtraKind
  33946. * - VertexBuffer.MatricesWeightsKind
  33947. * - VertexBuffer.MatricesWeightsExtraKind
  33948. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  33949. */
  33950. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  33951. /**
  33952. * Tests if a specific vertex buffer is associated with this mesh
  33953. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  33954. * - VertexBuffer.PositionKind
  33955. * - VertexBuffer.NormalKind
  33956. * - VertexBuffer.UVKind
  33957. * - VertexBuffer.UV2Kind
  33958. * - VertexBuffer.UV3Kind
  33959. * - VertexBuffer.UV4Kind
  33960. * - VertexBuffer.UV5Kind
  33961. * - VertexBuffer.UV6Kind
  33962. * - VertexBuffer.ColorKind
  33963. * - VertexBuffer.MatricesIndicesKind
  33964. * - VertexBuffer.MatricesIndicesExtraKind
  33965. * - VertexBuffer.MatricesWeightsKind
  33966. * - VertexBuffer.MatricesWeightsExtraKind
  33967. * @returns a boolean
  33968. */
  33969. isVerticesDataPresent(kind: string): boolean;
  33970. /**
  33971. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  33972. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  33973. * - VertexBuffer.PositionKind
  33974. * - VertexBuffer.UVKind
  33975. * - VertexBuffer.UV2Kind
  33976. * - VertexBuffer.UV3Kind
  33977. * - VertexBuffer.UV4Kind
  33978. * - VertexBuffer.UV5Kind
  33979. * - VertexBuffer.UV6Kind
  33980. * - VertexBuffer.ColorKind
  33981. * - VertexBuffer.MatricesIndicesKind
  33982. * - VertexBuffer.MatricesIndicesExtraKind
  33983. * - VertexBuffer.MatricesWeightsKind
  33984. * - VertexBuffer.MatricesWeightsExtraKind
  33985. * @returns a boolean
  33986. */
  33987. isVertexBufferUpdatable(kind: string): boolean;
  33988. /**
  33989. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  33990. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33991. * - VertexBuffer.PositionKind
  33992. * - VertexBuffer.NormalKind
  33993. * - VertexBuffer.UVKind
  33994. * - VertexBuffer.UV2Kind
  33995. * - VertexBuffer.UV3Kind
  33996. * - VertexBuffer.UV4Kind
  33997. * - VertexBuffer.UV5Kind
  33998. * - VertexBuffer.UV6Kind
  33999. * - VertexBuffer.ColorKind
  34000. * - VertexBuffer.MatricesIndicesKind
  34001. * - VertexBuffer.MatricesIndicesExtraKind
  34002. * - VertexBuffer.MatricesWeightsKind
  34003. * - VertexBuffer.MatricesWeightsExtraKind
  34004. * @returns an array of strings
  34005. */
  34006. getVerticesDataKinds(): string[];
  34007. /**
  34008. * Returns a positive integer : the total number of indices in this mesh geometry.
  34009. * @returns the numner of indices or zero if the mesh has no geometry.
  34010. */
  34011. getTotalIndices(): number;
  34012. /**
  34013. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  34014. * @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.
  34015. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  34016. * @returns the indices array or an empty array if the mesh has no geometry
  34017. */
  34018. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  34019. get isBlocked(): boolean;
  34020. /**
  34021. * Determine if the current mesh is ready to be rendered
  34022. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  34023. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  34024. * @returns true if all associated assets are ready (material, textures, shaders)
  34025. */
  34026. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  34027. /**
  34028. * 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.
  34029. */
  34030. get areNormalsFrozen(): boolean;
  34031. /**
  34032. * 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.
  34033. * @returns the current mesh
  34034. */
  34035. freezeNormals(): Mesh;
  34036. /**
  34037. * 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
  34038. * @returns the current mesh
  34039. */
  34040. unfreezeNormals(): Mesh;
  34041. /**
  34042. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  34043. */
  34044. set overridenInstanceCount(count: number);
  34045. /** @hidden */
  34046. _preActivate(): Mesh;
  34047. /** @hidden */
  34048. _preActivateForIntermediateRendering(renderId: number): Mesh;
  34049. /** @hidden */
  34050. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  34051. protected _afterComputeWorldMatrix(): void;
  34052. /** @hidden */
  34053. _postActivate(): void;
  34054. /**
  34055. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  34056. * This means the mesh underlying bounding box and sphere are recomputed.
  34057. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  34058. * @returns the current mesh
  34059. */
  34060. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  34061. /** @hidden */
  34062. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  34063. /**
  34064. * This function will subdivide the mesh into multiple submeshes
  34065. * @param count defines the expected number of submeshes
  34066. */
  34067. subdivide(count: number): void;
  34068. /**
  34069. * Copy a FloatArray into a specific associated vertex buffer
  34070. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  34071. * - VertexBuffer.PositionKind
  34072. * - VertexBuffer.UVKind
  34073. * - VertexBuffer.UV2Kind
  34074. * - VertexBuffer.UV3Kind
  34075. * - VertexBuffer.UV4Kind
  34076. * - VertexBuffer.UV5Kind
  34077. * - VertexBuffer.UV6Kind
  34078. * - VertexBuffer.ColorKind
  34079. * - VertexBuffer.MatricesIndicesKind
  34080. * - VertexBuffer.MatricesIndicesExtraKind
  34081. * - VertexBuffer.MatricesWeightsKind
  34082. * - VertexBuffer.MatricesWeightsExtraKind
  34083. * @param data defines the data source
  34084. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  34085. * @param stride defines the data stride size (can be null)
  34086. * @returns the current mesh
  34087. */
  34088. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  34089. /**
  34090. * Delete a vertex buffer associated with this mesh
  34091. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  34092. * - VertexBuffer.PositionKind
  34093. * - VertexBuffer.UVKind
  34094. * - VertexBuffer.UV2Kind
  34095. * - VertexBuffer.UV3Kind
  34096. * - VertexBuffer.UV4Kind
  34097. * - VertexBuffer.UV5Kind
  34098. * - VertexBuffer.UV6Kind
  34099. * - VertexBuffer.ColorKind
  34100. * - VertexBuffer.MatricesIndicesKind
  34101. * - VertexBuffer.MatricesIndicesExtraKind
  34102. * - VertexBuffer.MatricesWeightsKind
  34103. * - VertexBuffer.MatricesWeightsExtraKind
  34104. */
  34105. removeVerticesData(kind: string): void;
  34106. /**
  34107. * Flags an associated vertex buffer as updatable
  34108. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  34109. * - VertexBuffer.PositionKind
  34110. * - VertexBuffer.UVKind
  34111. * - VertexBuffer.UV2Kind
  34112. * - VertexBuffer.UV3Kind
  34113. * - VertexBuffer.UV4Kind
  34114. * - VertexBuffer.UV5Kind
  34115. * - VertexBuffer.UV6Kind
  34116. * - VertexBuffer.ColorKind
  34117. * - VertexBuffer.MatricesIndicesKind
  34118. * - VertexBuffer.MatricesIndicesExtraKind
  34119. * - VertexBuffer.MatricesWeightsKind
  34120. * - VertexBuffer.MatricesWeightsExtraKind
  34121. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  34122. */
  34123. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  34124. /**
  34125. * Sets the mesh global Vertex Buffer
  34126. * @param buffer defines the buffer to use
  34127. * @returns the current mesh
  34128. */
  34129. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  34130. /**
  34131. * Update a specific associated vertex buffer
  34132. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  34133. * - VertexBuffer.PositionKind
  34134. * - VertexBuffer.UVKind
  34135. * - VertexBuffer.UV2Kind
  34136. * - VertexBuffer.UV3Kind
  34137. * - VertexBuffer.UV4Kind
  34138. * - VertexBuffer.UV5Kind
  34139. * - VertexBuffer.UV6Kind
  34140. * - VertexBuffer.ColorKind
  34141. * - VertexBuffer.MatricesIndicesKind
  34142. * - VertexBuffer.MatricesIndicesExtraKind
  34143. * - VertexBuffer.MatricesWeightsKind
  34144. * - VertexBuffer.MatricesWeightsExtraKind
  34145. * @param data defines the data source
  34146. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  34147. * @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)
  34148. * @returns the current mesh
  34149. */
  34150. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  34151. /**
  34152. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  34153. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  34154. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  34155. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  34156. * @returns the current mesh
  34157. */
  34158. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  34159. /**
  34160. * Creates a un-shared specific occurence of the geometry for the mesh.
  34161. * @returns the current mesh
  34162. */
  34163. makeGeometryUnique(): Mesh;
  34164. /**
  34165. * Set the index buffer of this mesh
  34166. * @param indices defines the source data
  34167. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  34168. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  34169. * @returns the current mesh
  34170. */
  34171. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  34172. /**
  34173. * Update the current index buffer
  34174. * @param indices defines the source data
  34175. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  34176. * @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)
  34177. * @returns the current mesh
  34178. */
  34179. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  34180. /**
  34181. * Invert the geometry to move from a right handed system to a left handed one.
  34182. * @returns the current mesh
  34183. */
  34184. toLeftHanded(): Mesh;
  34185. /** @hidden */
  34186. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  34187. /** @hidden */
  34188. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  34189. /**
  34190. * Registers for this mesh a javascript function called just before the rendering process
  34191. * @param func defines the function to call before rendering this mesh
  34192. * @returns the current mesh
  34193. */
  34194. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  34195. /**
  34196. * Disposes a previously registered javascript function called before the rendering
  34197. * @param func defines the function to remove
  34198. * @returns the current mesh
  34199. */
  34200. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  34201. /**
  34202. * Registers for this mesh a javascript function called just after the rendering is complete
  34203. * @param func defines the function to call after rendering this mesh
  34204. * @returns the current mesh
  34205. */
  34206. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  34207. /**
  34208. * Disposes a previously registered javascript function called after the rendering.
  34209. * @param func defines the function to remove
  34210. * @returns the current mesh
  34211. */
  34212. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  34213. /** @hidden */
  34214. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  34215. /** @hidden */
  34216. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  34217. /** @hidden */
  34218. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  34219. /** @hidden */
  34220. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  34221. /** @hidden */
  34222. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  34223. /** @hidden */
  34224. _rebuild(): void;
  34225. /** @hidden */
  34226. _freeze(): void;
  34227. /** @hidden */
  34228. _unFreeze(): void;
  34229. /**
  34230. * 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
  34231. * @param subMesh defines the subMesh to render
  34232. * @param enableAlphaMode defines if alpha mode can be changed
  34233. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  34234. * @returns the current mesh
  34235. */
  34236. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  34237. private _onBeforeDraw;
  34238. /**
  34239. * Renormalize the mesh and patch it up if there are no weights
  34240. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  34241. * However in the case of zero weights then we set just a single influence to 1.
  34242. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  34243. */
  34244. cleanMatrixWeights(): void;
  34245. private normalizeSkinFourWeights;
  34246. private normalizeSkinWeightsAndExtra;
  34247. /**
  34248. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  34249. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  34250. * the user know there was an issue with importing the mesh
  34251. * @returns a validation object with skinned, valid and report string
  34252. */
  34253. validateSkinning(): {
  34254. skinned: boolean;
  34255. valid: boolean;
  34256. report: string;
  34257. };
  34258. /** @hidden */
  34259. _checkDelayState(): Mesh;
  34260. private _queueLoad;
  34261. /**
  34262. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  34263. * A mesh is in the frustum if its bounding box intersects the frustum
  34264. * @param frustumPlanes defines the frustum to test
  34265. * @returns true if the mesh is in the frustum planes
  34266. */
  34267. isInFrustum(frustumPlanes: Plane[]): boolean;
  34268. /**
  34269. * Sets the mesh material by the material or multiMaterial `id` property
  34270. * @param id is a string identifying the material or the multiMaterial
  34271. * @returns the current mesh
  34272. */
  34273. setMaterialByID(id: string): Mesh;
  34274. /**
  34275. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  34276. * @returns an array of IAnimatable
  34277. */
  34278. getAnimatables(): IAnimatable[];
  34279. /**
  34280. * Modifies the mesh geometry according to the passed transformation matrix.
  34281. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  34282. * The mesh normals are modified using the same transformation.
  34283. * Note that, under the hood, this method sets a new VertexBuffer each call.
  34284. * @param transform defines the transform matrix to use
  34285. * @see https://doc.babylonjs.com/resources/baking_transformations
  34286. * @returns the current mesh
  34287. */
  34288. bakeTransformIntoVertices(transform: Matrix): Mesh;
  34289. /**
  34290. * Modifies the mesh geometry according to its own current World Matrix.
  34291. * The mesh World Matrix is then reset.
  34292. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  34293. * Note that, under the hood, this method sets a new VertexBuffer each call.
  34294. * @see https://doc.babylonjs.com/resources/baking_transformations
  34295. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  34296. * @returns the current mesh
  34297. */
  34298. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  34299. /** @hidden */
  34300. get _positions(): Nullable<Vector3[]>;
  34301. /** @hidden */
  34302. _resetPointsArrayCache(): Mesh;
  34303. /** @hidden */
  34304. _generatePointsArray(): boolean;
  34305. /**
  34306. * Returns a new Mesh object generated from the current mesh properties.
  34307. * This method must not get confused with createInstance()
  34308. * @param name is a string, the name given to the new mesh
  34309. * @param newParent can be any Node object (default `null`)
  34310. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  34311. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  34312. * @returns a new mesh
  34313. */
  34314. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  34315. /**
  34316. * Releases resources associated with this mesh.
  34317. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  34318. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  34319. */
  34320. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  34321. /** @hidden */
  34322. _disposeInstanceSpecificData(): void;
  34323. /** @hidden */
  34324. _disposeThinInstanceSpecificData(): void;
  34325. /**
  34326. * Modifies the mesh geometry according to a displacement map.
  34327. * 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.
  34328. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  34329. * @param url is a string, the URL from the image file is to be downloaded.
  34330. * @param minHeight is the lower limit of the displacement.
  34331. * @param maxHeight is the upper limit of the displacement.
  34332. * @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.
  34333. * @param uvOffset is an optional vector2 used to offset UV.
  34334. * @param uvScale is an optional vector2 used to scale UV.
  34335. * @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.
  34336. * @returns the Mesh.
  34337. */
  34338. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  34339. /**
  34340. * Modifies the mesh geometry according to a displacementMap buffer.
  34341. * 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.
  34342. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  34343. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  34344. * @param heightMapWidth is the width of the buffer image.
  34345. * @param heightMapHeight is the height of the buffer image.
  34346. * @param minHeight is the lower limit of the displacement.
  34347. * @param maxHeight is the upper limit of the displacement.
  34348. * @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.
  34349. * @param uvOffset is an optional vector2 used to offset UV.
  34350. * @param uvScale is an optional vector2 used to scale UV.
  34351. * @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.
  34352. * @returns the Mesh.
  34353. */
  34354. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  34355. /**
  34356. * Modify the mesh to get a flat shading rendering.
  34357. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  34358. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  34359. * @returns current mesh
  34360. */
  34361. convertToFlatShadedMesh(): Mesh;
  34362. /**
  34363. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  34364. * In other words, more vertices, no more indices and a single bigger VBO.
  34365. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  34366. * @returns current mesh
  34367. */
  34368. convertToUnIndexedMesh(): Mesh;
  34369. /**
  34370. * Inverses facet orientations.
  34371. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34372. * @param flipNormals will also inverts the normals
  34373. * @returns current mesh
  34374. */
  34375. flipFaces(flipNormals?: boolean): Mesh;
  34376. /**
  34377. * Increase the number of facets and hence vertices in a mesh
  34378. * Vertex normals are interpolated from existing vertex normals
  34379. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34380. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  34381. */
  34382. increaseVertices(numberPerEdge: number): void;
  34383. /**
  34384. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  34385. * This will undo any application of covertToFlatShadedMesh
  34386. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34387. */
  34388. forceSharedVertices(): void;
  34389. /** @hidden */
  34390. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  34391. /** @hidden */
  34392. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  34393. /**
  34394. * Creates a new InstancedMesh object from the mesh model.
  34395. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  34396. * @param name defines the name of the new instance
  34397. * @returns a new InstancedMesh
  34398. */
  34399. createInstance(name: string): InstancedMesh;
  34400. /**
  34401. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  34402. * After this call, all the mesh instances have the same submeshes than the current mesh.
  34403. * @returns the current mesh
  34404. */
  34405. synchronizeInstances(): Mesh;
  34406. /**
  34407. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  34408. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  34409. * This should be used together with the simplification to avoid disappearing triangles.
  34410. * @param successCallback an optional success callback to be called after the optimization finished.
  34411. * @returns the current mesh
  34412. */
  34413. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  34414. /**
  34415. * Serialize current mesh
  34416. * @param serializationObject defines the object which will receive the serialization data
  34417. */
  34418. serialize(serializationObject: any): void;
  34419. /** @hidden */
  34420. _syncGeometryWithMorphTargetManager(): void;
  34421. /** @hidden */
  34422. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  34423. /**
  34424. * Returns a new Mesh object parsed from the source provided.
  34425. * @param parsedMesh is the source
  34426. * @param scene defines the hosting scene
  34427. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  34428. * @returns a new Mesh
  34429. */
  34430. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  34431. /**
  34432. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  34433. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34434. * @param name defines the name of the mesh to create
  34435. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  34436. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  34437. * @param closePath creates a seam between the first and the last points of each path of the path array
  34438. * @param offset is taken in account only if the `pathArray` is containing a single path
  34439. * @param scene defines the hosting scene
  34440. * @param updatable defines if the mesh must be flagged as updatable
  34441. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34442. * @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)
  34443. * @returns a new Mesh
  34444. */
  34445. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34446. /**
  34447. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  34448. * @param name defines the name of the mesh to create
  34449. * @param radius sets the radius size (float) of the polygon (default 0.5)
  34450. * @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
  34451. * @param scene defines the hosting scene
  34452. * @param updatable defines if the mesh must be flagged as updatable
  34453. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34454. * @returns a new Mesh
  34455. */
  34456. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  34457. /**
  34458. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  34459. * @param name defines the name of the mesh to create
  34460. * @param size sets the size (float) of each box side (default 1)
  34461. * @param scene defines the hosting scene
  34462. * @param updatable defines if the mesh must be flagged as updatable
  34463. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34464. * @returns a new Mesh
  34465. */
  34466. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  34467. /**
  34468. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  34469. * @param name defines the name of the mesh to create
  34470. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  34471. * @param diameter sets the diameter size (float) of the sphere (default 1)
  34472. * @param scene defines the hosting scene
  34473. * @param updatable defines if the mesh must be flagged as updatable
  34474. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34475. * @returns a new Mesh
  34476. */
  34477. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34478. /**
  34479. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  34480. * @param name defines the name of the mesh to create
  34481. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  34482. * @param diameter sets the diameter size (float) of the sphere (default 1)
  34483. * @param scene defines the hosting scene
  34484. * @returns a new Mesh
  34485. */
  34486. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  34487. /**
  34488. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  34489. * @param name defines the name of the mesh to create
  34490. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  34491. * @param diameterTop set the top cap diameter (floats, default 1)
  34492. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  34493. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  34494. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  34495. * @param scene defines the hosting scene
  34496. * @param updatable defines if the mesh must be flagged as updatable
  34497. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34498. * @returns a new Mesh
  34499. */
  34500. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  34501. /**
  34502. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  34503. * @param name defines the name of the mesh to create
  34504. * @param diameter sets the diameter size (float) of the torus (default 1)
  34505. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  34506. * @param tessellation sets the number of torus sides (positive integer, default 16)
  34507. * @param scene defines the hosting scene
  34508. * @param updatable defines if the mesh must be flagged as updatable
  34509. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34510. * @returns a new Mesh
  34511. */
  34512. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34513. /**
  34514. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  34515. * @param name defines the name of the mesh to create
  34516. * @param radius sets the global radius size (float) of the torus knot (default 2)
  34517. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  34518. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  34519. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  34520. * @param p the number of windings on X axis (positive integers, default 2)
  34521. * @param q the number of windings on Y axis (positive integers, default 3)
  34522. * @param scene defines the hosting scene
  34523. * @param updatable defines if the mesh must be flagged as updatable
  34524. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34525. * @returns a new Mesh
  34526. */
  34527. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34528. /**
  34529. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  34530. * @param name defines the name of the mesh to create
  34531. * @param points is an array successive Vector3
  34532. * @param scene defines the hosting scene
  34533. * @param updatable defines if the mesh must be flagged as updatable
  34534. * @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).
  34535. * @returns a new Mesh
  34536. */
  34537. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  34538. /**
  34539. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  34540. * @param name defines the name of the mesh to create
  34541. * @param points is an array successive Vector3
  34542. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  34543. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  34544. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  34545. * @param scene defines the hosting scene
  34546. * @param updatable defines if the mesh must be flagged as updatable
  34547. * @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)
  34548. * @returns a new Mesh
  34549. */
  34550. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  34551. /**
  34552. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  34553. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  34554. * 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.
  34555. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34556. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  34557. * Remember you can only change the shape positions, not their number when updating a polygon.
  34558. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  34559. * @param name defines the name of the mesh to create
  34560. * @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
  34561. * @param scene defines the hosting scene
  34562. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  34563. * @param updatable defines if the mesh must be flagged as updatable
  34564. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34565. * @param earcutInjection can be used to inject your own earcut reference
  34566. * @returns a new Mesh
  34567. */
  34568. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  34569. /**
  34570. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  34571. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  34572. * @param name defines the name of the mesh to create
  34573. * @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
  34574. * @param depth defines the height of extrusion
  34575. * @param scene defines the hosting scene
  34576. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  34577. * @param updatable defines if the mesh must be flagged as updatable
  34578. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34579. * @param earcutInjection can be used to inject your own earcut reference
  34580. * @returns a new Mesh
  34581. */
  34582. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  34583. /**
  34584. * Creates an extruded shape mesh.
  34585. * 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
  34586. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34587. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  34588. * @param name defines the name of the mesh to create
  34589. * @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
  34590. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  34591. * @param scale is the value to scale the shape
  34592. * @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
  34593. * @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
  34594. * @param scene defines the hosting scene
  34595. * @param updatable defines if the mesh must be flagged as updatable
  34596. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34597. * @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)
  34598. * @returns a new Mesh
  34599. */
  34600. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34601. /**
  34602. * Creates an custom extruded shape mesh.
  34603. * The custom extrusion is a parametric shape.
  34604. * It has no predefined shape. Its final shape will depend on the input parameters.
  34605. * Please consider using the same method from the MeshBuilder class instead
  34606. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  34607. * @param name defines the name of the mesh to create
  34608. * @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
  34609. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  34610. * @param scaleFunction is a custom Javascript function called on each path point
  34611. * @param rotationFunction is a custom Javascript function called on each path point
  34612. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  34613. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  34614. * @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
  34615. * @param scene defines the hosting scene
  34616. * @param updatable defines if the mesh must be flagged as updatable
  34617. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34618. * @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)
  34619. * @returns a new Mesh
  34620. */
  34621. 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;
  34622. /**
  34623. * Creates lathe mesh.
  34624. * The lathe is a shape with a symmetry axis : a 2D model shape is rotated around this axis to design the lathe.
  34625. * Please consider using the same method from the MeshBuilder class instead
  34626. * @param name defines the name of the mesh to create
  34627. * @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
  34628. * @param radius is the radius value of the lathe
  34629. * @param tessellation is the side number of the lathe.
  34630. * @param scene defines the hosting scene
  34631. * @param updatable defines if the mesh must be flagged as updatable
  34632. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34633. * @returns a new Mesh
  34634. */
  34635. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34636. /**
  34637. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  34638. * @param name defines the name of the mesh to create
  34639. * @param size sets the size (float) of both sides of the plane at once (default 1)
  34640. * @param scene defines the hosting scene
  34641. * @param updatable defines if the mesh must be flagged as updatable
  34642. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34643. * @returns a new Mesh
  34644. */
  34645. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34646. /**
  34647. * Creates a ground mesh.
  34648. * Please consider using the same method from the MeshBuilder class instead
  34649. * @param name defines the name of the mesh to create
  34650. * @param width set the width of the ground
  34651. * @param height set the height of the ground
  34652. * @param subdivisions sets the number of subdivisions per side
  34653. * @param scene defines the hosting scene
  34654. * @param updatable defines if the mesh must be flagged as updatable
  34655. * @returns a new Mesh
  34656. */
  34657. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  34658. /**
  34659. * Creates a tiled ground mesh.
  34660. * Please consider using the same method from the MeshBuilder class instead
  34661. * @param name defines the name of the mesh to create
  34662. * @param xmin set the ground minimum X coordinate
  34663. * @param zmin set the ground minimum Y coordinate
  34664. * @param xmax set the ground maximum X coordinate
  34665. * @param zmax set the ground maximum Z coordinate
  34666. * @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
  34667. * @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
  34668. * @param scene defines the hosting scene
  34669. * @param updatable defines if the mesh must be flagged as updatable
  34670. * @returns a new Mesh
  34671. */
  34672. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  34673. w: number;
  34674. h: number;
  34675. }, precision: {
  34676. w: number;
  34677. h: number;
  34678. }, scene: Scene, updatable?: boolean): Mesh;
  34679. /**
  34680. * Creates a ground mesh from a height map.
  34681. * Please consider using the same method from the MeshBuilder class instead
  34682. * @see https://doc.babylonjs.com/babylon101/height_map
  34683. * @param name defines the name of the mesh to create
  34684. * @param url sets the URL of the height map image resource
  34685. * @param width set the ground width size
  34686. * @param height set the ground height size
  34687. * @param subdivisions sets the number of subdivision per side
  34688. * @param minHeight is the minimum altitude on the ground
  34689. * @param maxHeight is the maximum altitude on the ground
  34690. * @param scene defines the hosting scene
  34691. * @param updatable defines if the mesh must be flagged as updatable
  34692. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  34693. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  34694. * @returns a new Mesh
  34695. */
  34696. 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;
  34697. /**
  34698. * Creates a tube mesh.
  34699. * The tube is a parametric shape.
  34700. * It has no predefined shape. Its final shape will depend on the input parameters.
  34701. * Please consider using the same method from the MeshBuilder class instead
  34702. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34703. * @param name defines the name of the mesh to create
  34704. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  34705. * @param radius sets the tube radius size
  34706. * @param tessellation is the number of sides on the tubular surface
  34707. * @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
  34708. * @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
  34709. * @param scene defines the hosting scene
  34710. * @param updatable defines if the mesh must be flagged as updatable
  34711. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34712. * @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)
  34713. * @returns a new Mesh
  34714. */
  34715. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  34716. (i: number, distance: number): number;
  34717. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34718. /**
  34719. * Creates a polyhedron mesh.
  34720. * Please consider using the same method from the MeshBuilder class instead.
  34721. * * 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
  34722. * * The parameter `size` (positive float, default 1) sets the polygon size
  34723. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  34724. * * 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`
  34725. * * 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
  34726. * * 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)`)
  34727. * * 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
  34728. * * 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
  34729. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34730. * * 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
  34731. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34732. * @param name defines the name of the mesh to create
  34733. * @param options defines the options used to create the mesh
  34734. * @param scene defines the hosting scene
  34735. * @returns a new Mesh
  34736. */
  34737. static CreatePolyhedron(name: string, options: {
  34738. type?: number;
  34739. size?: number;
  34740. sizeX?: number;
  34741. sizeY?: number;
  34742. sizeZ?: number;
  34743. custom?: any;
  34744. faceUV?: Vector4[];
  34745. faceColors?: Color4[];
  34746. updatable?: boolean;
  34747. sideOrientation?: number;
  34748. }, scene: Scene): Mesh;
  34749. /**
  34750. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  34751. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  34752. * * 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`)
  34753. * * The parameter `subdivisions` sets the number of subdivisions (positive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  34754. * * 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
  34755. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34756. * * 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
  34757. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34758. * @param name defines the name of the mesh
  34759. * @param options defines the options used to create the mesh
  34760. * @param scene defines the hosting scene
  34761. * @returns a new Mesh
  34762. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  34763. */
  34764. static CreateIcoSphere(name: string, options: {
  34765. radius?: number;
  34766. flat?: boolean;
  34767. subdivisions?: number;
  34768. sideOrientation?: number;
  34769. updatable?: boolean;
  34770. }, scene: Scene): Mesh;
  34771. /**
  34772. * Creates a decal mesh.
  34773. * Please consider using the same method from the MeshBuilder class instead.
  34774. * A decal is a mesh usually applied as a model onto the surface of another mesh
  34775. * @param name defines the name of the mesh
  34776. * @param sourceMesh defines the mesh receiving the decal
  34777. * @param position sets the position of the decal in world coordinates
  34778. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  34779. * @param size sets the decal scaling
  34780. * @param angle sets the angle to rotate the decal
  34781. * @returns a new Mesh
  34782. */
  34783. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  34784. /** Creates a Capsule Mesh
  34785. * @param name defines the name of the mesh.
  34786. * @param options the constructors options used to shape the mesh.
  34787. * @param scene defines the scene the mesh is scoped to.
  34788. * @returns the capsule mesh
  34789. * @see https://doc.babylonjs.com/how_to/capsule_shape
  34790. */
  34791. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  34792. /**
  34793. * Prepare internal position array for software CPU skinning
  34794. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  34795. */
  34796. setPositionsForCPUSkinning(): Float32Array;
  34797. /**
  34798. * Prepare internal normal array for software CPU skinning
  34799. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  34800. */
  34801. setNormalsForCPUSkinning(): Float32Array;
  34802. /**
  34803. * Updates the vertex buffer by applying transformation from the bones
  34804. * @param skeleton defines the skeleton to apply to current mesh
  34805. * @returns the current mesh
  34806. */
  34807. applySkeleton(skeleton: Skeleton): Mesh;
  34808. /**
  34809. * 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
  34810. * @param meshes defines the list of meshes to scan
  34811. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  34812. */
  34813. static MinMax(meshes: AbstractMesh[]): {
  34814. min: Vector3;
  34815. max: Vector3;
  34816. };
  34817. /**
  34818. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  34819. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  34820. * @returns a vector3
  34821. */
  34822. static Center(meshesOrMinMaxVector: {
  34823. min: Vector3;
  34824. max: Vector3;
  34825. } | AbstractMesh[]): Vector3;
  34826. /**
  34827. * Merge the array of meshes into a single mesh for performance reasons.
  34828. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  34829. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  34830. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  34831. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  34832. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  34833. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  34834. * @returns a new mesh
  34835. */
  34836. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  34837. /** @hidden */
  34838. addInstance(instance: InstancedMesh): void;
  34839. /** @hidden */
  34840. removeInstance(instance: InstancedMesh): void;
  34841. }
  34842. }
  34843. declare module BABYLON {
  34844. /**
  34845. * The options Interface for creating a Capsule Mesh
  34846. */
  34847. export interface ICreateCapsuleOptions {
  34848. /** The Orientation of the capsule. Default : Vector3.Up() */
  34849. orientation?: Vector3;
  34850. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  34851. subdivisions: number;
  34852. /** Number of cylindrical segments on the capsule. */
  34853. tessellation: number;
  34854. /** Height or Length of the capsule. */
  34855. height: number;
  34856. /** Radius of the capsule. */
  34857. radius: number;
  34858. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  34859. capSubdivisions: number;
  34860. /** Overwrite for the top radius. */
  34861. radiusTop?: number;
  34862. /** Overwrite for the bottom radius. */
  34863. radiusBottom?: number;
  34864. /** Overwrite for the top capSubdivisions. */
  34865. topCapSubdivisions?: number;
  34866. /** Overwrite for the bottom capSubdivisions. */
  34867. bottomCapSubdivisions?: number;
  34868. /** Internal geometry is supposed to change once created. */
  34869. updatable?: boolean;
  34870. }
  34871. /**
  34872. * Class containing static functions to help procedurally build meshes
  34873. */
  34874. export class CapsuleBuilder {
  34875. /**
  34876. * Creates a capsule or a pill mesh
  34877. * @param name defines the name of the mesh
  34878. * @param options The constructors options.
  34879. * @param scene The scene the mesh is scoped to.
  34880. * @returns Capsule Mesh
  34881. */
  34882. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  34883. }
  34884. }
  34885. declare module BABYLON {
  34886. /**
  34887. * Define an interface for all classes that will get and set the data on vertices
  34888. */
  34889. export interface IGetSetVerticesData {
  34890. /**
  34891. * Gets a boolean indicating if specific vertex data is present
  34892. * @param kind defines the vertex data kind to use
  34893. * @returns true is data kind is present
  34894. */
  34895. isVerticesDataPresent(kind: string): boolean;
  34896. /**
  34897. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  34898. * @param kind defines the data kind (Position, normal, etc...)
  34899. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  34900. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  34901. * @returns a float array containing vertex data
  34902. */
  34903. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  34904. /**
  34905. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  34906. * @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.
  34907. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  34908. * @returns the indices array or an empty array if the mesh has no geometry
  34909. */
  34910. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  34911. /**
  34912. * Set specific vertex data
  34913. * @param kind defines the data kind (Position, normal, etc...)
  34914. * @param data defines the vertex data to use
  34915. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  34916. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  34917. */
  34918. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  34919. /**
  34920. * Update a specific associated vertex buffer
  34921. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  34922. * - VertexBuffer.PositionKind
  34923. * - VertexBuffer.UVKind
  34924. * - VertexBuffer.UV2Kind
  34925. * - VertexBuffer.UV3Kind
  34926. * - VertexBuffer.UV4Kind
  34927. * - VertexBuffer.UV5Kind
  34928. * - VertexBuffer.UV6Kind
  34929. * - VertexBuffer.ColorKind
  34930. * - VertexBuffer.MatricesIndicesKind
  34931. * - VertexBuffer.MatricesIndicesExtraKind
  34932. * - VertexBuffer.MatricesWeightsKind
  34933. * - VertexBuffer.MatricesWeightsExtraKind
  34934. * @param data defines the data source
  34935. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  34936. * @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)
  34937. */
  34938. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  34939. /**
  34940. * Creates a new index buffer
  34941. * @param indices defines the indices to store in the index buffer
  34942. * @param totalVertices defines the total number of vertices (could be null)
  34943. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  34944. */
  34945. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  34946. }
  34947. /**
  34948. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  34949. */
  34950. export class VertexData {
  34951. /**
  34952. * Mesh side orientation : usually the external or front surface
  34953. */
  34954. static readonly FRONTSIDE: number;
  34955. /**
  34956. * Mesh side orientation : usually the internal or back surface
  34957. */
  34958. static readonly BACKSIDE: number;
  34959. /**
  34960. * Mesh side orientation : both internal and external or front and back surfaces
  34961. */
  34962. static readonly DOUBLESIDE: number;
  34963. /**
  34964. * Mesh side orientation : by default, `FRONTSIDE`
  34965. */
  34966. static readonly DEFAULTSIDE: number;
  34967. /**
  34968. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  34969. */
  34970. positions: Nullable<FloatArray>;
  34971. /**
  34972. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  34973. */
  34974. normals: Nullable<FloatArray>;
  34975. /**
  34976. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  34977. */
  34978. tangents: Nullable<FloatArray>;
  34979. /**
  34980. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34981. */
  34982. uvs: Nullable<FloatArray>;
  34983. /**
  34984. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34985. */
  34986. uvs2: Nullable<FloatArray>;
  34987. /**
  34988. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34989. */
  34990. uvs3: Nullable<FloatArray>;
  34991. /**
  34992. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34993. */
  34994. uvs4: Nullable<FloatArray>;
  34995. /**
  34996. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34997. */
  34998. uvs5: Nullable<FloatArray>;
  34999. /**
  35000. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  35001. */
  35002. uvs6: Nullable<FloatArray>;
  35003. /**
  35004. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  35005. */
  35006. colors: Nullable<FloatArray>;
  35007. /**
  35008. * 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).
  35009. */
  35010. matricesIndices: Nullable<FloatArray>;
  35011. /**
  35012. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  35013. */
  35014. matricesWeights: Nullable<FloatArray>;
  35015. /**
  35016. * An array extending the number of possible indices
  35017. */
  35018. matricesIndicesExtra: Nullable<FloatArray>;
  35019. /**
  35020. * An array extending the number of possible weights when the number of indices is extended
  35021. */
  35022. matricesWeightsExtra: Nullable<FloatArray>;
  35023. /**
  35024. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  35025. */
  35026. indices: Nullable<IndicesArray>;
  35027. /**
  35028. * Uses the passed data array to set the set the values for the specified kind of data
  35029. * @param data a linear array of floating numbers
  35030. * @param kind the type of data that is being set, eg positions, colors etc
  35031. */
  35032. set(data: FloatArray, kind: string): void;
  35033. /**
  35034. * Associates the vertexData to the passed Mesh.
  35035. * Sets it as updatable or not (default `false`)
  35036. * @param mesh the mesh the vertexData is applied to
  35037. * @param updatable when used and having the value true allows new data to update the vertexData
  35038. * @returns the VertexData
  35039. */
  35040. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  35041. /**
  35042. * Associates the vertexData to the passed Geometry.
  35043. * Sets it as updatable or not (default `false`)
  35044. * @param geometry the geometry the vertexData is applied to
  35045. * @param updatable when used and having the value true allows new data to update the vertexData
  35046. * @returns VertexData
  35047. */
  35048. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  35049. /**
  35050. * Updates the associated mesh
  35051. * @param mesh the mesh to be updated
  35052. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  35053. * @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
  35054. * @returns VertexData
  35055. */
  35056. updateMesh(mesh: Mesh): VertexData;
  35057. /**
  35058. * Updates the associated geometry
  35059. * @param geometry the geometry to be updated
  35060. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  35061. * @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
  35062. * @returns VertexData.
  35063. */
  35064. updateGeometry(geometry: Geometry): VertexData;
  35065. private _applyTo;
  35066. private _update;
  35067. /**
  35068. * Transforms each position and each normal of the vertexData according to the passed Matrix
  35069. * @param matrix the transforming matrix
  35070. * @returns the VertexData
  35071. */
  35072. transform(matrix: Matrix): VertexData;
  35073. /**
  35074. * Merges the passed VertexData into the current one
  35075. * @param other the VertexData to be merged into the current one
  35076. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  35077. * @returns the modified VertexData
  35078. */
  35079. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  35080. private _mergeElement;
  35081. private _validate;
  35082. /**
  35083. * Serializes the VertexData
  35084. * @returns a serialized object
  35085. */
  35086. serialize(): any;
  35087. /**
  35088. * Extracts the vertexData from a mesh
  35089. * @param mesh the mesh from which to extract the VertexData
  35090. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  35091. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  35092. * @returns the object VertexData associated to the passed mesh
  35093. */
  35094. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  35095. /**
  35096. * Extracts the vertexData from the geometry
  35097. * @param geometry the geometry from which to extract the VertexData
  35098. * @param copyWhenShared defines if the VertexData must be cloned when the geometry is shared between multiple meshes, optional, default false
  35099. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  35100. * @returns the object VertexData associated to the passed mesh
  35101. */
  35102. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  35103. private static _ExtractFrom;
  35104. /**
  35105. * Creates the VertexData for a Ribbon
  35106. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  35107. * * pathArray array of paths, each of which an array of successive Vector3
  35108. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  35109. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  35110. * * 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
  35111. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35112. * * 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)
  35113. * * 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)
  35114. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  35115. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  35116. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  35117. * @returns the VertexData of the ribbon
  35118. */
  35119. static CreateRibbon(options: {
  35120. pathArray: Vector3[][];
  35121. closeArray?: boolean;
  35122. closePath?: boolean;
  35123. offset?: number;
  35124. sideOrientation?: number;
  35125. frontUVs?: Vector4;
  35126. backUVs?: Vector4;
  35127. invertUV?: boolean;
  35128. uvs?: Vector2[];
  35129. colors?: Color4[];
  35130. }): VertexData;
  35131. /**
  35132. * Creates the VertexData for a box
  35133. * @param options an object used to set the following optional parameters for the box, required but can be empty
  35134. * * size sets the width, height and depth of the box to the value of size, optional default 1
  35135. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  35136. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  35137. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  35138. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  35139. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  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 box
  35144. */
  35145. static CreateBox(options: {
  35146. size?: number;
  35147. width?: number;
  35148. height?: number;
  35149. depth?: number;
  35150. faceUV?: Vector4[];
  35151. faceColors?: Color4[];
  35152. sideOrientation?: number;
  35153. frontUVs?: Vector4;
  35154. backUVs?: Vector4;
  35155. }): VertexData;
  35156. /**
  35157. * Creates the VertexData for a tiled box
  35158. * @param options an object used to set the following optional parameters for the box, required but can be empty
  35159. * * faceTiles sets the pattern, tile size and number of tiles for a face
  35160. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  35161. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  35162. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35163. * @returns the VertexData of the box
  35164. */
  35165. static CreateTiledBox(options: {
  35166. pattern?: number;
  35167. width?: number;
  35168. height?: number;
  35169. depth?: number;
  35170. tileSize?: number;
  35171. tileWidth?: number;
  35172. tileHeight?: number;
  35173. alignHorizontal?: number;
  35174. alignVertical?: number;
  35175. faceUV?: Vector4[];
  35176. faceColors?: Color4[];
  35177. sideOrientation?: number;
  35178. }): VertexData;
  35179. /**
  35180. * Creates the VertexData for a tiled plane
  35181. * @param options an object used to set the following optional parameters for the box, required but can be empty
  35182. * * pattern a limited pattern arrangement depending on the number
  35183. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  35184. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  35185. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  35186. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35187. * * 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)
  35188. * * 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)
  35189. * @returns the VertexData of the tiled plane
  35190. */
  35191. static CreateTiledPlane(options: {
  35192. pattern?: number;
  35193. tileSize?: number;
  35194. tileWidth?: number;
  35195. tileHeight?: number;
  35196. size?: number;
  35197. width?: number;
  35198. height?: number;
  35199. alignHorizontal?: number;
  35200. alignVertical?: number;
  35201. sideOrientation?: number;
  35202. frontUVs?: Vector4;
  35203. backUVs?: Vector4;
  35204. }): VertexData;
  35205. /**
  35206. * Creates the VertexData for an ellipsoid, defaults to a sphere
  35207. * @param options an object used to set the following optional parameters for the box, required but can be empty
  35208. * * segments sets the number of horizontal strips optional, default 32
  35209. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  35210. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  35211. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  35212. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  35213. * * 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
  35214. * * 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
  35215. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35216. * * 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)
  35217. * * 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)
  35218. * @returns the VertexData of the ellipsoid
  35219. */
  35220. static CreateSphere(options: {
  35221. segments?: number;
  35222. diameter?: number;
  35223. diameterX?: number;
  35224. diameterY?: number;
  35225. diameterZ?: number;
  35226. arc?: number;
  35227. slice?: number;
  35228. sideOrientation?: number;
  35229. frontUVs?: Vector4;
  35230. backUVs?: Vector4;
  35231. }): VertexData;
  35232. /**
  35233. * Creates the VertexData for a cylinder, cone or prism
  35234. * @param options an object used to set the following optional parameters for the box, required but can be empty
  35235. * * height sets the height (y direction) of the cylinder, optional, default 2
  35236. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  35237. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  35238. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  35239. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  35240. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  35241. * * 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
  35242. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  35243. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  35244. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  35245. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  35246. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35247. * * 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)
  35248. * * 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)
  35249. * @returns the VertexData of the cylinder, cone or prism
  35250. */
  35251. static CreateCylinder(options: {
  35252. height?: number;
  35253. diameterTop?: number;
  35254. diameterBottom?: number;
  35255. diameter?: number;
  35256. tessellation?: number;
  35257. subdivisions?: number;
  35258. arc?: number;
  35259. faceColors?: Color4[];
  35260. faceUV?: Vector4[];
  35261. hasRings?: boolean;
  35262. enclose?: boolean;
  35263. sideOrientation?: number;
  35264. frontUVs?: Vector4;
  35265. backUVs?: Vector4;
  35266. }): VertexData;
  35267. /**
  35268. * Creates the VertexData for a torus
  35269. * @param options an object used to set the following optional parameters for the box, required but can be empty
  35270. * * diameter the diameter of the torus, optional default 1
  35271. * * thickness the diameter of the tube forming the torus, optional default 0.5
  35272. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  35273. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35274. * * 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)
  35275. * * 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)
  35276. * @returns the VertexData of the torus
  35277. */
  35278. static CreateTorus(options: {
  35279. diameter?: number;
  35280. thickness?: number;
  35281. tessellation?: number;
  35282. sideOrientation?: number;
  35283. frontUVs?: Vector4;
  35284. backUVs?: Vector4;
  35285. }): VertexData;
  35286. /**
  35287. * Creates the VertexData of the LineSystem
  35288. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  35289. * - lines an array of lines, each line being an array of successive Vector3
  35290. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  35291. * @returns the VertexData of the LineSystem
  35292. */
  35293. static CreateLineSystem(options: {
  35294. lines: Vector3[][];
  35295. colors?: Nullable<Color4[][]>;
  35296. }): VertexData;
  35297. /**
  35298. * Create the VertexData for a DashedLines
  35299. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  35300. * - points an array successive Vector3
  35301. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  35302. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  35303. * - dashNb the intended total number of dashes, optional, default 200
  35304. * @returns the VertexData for the DashedLines
  35305. */
  35306. static CreateDashedLines(options: {
  35307. points: Vector3[];
  35308. dashSize?: number;
  35309. gapSize?: number;
  35310. dashNb?: number;
  35311. }): VertexData;
  35312. /**
  35313. * Creates the VertexData for a Ground
  35314. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  35315. * - width the width (x direction) of the ground, optional, default 1
  35316. * - height the height (z direction) of the ground, optional, default 1
  35317. * - subdivisions the number of subdivisions per side, optional, default 1
  35318. * @returns the VertexData of the Ground
  35319. */
  35320. static CreateGround(options: {
  35321. width?: number;
  35322. height?: number;
  35323. subdivisions?: number;
  35324. subdivisionsX?: number;
  35325. subdivisionsY?: number;
  35326. }): VertexData;
  35327. /**
  35328. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  35329. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  35330. * * xmin the ground minimum X coordinate, optional, default -1
  35331. * * zmin the ground minimum Z coordinate, optional, default -1
  35332. * * xmax the ground maximum X coordinate, optional, default 1
  35333. * * zmax the ground maximum Z coordinate, optional, default 1
  35334. * * 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}
  35335. * * 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}
  35336. * @returns the VertexData of the TiledGround
  35337. */
  35338. static CreateTiledGround(options: {
  35339. xmin: number;
  35340. zmin: number;
  35341. xmax: number;
  35342. zmax: number;
  35343. subdivisions?: {
  35344. w: number;
  35345. h: number;
  35346. };
  35347. precision?: {
  35348. w: number;
  35349. h: number;
  35350. };
  35351. }): VertexData;
  35352. /**
  35353. * Creates the VertexData of the Ground designed from a heightmap
  35354. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  35355. * * width the width (x direction) of the ground
  35356. * * height the height (z direction) of the ground
  35357. * * subdivisions the number of subdivisions per side
  35358. * * minHeight the minimum altitude on the ground, optional, default 0
  35359. * * maxHeight the maximum altitude on the ground, optional default 1
  35360. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  35361. * * buffer the array holding the image color data
  35362. * * bufferWidth the width of image
  35363. * * bufferHeight the height of image
  35364. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  35365. * @returns the VertexData of the Ground designed from a heightmap
  35366. */
  35367. static CreateGroundFromHeightMap(options: {
  35368. width: number;
  35369. height: number;
  35370. subdivisions: number;
  35371. minHeight: number;
  35372. maxHeight: number;
  35373. colorFilter: Color3;
  35374. buffer: Uint8Array;
  35375. bufferWidth: number;
  35376. bufferHeight: number;
  35377. alphaFilter: number;
  35378. }): VertexData;
  35379. /**
  35380. * Creates the VertexData for a Plane
  35381. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  35382. * * size sets the width and height of the plane to the value of size, optional default 1
  35383. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  35384. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  35385. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35386. * * 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)
  35387. * * 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)
  35388. * @returns the VertexData of the box
  35389. */
  35390. static CreatePlane(options: {
  35391. size?: number;
  35392. width?: number;
  35393. height?: number;
  35394. sideOrientation?: number;
  35395. frontUVs?: Vector4;
  35396. backUVs?: Vector4;
  35397. }): VertexData;
  35398. /**
  35399. * Creates the VertexData of the Disc or regular Polygon
  35400. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  35401. * * radius the radius of the disc, optional default 0.5
  35402. * * tessellation the number of polygon sides, optional, default 64
  35403. * * 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
  35404. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35405. * * 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)
  35406. * * 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)
  35407. * @returns the VertexData of the box
  35408. */
  35409. static CreateDisc(options: {
  35410. radius?: number;
  35411. tessellation?: number;
  35412. arc?: number;
  35413. sideOrientation?: number;
  35414. frontUVs?: Vector4;
  35415. backUVs?: Vector4;
  35416. }): VertexData;
  35417. /**
  35418. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  35419. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  35420. * @param polygon a mesh built from polygonTriangulation.build()
  35421. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35422. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  35423. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  35424. * @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)
  35425. * @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)
  35426. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  35427. * @returns the VertexData of the Polygon
  35428. */
  35429. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  35430. /**
  35431. * Creates the VertexData of the IcoSphere
  35432. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  35433. * * radius the radius of the IcoSphere, optional default 1
  35434. * * radiusX allows stretching in the x direction, optional, default radius
  35435. * * radiusY allows stretching in the y direction, optional, default radius
  35436. * * radiusZ allows stretching in the z direction, optional, default radius
  35437. * * flat when true creates a flat shaded mesh, optional, default true
  35438. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  35439. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35440. * * 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)
  35441. * * 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)
  35442. * @returns the VertexData of the IcoSphere
  35443. */
  35444. static CreateIcoSphere(options: {
  35445. radius?: number;
  35446. radiusX?: number;
  35447. radiusY?: number;
  35448. radiusZ?: number;
  35449. flat?: boolean;
  35450. subdivisions?: number;
  35451. sideOrientation?: number;
  35452. frontUVs?: Vector4;
  35453. backUVs?: Vector4;
  35454. }): VertexData;
  35455. /**
  35456. * Creates the VertexData for a Polyhedron
  35457. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  35458. * * type provided types are:
  35459. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  35460. * * 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)
  35461. * * size the size of the IcoSphere, optional default 1
  35462. * * sizeX allows stretching in the x direction, optional, default size
  35463. * * sizeY allows stretching in the y direction, optional, default size
  35464. * * sizeZ allows stretching in the z direction, optional, default size
  35465. * * 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
  35466. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  35467. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  35468. * * flat when true creates a flat shaded mesh, optional, default true
  35469. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  35470. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35471. * * 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)
  35472. * * 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)
  35473. * @returns the VertexData of the Polyhedron
  35474. */
  35475. static CreatePolyhedron(options: {
  35476. type?: number;
  35477. size?: number;
  35478. sizeX?: number;
  35479. sizeY?: number;
  35480. sizeZ?: number;
  35481. custom?: any;
  35482. faceUV?: Vector4[];
  35483. faceColors?: Color4[];
  35484. flat?: boolean;
  35485. sideOrientation?: number;
  35486. frontUVs?: Vector4;
  35487. backUVs?: Vector4;
  35488. }): VertexData;
  35489. /**
  35490. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  35491. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  35492. * @returns the VertexData of the Capsule
  35493. */
  35494. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  35495. /**
  35496. * Creates the VertexData for a TorusKnot
  35497. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  35498. * * radius the radius of the torus knot, optional, default 2
  35499. * * tube the thickness of the tube, optional, default 0.5
  35500. * * radialSegments the number of sides on each tube segments, optional, default 32
  35501. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  35502. * * p the number of windings around the z axis, optional, default 2
  35503. * * q the number of windings around the x axis, optional, default 3
  35504. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35505. * * 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)
  35506. * * 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)
  35507. * @returns the VertexData of the Torus Knot
  35508. */
  35509. static CreateTorusKnot(options: {
  35510. radius?: number;
  35511. tube?: number;
  35512. radialSegments?: number;
  35513. tubularSegments?: number;
  35514. p?: number;
  35515. q?: number;
  35516. sideOrientation?: number;
  35517. frontUVs?: Vector4;
  35518. backUVs?: Vector4;
  35519. }): VertexData;
  35520. /**
  35521. * Compute normals for given positions and indices
  35522. * @param positions an array of vertex positions, [...., x, y, z, ......]
  35523. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  35524. * @param normals an array of vertex normals, [...., x, y, z, ......]
  35525. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  35526. * * facetNormals : optional array of facet normals (vector3)
  35527. * * facetPositions : optional array of facet positions (vector3)
  35528. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  35529. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  35530. * * bInfo : optional bounding info, required for facetPartitioning computation
  35531. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  35532. * * subDiv : optional partitioning data about subdivisions on each axis (int), required for facetPartitioning computation
  35533. * * useRightHandedSystem: optional boolean to for right handed system computation
  35534. * * depthSort : optional boolean to enable the facet depth sort computation
  35535. * * distanceTo : optional Vector3 to compute the facet depth from this location
  35536. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  35537. */
  35538. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  35539. facetNormals?: any;
  35540. facetPositions?: any;
  35541. facetPartitioning?: any;
  35542. ratio?: number;
  35543. bInfo?: any;
  35544. bbSize?: Vector3;
  35545. subDiv?: any;
  35546. useRightHandedSystem?: boolean;
  35547. depthSort?: boolean;
  35548. distanceTo?: Vector3;
  35549. depthSortedFacets?: any;
  35550. }): void;
  35551. /** @hidden */
  35552. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  35553. /**
  35554. * Applies VertexData created from the imported parameters to the geometry
  35555. * @param parsedVertexData the parsed data from an imported file
  35556. * @param geometry the geometry to apply the VertexData to
  35557. */
  35558. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  35559. }
  35560. }
  35561. declare module BABYLON {
  35562. /**
  35563. * Class containing static functions to help procedurally build meshes
  35564. */
  35565. export class DiscBuilder {
  35566. /**
  35567. * Creates a plane polygonal mesh. By default, this is a disc
  35568. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  35569. * * 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
  35570. * * 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
  35571. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35572. * * 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
  35573. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35574. * @param name defines the name of the mesh
  35575. * @param options defines the options used to create the mesh
  35576. * @param scene defines the hosting scene
  35577. * @returns the plane polygonal mesh
  35578. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  35579. */
  35580. static CreateDisc(name: string, options: {
  35581. radius?: number;
  35582. tessellation?: number;
  35583. arc?: number;
  35584. updatable?: boolean;
  35585. sideOrientation?: number;
  35586. frontUVs?: Vector4;
  35587. backUVs?: Vector4;
  35588. }, scene?: Nullable<Scene>): Mesh;
  35589. }
  35590. }
  35591. declare module BABYLON {
  35592. /**
  35593. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  35594. *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.
  35595. * The SPS is also a particle system. It provides some methods to manage the particles.
  35596. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  35597. *
  35598. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  35599. */
  35600. export class SolidParticleSystem implements IDisposable {
  35601. /**
  35602. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  35603. * Example : var p = SPS.particles[i];
  35604. */
  35605. particles: SolidParticle[];
  35606. /**
  35607. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  35608. */
  35609. nbParticles: number;
  35610. /**
  35611. * If the particles must ever face the camera (default false). Useful for planar particles.
  35612. */
  35613. billboard: boolean;
  35614. /**
  35615. * Recompute normals when adding a shape
  35616. */
  35617. recomputeNormals: boolean;
  35618. /**
  35619. * This a counter ofr your own usage. It's not set by any SPS functions.
  35620. */
  35621. counter: number;
  35622. /**
  35623. * The SPS name. This name is also given to the underlying mesh.
  35624. */
  35625. name: string;
  35626. /**
  35627. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are available.
  35628. */
  35629. mesh: Mesh;
  35630. /**
  35631. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  35632. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  35633. */
  35634. vars: any;
  35635. /**
  35636. * This array is populated when the SPS is set as 'pickable'.
  35637. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  35638. * Each element of this array is an object `{idx: int, faceId: int}`.
  35639. * `idx` is the picked particle index in the `SPS.particles` array
  35640. * `faceId` is the picked face index counted within this particle.
  35641. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  35642. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  35643. * Use the method SPS.pickedParticle(pickingInfo) instead.
  35644. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  35645. */
  35646. pickedParticles: {
  35647. idx: number;
  35648. faceId: number;
  35649. }[];
  35650. /**
  35651. * This array is populated when the SPS is set as 'pickable'
  35652. * Each key of this array is a submesh index.
  35653. * Each element of this array is a second array defined like this :
  35654. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  35655. * Each element of this second array is an object `{idx: int, faceId: int}`.
  35656. * `idx` is the picked particle index in the `SPS.particles` array
  35657. * `faceId` is the picked face index counted within this particle.
  35658. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  35659. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  35660. */
  35661. pickedBySubMesh: {
  35662. idx: number;
  35663. faceId: number;
  35664. }[][];
  35665. /**
  35666. * This array is populated when `enableDepthSort` is set to true.
  35667. * Each element of this array is an instance of the class DepthSortedParticle.
  35668. */
  35669. depthSortedParticles: DepthSortedParticle[];
  35670. /**
  35671. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  35672. * @hidden
  35673. */
  35674. _bSphereOnly: boolean;
  35675. /**
  35676. * A number to multiply the bounding sphere radius by in order to reduce it for instance. (Internal use only)
  35677. * @hidden
  35678. */
  35679. _bSphereRadiusFactor: number;
  35680. private _scene;
  35681. private _positions;
  35682. private _indices;
  35683. private _normals;
  35684. private _colors;
  35685. private _uvs;
  35686. private _indices32;
  35687. private _positions32;
  35688. private _normals32;
  35689. private _fixedNormal32;
  35690. private _colors32;
  35691. private _uvs32;
  35692. private _index;
  35693. private _updatable;
  35694. private _pickable;
  35695. private _isVisibilityBoxLocked;
  35696. private _alwaysVisible;
  35697. private _depthSort;
  35698. private _expandable;
  35699. private _shapeCounter;
  35700. private _copy;
  35701. private _color;
  35702. private _computeParticleColor;
  35703. private _computeParticleTexture;
  35704. private _computeParticleRotation;
  35705. private _computeParticleVertex;
  35706. private _computeBoundingBox;
  35707. private _depthSortParticles;
  35708. private _camera;
  35709. private _mustUnrotateFixedNormals;
  35710. private _particlesIntersect;
  35711. private _needs32Bits;
  35712. private _isNotBuilt;
  35713. private _lastParticleId;
  35714. private _idxOfId;
  35715. private _multimaterialEnabled;
  35716. private _useModelMaterial;
  35717. private _indicesByMaterial;
  35718. private _materialIndexes;
  35719. private _depthSortFunction;
  35720. private _materialSortFunction;
  35721. private _materials;
  35722. private _multimaterial;
  35723. private _materialIndexesById;
  35724. private _defaultMaterial;
  35725. private _autoUpdateSubMeshes;
  35726. private _tmpVertex;
  35727. /**
  35728. * Creates a SPS (Solid Particle System) object.
  35729. * @param name (String) is the SPS name, this will be the underlying mesh name.
  35730. * @param scene (Scene) is the scene in which the SPS is added.
  35731. * @param options defines the options of the sps e.g.
  35732. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  35733. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  35734. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  35735. * * 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.
  35736. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  35737. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  35738. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  35739. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  35740. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the bounding sphere radius by in order to reduce it for instance.
  35741. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  35742. */
  35743. constructor(name: string, scene: Scene, options?: {
  35744. updatable?: boolean;
  35745. isPickable?: boolean;
  35746. enableDepthSort?: boolean;
  35747. particleIntersection?: boolean;
  35748. boundingSphereOnly?: boolean;
  35749. bSphereRadiusFactor?: number;
  35750. expandable?: boolean;
  35751. useModelMaterial?: boolean;
  35752. enableMultiMaterial?: boolean;
  35753. });
  35754. /**
  35755. * Builds the SPS underlying mesh. Returns a standard Mesh.
  35756. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  35757. * @returns the created mesh
  35758. */
  35759. buildMesh(): Mesh;
  35760. /**
  35761. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  35762. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  35763. * Thus the particles generated from `digest()` have their property `position` set yet.
  35764. * @param mesh ( Mesh ) is the mesh to be digested
  35765. * @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
  35766. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  35767. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  35768. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  35769. * @returns the current SPS
  35770. */
  35771. digest(mesh: Mesh, options?: {
  35772. facetNb?: number;
  35773. number?: number;
  35774. delta?: number;
  35775. storage?: [];
  35776. }): SolidParticleSystem;
  35777. /**
  35778. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  35779. * @hidden
  35780. */
  35781. private _unrotateFixedNormals;
  35782. /**
  35783. * Resets the temporary working copy particle
  35784. * @hidden
  35785. */
  35786. private _resetCopy;
  35787. /**
  35788. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  35789. * @param p the current index in the positions array to be updated
  35790. * @param ind the current index in the indices array
  35791. * @param shape a Vector3 array, the shape geometry
  35792. * @param positions the positions array to be updated
  35793. * @param meshInd the shape indices array
  35794. * @param indices the indices array to be updated
  35795. * @param meshUV the shape uv array
  35796. * @param uvs the uv array to be updated
  35797. * @param meshCol the shape color array
  35798. * @param colors the color array to be updated
  35799. * @param meshNor the shape normals array
  35800. * @param normals the normals array to be updated
  35801. * @param idx the particle index
  35802. * @param idxInShape the particle index in its shape
  35803. * @param options the addShape() method passed options
  35804. * @model the particle model
  35805. * @hidden
  35806. */
  35807. private _meshBuilder;
  35808. /**
  35809. * Returns a shape Vector3 array from positions float array
  35810. * @param positions float array
  35811. * @returns a vector3 array
  35812. * @hidden
  35813. */
  35814. private _posToShape;
  35815. /**
  35816. * Returns a shapeUV array from a float uvs (array deep copy)
  35817. * @param uvs as a float array
  35818. * @returns a shapeUV array
  35819. * @hidden
  35820. */
  35821. private _uvsToShapeUV;
  35822. /**
  35823. * Adds a new particle object in the particles array
  35824. * @param idx particle index in particles array
  35825. * @param id particle id
  35826. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  35827. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  35828. * @param model particle ModelShape object
  35829. * @param shapeId model shape identifier
  35830. * @param idxInShape index of the particle in the current model
  35831. * @param bInfo model bounding info object
  35832. * @param storage target storage array, if any
  35833. * @hidden
  35834. */
  35835. private _addParticle;
  35836. /**
  35837. * Adds some particles to the SPS from the model shape. Returns the shape id.
  35838. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  35839. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  35840. * @param nb (positive integer) the number of particles to be created from this model
  35841. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  35842. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  35843. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  35844. * @returns the number of shapes in the system
  35845. */
  35846. addShape(mesh: Mesh, nb: number, options?: {
  35847. positionFunction?: any;
  35848. vertexFunction?: any;
  35849. storage?: [];
  35850. }): number;
  35851. /**
  35852. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  35853. * @hidden
  35854. */
  35855. private _rebuildParticle;
  35856. /**
  35857. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  35858. * @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.
  35859. * @returns the SPS.
  35860. */
  35861. rebuildMesh(reset?: boolean): SolidParticleSystem;
  35862. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  35863. * Returns an array with the removed particles.
  35864. * 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.
  35865. * The SPS can't be empty so at least one particle needs to remain in place.
  35866. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  35867. * @param start index of the first particle to remove
  35868. * @param end index of the last particle to remove (included)
  35869. * @returns an array populated with the removed particles
  35870. */
  35871. removeParticles(start: number, end: number): SolidParticle[];
  35872. /**
  35873. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  35874. * @param solidParticleArray an array populated with Solid Particles objects
  35875. * @returns the SPS
  35876. */
  35877. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  35878. /**
  35879. * Creates a new particle and modifies the SPS mesh geometry :
  35880. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  35881. * - calls _addParticle() to populate the particle array
  35882. * factorized code from addShape() and insertParticlesFromArray()
  35883. * @param idx particle index in the particles array
  35884. * @param i particle index in its shape
  35885. * @param modelShape particle ModelShape object
  35886. * @param shape shape vertex array
  35887. * @param meshInd shape indices array
  35888. * @param meshUV shape uv array
  35889. * @param meshCol shape color array
  35890. * @param meshNor shape normals array
  35891. * @param bbInfo shape bounding info
  35892. * @param storage target particle storage
  35893. * @options addShape() passed options
  35894. * @hidden
  35895. */
  35896. private _insertNewParticle;
  35897. /**
  35898. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  35899. * This method calls `updateParticle()` for each particle of the SPS.
  35900. * For an animated SPS, it is usually called within the render loop.
  35901. * 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.
  35902. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  35903. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  35904. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  35905. * @returns the SPS.
  35906. */
  35907. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  35908. /**
  35909. * Disposes the SPS.
  35910. */
  35911. dispose(): void;
  35912. /** Returns an object {idx: number faceId: number} for the picked particle from the passed pickingInfo object.
  35913. * idx is the particle index in the SPS
  35914. * faceId is the picked face index counted within this particle.
  35915. * Returns null if the pickInfo can't identify a picked particle.
  35916. * @param pickingInfo (PickingInfo object)
  35917. * @returns {idx: number, faceId: number} or null
  35918. */
  35919. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  35920. idx: number;
  35921. faceId: number;
  35922. }>;
  35923. /**
  35924. * Returns a SolidParticle object from its identifier : particle.id
  35925. * @param id (integer) the particle Id
  35926. * @returns the searched particle or null if not found in the SPS.
  35927. */
  35928. getParticleById(id: number): Nullable<SolidParticle>;
  35929. /**
  35930. * Returns a new array populated with the particles having the passed shapeId.
  35931. * @param shapeId (integer) the shape identifier
  35932. * @returns a new solid particle array
  35933. */
  35934. getParticlesByShapeId(shapeId: number): SolidParticle[];
  35935. /**
  35936. * Populates the passed array "ref" with the particles having the passed shapeId.
  35937. * @param shapeId the shape identifier
  35938. * @returns the SPS
  35939. * @param ref
  35940. */
  35941. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  35942. /**
  35943. * Computes the required SubMeshes according the materials assigned to the particles.
  35944. * @returns the solid particle system.
  35945. * Does nothing if called before the SPS mesh is built.
  35946. */
  35947. computeSubMeshes(): SolidParticleSystem;
  35948. /**
  35949. * Sorts the solid particles by material when MultiMaterial is enabled.
  35950. * Updates the indices32 array.
  35951. * Updates the indicesByMaterial array.
  35952. * Updates the mesh indices array.
  35953. * @returns the SPS
  35954. * @hidden
  35955. */
  35956. private _sortParticlesByMaterial;
  35957. /**
  35958. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  35959. * @hidden
  35960. */
  35961. private _setMaterialIndexesById;
  35962. /**
  35963. * Returns an array with unique values of Materials from the passed array
  35964. * @param array the material array to be checked and filtered
  35965. * @hidden
  35966. */
  35967. private _filterUniqueMaterialId;
  35968. /**
  35969. * Sets a new Standard Material as _defaultMaterial if not already set.
  35970. * @hidden
  35971. */
  35972. private _setDefaultMaterial;
  35973. /**
  35974. * Visibility helper : Recomputes the visible size according to the mesh bounding box
  35975. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35976. * @returns the SPS.
  35977. */
  35978. refreshVisibleSize(): SolidParticleSystem;
  35979. /**
  35980. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  35981. * @param size the size (float) of the visibility box
  35982. * note : this doesn't lock the SPS mesh bounding box.
  35983. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35984. */
  35985. setVisibilityBox(size: number): void;
  35986. /**
  35987. * Gets whether the SPS as always visible or not
  35988. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35989. */
  35990. get isAlwaysVisible(): boolean;
  35991. /**
  35992. * Sets the SPS as always visible or not
  35993. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35994. */
  35995. set isAlwaysVisible(val: boolean);
  35996. /**
  35997. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  35998. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35999. */
  36000. set isVisibilityBoxLocked(val: boolean);
  36001. /**
  36002. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  36003. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  36004. */
  36005. get isVisibilityBoxLocked(): boolean;
  36006. /**
  36007. * Tells to `setParticles()` to compute the particle rotations or not.
  36008. * Default value : true. The SPS is faster when it's set to false.
  36009. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  36010. */
  36011. set computeParticleRotation(val: boolean);
  36012. /**
  36013. * Tells to `setParticles()` to compute the particle colors or not.
  36014. * Default value : true. The SPS is faster when it's set to false.
  36015. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  36016. */
  36017. set computeParticleColor(val: boolean);
  36018. set computeParticleTexture(val: boolean);
  36019. /**
  36020. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  36021. * Default value : false. The SPS is faster when it's set to false.
  36022. * Note : the particle custom vertex positions aren't stored values.
  36023. */
  36024. set computeParticleVertex(val: boolean);
  36025. /**
  36026. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  36027. */
  36028. set computeBoundingBox(val: boolean);
  36029. /**
  36030. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  36031. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  36032. * Default : `true`
  36033. */
  36034. set depthSortParticles(val: boolean);
  36035. /**
  36036. * Gets if `setParticles()` computes the particle rotations or not.
  36037. * Default value : true. The SPS is faster when it's set to false.
  36038. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  36039. */
  36040. get computeParticleRotation(): boolean;
  36041. /**
  36042. * Gets if `setParticles()` computes the particle colors or not.
  36043. * Default value : true. The SPS is faster when it's set to false.
  36044. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  36045. */
  36046. get computeParticleColor(): boolean;
  36047. /**
  36048. * Gets if `setParticles()` computes the particle textures or not.
  36049. * Default value : true. The SPS is faster when it's set to false.
  36050. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  36051. */
  36052. get computeParticleTexture(): boolean;
  36053. /**
  36054. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  36055. * Default value : false. The SPS is faster when it's set to false.
  36056. * Note : the particle custom vertex positions aren't stored values.
  36057. */
  36058. get computeParticleVertex(): boolean;
  36059. /**
  36060. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  36061. */
  36062. get computeBoundingBox(): boolean;
  36063. /**
  36064. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  36065. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  36066. * Default : `true`
  36067. */
  36068. get depthSortParticles(): boolean;
  36069. /**
  36070. * Gets if the SPS is created as expandable at construction time.
  36071. * Default : `false`
  36072. */
  36073. get expandable(): boolean;
  36074. /**
  36075. * Gets if the SPS supports the Multi Materials
  36076. */
  36077. get multimaterialEnabled(): boolean;
  36078. /**
  36079. * Gets if the SPS uses the model materials for its own multimaterial.
  36080. */
  36081. get useModelMaterial(): boolean;
  36082. /**
  36083. * The SPS used material array.
  36084. */
  36085. get materials(): Material[];
  36086. /**
  36087. * Sets the SPS MultiMaterial from the passed materials.
  36088. * Note : the passed array is internally copied and not used then by reference.
  36089. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  36090. */
  36091. setMultiMaterial(materials: Material[]): void;
  36092. /**
  36093. * The SPS computed multimaterial object
  36094. */
  36095. get multimaterial(): MultiMaterial;
  36096. set multimaterial(mm: MultiMaterial);
  36097. /**
  36098. * If the subMeshes must be updated on the next call to setParticles()
  36099. */
  36100. get autoUpdateSubMeshes(): boolean;
  36101. set autoUpdateSubMeshes(val: boolean);
  36102. /**
  36103. * This function does nothing. It may be overwritten to set all the particle first values.
  36104. * The SPS doesn't call this function, you may have to call it by your own.
  36105. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  36106. */
  36107. initParticles(): void;
  36108. /**
  36109. * This function does nothing. It may be overwritten to recycle a particle.
  36110. * The SPS doesn't call this function, you may have to call it by your own.
  36111. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  36112. * @param particle The particle to recycle
  36113. * @returns the recycled particle
  36114. */
  36115. recycleParticle(particle: SolidParticle): SolidParticle;
  36116. /**
  36117. * Updates a particle : this function should be overwritten by the user.
  36118. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  36119. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  36120. * @example : just set a particle position or velocity and recycle conditions
  36121. * @param particle The particle to update
  36122. * @returns the updated particle
  36123. */
  36124. updateParticle(particle: SolidParticle): SolidParticle;
  36125. /**
  36126. * Updates a vertex of a particle : it can be overwritten by the user.
  36127. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  36128. * @param particle the current particle
  36129. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  36130. * @param pt the index of the current vertex in the particle shape
  36131. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  36132. * @example : just set a vertex particle position or color
  36133. * @returns the sps
  36134. */
  36135. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  36136. /**
  36137. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  36138. * This does nothing and may be overwritten by the user.
  36139. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36140. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36141. * @param update the boolean update value actually passed to setParticles()
  36142. */
  36143. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  36144. /**
  36145. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  36146. * This will be passed three parameters.
  36147. * This does nothing and may be overwritten by the user.
  36148. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36149. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36150. * @param update the boolean update value actually passed to setParticles()
  36151. */
  36152. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  36153. }
  36154. }
  36155. declare module BABYLON {
  36156. /**
  36157. * Represents one particle of a solid particle system.
  36158. */
  36159. export class SolidParticle {
  36160. /**
  36161. * particle global index
  36162. */
  36163. idx: number;
  36164. /**
  36165. * particle identifier
  36166. */
  36167. id: number;
  36168. /**
  36169. * The color of the particle
  36170. */
  36171. color: Nullable<Color4>;
  36172. /**
  36173. * The world space position of the particle.
  36174. */
  36175. position: Vector3;
  36176. /**
  36177. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  36178. */
  36179. rotation: Vector3;
  36180. /**
  36181. * The world space rotation quaternion of the particle.
  36182. */
  36183. rotationQuaternion: Nullable<Quaternion>;
  36184. /**
  36185. * The scaling of the particle.
  36186. */
  36187. scaling: Vector3;
  36188. /**
  36189. * The uvs of the particle.
  36190. */
  36191. uvs: Vector4;
  36192. /**
  36193. * The current speed of the particle.
  36194. */
  36195. velocity: Vector3;
  36196. /**
  36197. * The pivot point in the particle local space.
  36198. */
  36199. pivot: Vector3;
  36200. /**
  36201. * Must the particle be translated from its pivot point in its local space ?
  36202. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  36203. * Default : false
  36204. */
  36205. translateFromPivot: boolean;
  36206. /**
  36207. * Is the particle active or not ?
  36208. */
  36209. alive: boolean;
  36210. /**
  36211. * Is the particle visible or not ?
  36212. */
  36213. isVisible: boolean;
  36214. /**
  36215. * Index of this particle in the global "positions" array (Internal use)
  36216. * @hidden
  36217. */
  36218. _pos: number;
  36219. /**
  36220. * @hidden Index of this particle in the global "indices" array (Internal use)
  36221. */
  36222. _ind: number;
  36223. /**
  36224. * @hidden ModelShape of this particle (Internal use)
  36225. */
  36226. _model: ModelShape;
  36227. /**
  36228. * ModelShape id of this particle
  36229. */
  36230. shapeId: number;
  36231. /**
  36232. * Index of the particle in its shape id
  36233. */
  36234. idxInShape: number;
  36235. /**
  36236. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  36237. */
  36238. _modelBoundingInfo: BoundingInfo;
  36239. /**
  36240. * @hidden Particle BoundingInfo object (Internal use)
  36241. */
  36242. _boundingInfo: BoundingInfo;
  36243. /**
  36244. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  36245. */
  36246. _sps: SolidParticleSystem;
  36247. /**
  36248. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  36249. */
  36250. _stillInvisible: boolean;
  36251. /**
  36252. * @hidden Last computed particle rotation matrix
  36253. */
  36254. _rotationMatrix: number[];
  36255. /**
  36256. * Parent particle Id, if any.
  36257. * Default null.
  36258. */
  36259. parentId: Nullable<number>;
  36260. /**
  36261. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  36262. */
  36263. materialIndex: Nullable<number>;
  36264. /**
  36265. * Custom object or properties.
  36266. */
  36267. props: Nullable<any>;
  36268. /**
  36269. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  36270. * The possible values are :
  36271. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  36272. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36273. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  36274. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  36275. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36276. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  36277. * */
  36278. cullingStrategy: number;
  36279. /**
  36280. * @hidden Internal global position in the SPS.
  36281. */
  36282. _globalPosition: Vector3;
  36283. /**
  36284. * Creates a Solid Particle object.
  36285. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  36286. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  36287. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  36288. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  36289. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  36290. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  36291. * @param shapeId (integer) is the model shape identifier in the SPS.
  36292. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  36293. * @param sps defines the sps it is associated to
  36294. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  36295. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  36296. */
  36297. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  36298. /**
  36299. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  36300. * @param target the particle target
  36301. * @returns the current particle
  36302. */
  36303. copyToRef(target: SolidParticle): SolidParticle;
  36304. /**
  36305. * Legacy support, changed scale to scaling
  36306. */
  36307. get scale(): Vector3;
  36308. /**
  36309. * Legacy support, changed scale to scaling
  36310. */
  36311. set scale(scale: Vector3);
  36312. /**
  36313. * Legacy support, changed quaternion to rotationQuaternion
  36314. */
  36315. get quaternion(): Nullable<Quaternion>;
  36316. /**
  36317. * Legacy support, changed quaternion to rotationQuaternion
  36318. */
  36319. set quaternion(q: Nullable<Quaternion>);
  36320. /**
  36321. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  36322. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  36323. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  36324. * @returns true if it intersects
  36325. */
  36326. intersectsMesh(target: Mesh | SolidParticle): boolean;
  36327. /**
  36328. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  36329. * A particle is in the frustum if its bounding box intersects the frustum
  36330. * @param frustumPlanes defines the frustum to test
  36331. * @returns true if the particle is in the frustum planes
  36332. */
  36333. isInFrustum(frustumPlanes: Plane[]): boolean;
  36334. /**
  36335. * get the rotation matrix of the particle
  36336. * @hidden
  36337. */
  36338. getRotationMatrix(m: Matrix): void;
  36339. }
  36340. /**
  36341. * Represents the shape of the model used by one particle of a solid particle system.
  36342. * SPS internal tool, don't use it manually.
  36343. */
  36344. export class ModelShape {
  36345. /**
  36346. * The shape id
  36347. * @hidden
  36348. */
  36349. shapeID: number;
  36350. /**
  36351. * flat array of model positions (internal use)
  36352. * @hidden
  36353. */
  36354. _shape: Vector3[];
  36355. /**
  36356. * flat array of model UVs (internal use)
  36357. * @hidden
  36358. */
  36359. _shapeUV: number[];
  36360. /**
  36361. * color array of the model
  36362. * @hidden
  36363. */
  36364. _shapeColors: number[];
  36365. /**
  36366. * indices array of the model
  36367. * @hidden
  36368. */
  36369. _indices: number[];
  36370. /**
  36371. * normals array of the model
  36372. * @hidden
  36373. */
  36374. _normals: number[];
  36375. /**
  36376. * length of the shape in the model indices array (internal use)
  36377. * @hidden
  36378. */
  36379. _indicesLength: number;
  36380. /**
  36381. * Custom position function (internal use)
  36382. * @hidden
  36383. */
  36384. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  36385. /**
  36386. * Custom vertex function (internal use)
  36387. * @hidden
  36388. */
  36389. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  36390. /**
  36391. * Model material (internal use)
  36392. * @hidden
  36393. */
  36394. _material: Nullable<Material>;
  36395. /**
  36396. * 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.
  36397. * SPS internal tool, don't use it manually.
  36398. * @hidden
  36399. */
  36400. 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>);
  36401. }
  36402. /**
  36403. * Represents a Depth Sorted Particle in the solid particle system.
  36404. * @hidden
  36405. */
  36406. export class DepthSortedParticle {
  36407. /**
  36408. * Particle index
  36409. */
  36410. idx: number;
  36411. /**
  36412. * Index of the particle in the "indices" array
  36413. */
  36414. ind: number;
  36415. /**
  36416. * Length of the particle shape in the "indices" array
  36417. */
  36418. indicesLength: number;
  36419. /**
  36420. * Squared distance from the particle to the camera
  36421. */
  36422. sqDistance: number;
  36423. /**
  36424. * Material index when used with MultiMaterials
  36425. */
  36426. materialIndex: number;
  36427. /**
  36428. * Creates a new sorted particle
  36429. * @param materialIndex
  36430. */
  36431. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  36432. }
  36433. /**
  36434. * Represents a solid particle vertex
  36435. */
  36436. export class SolidParticleVertex {
  36437. /**
  36438. * Vertex position
  36439. */
  36440. position: Vector3;
  36441. /**
  36442. * Vertex color
  36443. */
  36444. color: Color4;
  36445. /**
  36446. * Vertex UV
  36447. */
  36448. uv: Vector2;
  36449. /**
  36450. * Creates a new solid particle vertex
  36451. */
  36452. constructor();
  36453. /** Vertex x coordinate */
  36454. get x(): number;
  36455. set x(val: number);
  36456. /** Vertex y coordinate */
  36457. get y(): number;
  36458. set y(val: number);
  36459. /** Vertex z coordinate */
  36460. get z(): number;
  36461. set z(val: number);
  36462. }
  36463. }
  36464. declare module BABYLON {
  36465. /**
  36466. * @hidden
  36467. */
  36468. export class _MeshCollisionData {
  36469. _checkCollisions: boolean;
  36470. _collisionMask: number;
  36471. _collisionGroup: number;
  36472. _surroundingMeshes: Nullable<AbstractMesh[]>;
  36473. _collider: Nullable<Collider>;
  36474. _oldPositionForCollisions: Vector3;
  36475. _diffPositionForCollisions: Vector3;
  36476. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  36477. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  36478. _collisionResponse: boolean;
  36479. }
  36480. }
  36481. declare module BABYLON {
  36482. /** @hidden */
  36483. class _FacetDataStorage {
  36484. facetPositions: Vector3[];
  36485. facetNormals: Vector3[];
  36486. facetPartitioning: number[][];
  36487. facetNb: number;
  36488. partitioningSubdivisions: number;
  36489. partitioningBBoxRatio: number;
  36490. facetDataEnabled: boolean;
  36491. facetParameters: any;
  36492. bbSize: Vector3;
  36493. subDiv: {
  36494. max: number;
  36495. X: number;
  36496. Y: number;
  36497. Z: number;
  36498. };
  36499. facetDepthSort: boolean;
  36500. facetDepthSortEnabled: boolean;
  36501. depthSortedIndices: IndicesArray;
  36502. depthSortedFacets: {
  36503. ind: number;
  36504. sqDistance: number;
  36505. }[];
  36506. facetDepthSortFunction: (f1: {
  36507. ind: number;
  36508. sqDistance: number;
  36509. }, f2: {
  36510. ind: number;
  36511. sqDistance: number;
  36512. }) => number;
  36513. facetDepthSortFrom: Vector3;
  36514. facetDepthSortOrigin: Vector3;
  36515. invertedMatrix: Matrix;
  36516. }
  36517. /**
  36518. * @hidden
  36519. **/
  36520. class _InternalAbstractMeshDataInfo {
  36521. _hasVertexAlpha: boolean;
  36522. _useVertexColors: boolean;
  36523. _numBoneInfluencers: number;
  36524. _applyFog: boolean;
  36525. _receiveShadows: boolean;
  36526. _facetData: _FacetDataStorage;
  36527. _visibility: number;
  36528. _skeleton: Nullable<Skeleton>;
  36529. _layerMask: number;
  36530. _computeBonesUsingShaders: boolean;
  36531. _isActive: boolean;
  36532. _onlyForInstances: boolean;
  36533. _isActiveIntermediate: boolean;
  36534. _onlyForInstancesIntermediate: boolean;
  36535. _actAsRegularMesh: boolean;
  36536. _currentLOD: Nullable<AbstractMesh>;
  36537. _currentLODIsUpToDate: boolean;
  36538. }
  36539. /**
  36540. * Class used to store all common mesh properties
  36541. */
  36542. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  36543. /** No occlusion */
  36544. static OCCLUSION_TYPE_NONE: number;
  36545. /** Occlusion set to optimistic */
  36546. static OCCLUSION_TYPE_OPTIMISTIC: number;
  36547. /** Occlusion set to strict */
  36548. static OCCLUSION_TYPE_STRICT: number;
  36549. /** Use an accurate occlusion algorithm */
  36550. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  36551. /** Use a conservative occlusion algorithm */
  36552. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  36553. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  36554. * Test order :
  36555. * Is the bounding sphere outside the frustum ?
  36556. * If not, are the bounding box vertices outside the frustum ?
  36557. * It not, then the cullable object is in the frustum.
  36558. */
  36559. static readonly CULLINGSTRATEGY_STANDARD: number;
  36560. /** Culling strategy : Bounding Sphere Only.
  36561. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  36562. * It's also less accurate than the standard because some not visible objects can still be selected.
  36563. * Test : is the bounding sphere outside the frustum ?
  36564. * If not, then the cullable object is in the frustum.
  36565. */
  36566. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  36567. /** Culling strategy : Optimistic Inclusion.
  36568. * This in an inclusion test first, then the standard exclusion test.
  36569. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  36570. * 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.
  36571. * Anyway, it's as accurate as the standard strategy.
  36572. * Test :
  36573. * Is the cullable object bounding sphere center in the frustum ?
  36574. * If not, apply the default culling strategy.
  36575. */
  36576. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  36577. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  36578. * This in an inclusion test first, then the bounding sphere only exclusion test.
  36579. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  36580. * 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.
  36581. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  36582. * Test :
  36583. * Is the cullable object bounding sphere center in the frustum ?
  36584. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  36585. */
  36586. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  36587. /**
  36588. * No billboard
  36589. */
  36590. static get BILLBOARDMODE_NONE(): number;
  36591. /** Billboard on X axis */
  36592. static get BILLBOARDMODE_X(): number;
  36593. /** Billboard on Y axis */
  36594. static get BILLBOARDMODE_Y(): number;
  36595. /** Billboard on Z axis */
  36596. static get BILLBOARDMODE_Z(): number;
  36597. /** Billboard on all axes */
  36598. static get BILLBOARDMODE_ALL(): number;
  36599. /** Billboard on using position instead of orientation */
  36600. static get BILLBOARDMODE_USE_POSITION(): number;
  36601. /** @hidden */
  36602. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  36603. /**
  36604. * The culling strategy to use to check whether the mesh must be rendered or not.
  36605. * This value can be changed at any time and will be used on the next render mesh selection.
  36606. * The possible values are :
  36607. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  36608. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36609. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  36610. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  36611. * Please read each static variable documentation to get details about the culling process.
  36612. * */
  36613. cullingStrategy: number;
  36614. /**
  36615. * Gets the number of facets in the mesh
  36616. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  36617. */
  36618. get facetNb(): number;
  36619. /**
  36620. * Gets or set the number (integer) of subdivisions per axis in the partitioning space
  36621. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  36622. */
  36623. get partitioningSubdivisions(): number;
  36624. set partitioningSubdivisions(nb: number);
  36625. /**
  36626. * The ratio (float) to apply to the bounding box size to set to the partitioning space.
  36627. * Ex : 1.01 (default) the partitioning space is 1% bigger than the bounding box
  36628. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  36629. */
  36630. get partitioningBBoxRatio(): number;
  36631. set partitioningBBoxRatio(ratio: number);
  36632. /**
  36633. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  36634. * Works only for updatable meshes.
  36635. * Doesn't work with multi-materials
  36636. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  36637. */
  36638. get mustDepthSortFacets(): boolean;
  36639. set mustDepthSortFacets(sort: boolean);
  36640. /**
  36641. * The location (Vector3) where the facet depth sort must be computed from.
  36642. * By default, the active camera position.
  36643. * Used only when facet depth sort is enabled
  36644. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  36645. */
  36646. get facetDepthSortFrom(): Vector3;
  36647. set facetDepthSortFrom(location: Vector3);
  36648. /**
  36649. * gets a boolean indicating if facetData is enabled
  36650. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  36651. */
  36652. get isFacetDataEnabled(): boolean;
  36653. /** @hidden */
  36654. _updateNonUniformScalingState(value: boolean): boolean;
  36655. /**
  36656. * An event triggered when this mesh collides with another one
  36657. */
  36658. onCollideObservable: Observable<AbstractMesh>;
  36659. /** Set a function to call when this mesh collides with another one */
  36660. set onCollide(callback: () => void);
  36661. /**
  36662. * An event triggered when the collision's position changes
  36663. */
  36664. onCollisionPositionChangeObservable: Observable<Vector3>;
  36665. /** Set a function to call when the collision's position changes */
  36666. set onCollisionPositionChange(callback: () => void);
  36667. /**
  36668. * An event triggered when material is changed
  36669. */
  36670. onMaterialChangedObservable: Observable<AbstractMesh>;
  36671. /**
  36672. * Gets or sets the orientation for POV movement & rotation
  36673. */
  36674. definedFacingForward: boolean;
  36675. /** @hidden */
  36676. _occlusionQuery: Nullable<WebGLQuery>;
  36677. /** @hidden */
  36678. _renderingGroup: Nullable<RenderingGroup>;
  36679. /**
  36680. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  36681. */
  36682. get visibility(): number;
  36683. /**
  36684. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  36685. */
  36686. set visibility(value: number);
  36687. /** Gets or sets the alpha index used to sort transparent meshes
  36688. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  36689. */
  36690. alphaIndex: number;
  36691. /**
  36692. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  36693. */
  36694. isVisible: boolean;
  36695. /**
  36696. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  36697. */
  36698. isPickable: boolean;
  36699. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  36700. showSubMeshesBoundingBox: boolean;
  36701. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  36702. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  36703. */
  36704. isBlocker: boolean;
  36705. /**
  36706. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  36707. */
  36708. enablePointerMoveEvents: boolean;
  36709. private _renderingGroupId;
  36710. /**
  36711. * Specifies the rendering group id for this mesh (0 by default)
  36712. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  36713. */
  36714. get renderingGroupId(): number;
  36715. set renderingGroupId(value: number);
  36716. private _material;
  36717. /** Gets or sets current material */
  36718. get material(): Nullable<Material>;
  36719. set material(value: Nullable<Material>);
  36720. /**
  36721. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  36722. * @see https://doc.babylonjs.com/babylon101/shadows
  36723. */
  36724. get receiveShadows(): boolean;
  36725. set receiveShadows(value: boolean);
  36726. /** Defines color to use when rendering outline */
  36727. outlineColor: Color3;
  36728. /** Define width to use when rendering outline */
  36729. outlineWidth: number;
  36730. /** Defines color to use when rendering overlay */
  36731. overlayColor: Color3;
  36732. /** Defines alpha to use when rendering overlay */
  36733. overlayAlpha: number;
  36734. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  36735. get hasVertexAlpha(): boolean;
  36736. set hasVertexAlpha(value: boolean);
  36737. /** 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) */
  36738. get useVertexColors(): boolean;
  36739. set useVertexColors(value: boolean);
  36740. /**
  36741. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  36742. */
  36743. get computeBonesUsingShaders(): boolean;
  36744. set computeBonesUsingShaders(value: boolean);
  36745. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  36746. get numBoneInfluencers(): number;
  36747. set numBoneInfluencers(value: number);
  36748. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  36749. get applyFog(): boolean;
  36750. set applyFog(value: boolean);
  36751. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  36752. useOctreeForRenderingSelection: boolean;
  36753. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  36754. useOctreeForPicking: boolean;
  36755. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  36756. useOctreeForCollisions: boolean;
  36757. /**
  36758. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  36759. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  36760. */
  36761. get layerMask(): number;
  36762. set layerMask(value: number);
  36763. /**
  36764. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  36765. */
  36766. alwaysSelectAsActiveMesh: boolean;
  36767. /**
  36768. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  36769. */
  36770. doNotSyncBoundingInfo: boolean;
  36771. /**
  36772. * Gets or sets the current action manager
  36773. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  36774. */
  36775. actionManager: Nullable<AbstractActionManager>;
  36776. private _meshCollisionData;
  36777. /**
  36778. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  36779. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36780. */
  36781. ellipsoid: Vector3;
  36782. /**
  36783. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  36784. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36785. */
  36786. ellipsoidOffset: Vector3;
  36787. /**
  36788. * Gets or sets a collision mask used to mask collisions (default is -1).
  36789. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  36790. */
  36791. get collisionMask(): number;
  36792. set collisionMask(mask: number);
  36793. /**
  36794. * Gets or sets a collision response flag (default is true).
  36795. * when collisionResponse is false, events are still triggered but colliding entity has no response
  36796. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  36797. * to respond to the collision.
  36798. */
  36799. get collisionResponse(): boolean;
  36800. set collisionResponse(response: boolean);
  36801. /**
  36802. * Gets or sets the current collision group mask (-1 by default).
  36803. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  36804. */
  36805. get collisionGroup(): number;
  36806. set collisionGroup(mask: number);
  36807. /**
  36808. * Gets or sets current surrounding meshes (null by default).
  36809. *
  36810. * By default collision detection is tested against every mesh in the scene.
  36811. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  36812. * meshes will be tested for the collision.
  36813. *
  36814. * Note: if set to an empty array no collision will happen when this mesh is moved.
  36815. */
  36816. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  36817. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  36818. /**
  36819. * Defines edge width used when edgesRenderer is enabled
  36820. * @see https://www.babylonjs-playground.com/#10OJSG#13
  36821. */
  36822. edgesWidth: number;
  36823. /**
  36824. * Defines edge color used when edgesRenderer is enabled
  36825. * @see https://www.babylonjs-playground.com/#10OJSG#13
  36826. */
  36827. edgesColor: Color4;
  36828. /** @hidden */
  36829. _edgesRenderer: Nullable<IEdgesRenderer>;
  36830. /** @hidden */
  36831. _masterMesh: Nullable<AbstractMesh>;
  36832. /** @hidden */
  36833. _boundingInfo: Nullable<BoundingInfo>;
  36834. /** @hidden */
  36835. _renderId: number;
  36836. /**
  36837. * Gets or sets the list of subMeshes
  36838. * @see https://doc.babylonjs.com/how_to/multi_materials
  36839. */
  36840. subMeshes: SubMesh[];
  36841. /** @hidden */
  36842. _intersectionsInProgress: AbstractMesh[];
  36843. /** @hidden */
  36844. _unIndexed: boolean;
  36845. /** @hidden */
  36846. _lightSources: Light[];
  36847. /** Gets the list of lights affecting that mesh */
  36848. get lightSources(): Light[];
  36849. /** @hidden */
  36850. get _positions(): Nullable<Vector3[]>;
  36851. /** @hidden */
  36852. _waitingData: {
  36853. lods: Nullable<any>;
  36854. actions: Nullable<any>;
  36855. freezeWorldMatrix: Nullable<boolean>;
  36856. };
  36857. /** @hidden */
  36858. _bonesTransformMatrices: Nullable<Float32Array>;
  36859. /** @hidden */
  36860. _transformMatrixTexture: Nullable<RawTexture>;
  36861. /**
  36862. * Gets or sets a skeleton to apply skinning transformations
  36863. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  36864. */
  36865. set skeleton(value: Nullable<Skeleton>);
  36866. get skeleton(): Nullable<Skeleton>;
  36867. /**
  36868. * An event triggered when the mesh is rebuilt.
  36869. */
  36870. onRebuildObservable: Observable<AbstractMesh>;
  36871. /**
  36872. * The current mesh uniform buffer.
  36873. * @hidden Internal use only.
  36874. */
  36875. _uniformBuffer: UniformBuffer;
  36876. /**
  36877. * Creates a new AbstractMesh
  36878. * @param name defines the name of the mesh
  36879. * @param scene defines the hosting scene
  36880. */
  36881. constructor(name: string, scene?: Nullable<Scene>);
  36882. protected _buildUniformLayout(): void;
  36883. /**
  36884. * Transfer the mesh values to its UBO.
  36885. * @param world The world matrix associated with the mesh
  36886. */
  36887. transferToEffect(world: Matrix): void;
  36888. /**
  36889. * Gets the mesh uniform buffer.
  36890. * @return the uniform buffer of the mesh.
  36891. */
  36892. getMeshUniformBuffer(): UniformBuffer;
  36893. /**
  36894. * Returns the string "AbstractMesh"
  36895. * @returns "AbstractMesh"
  36896. */
  36897. getClassName(): string;
  36898. /**
  36899. * Gets a string representation of the current mesh
  36900. * @param fullDetails defines a boolean indicating if full details must be included
  36901. * @returns a string representation of the current mesh
  36902. */
  36903. toString(fullDetails?: boolean): string;
  36904. /**
  36905. * @hidden
  36906. */
  36907. protected _getEffectiveParent(): Nullable<Node>;
  36908. /** @hidden */
  36909. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  36910. /** @hidden */
  36911. _rebuild(): void;
  36912. /** @hidden */
  36913. _resyncLightSources(): void;
  36914. /** @hidden */
  36915. _resyncLightSource(light: Light): void;
  36916. /** @hidden */
  36917. _unBindEffect(): void;
  36918. /** @hidden */
  36919. _removeLightSource(light: Light, dispose: boolean): void;
  36920. private _markSubMeshesAsDirty;
  36921. /** @hidden */
  36922. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  36923. /** @hidden */
  36924. _markSubMeshesAsAttributesDirty(): void;
  36925. /** @hidden */
  36926. _markSubMeshesAsMiscDirty(): void;
  36927. /**
  36928. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  36929. */
  36930. get scaling(): Vector3;
  36931. set scaling(newScaling: Vector3);
  36932. /**
  36933. * Returns true if the mesh is blocked. Implemented by child classes
  36934. */
  36935. get isBlocked(): boolean;
  36936. /**
  36937. * Returns the mesh itself by default. Implemented by child classes
  36938. * @param camera defines the camera to use to pick the right LOD level
  36939. * @returns the currentAbstractMesh
  36940. */
  36941. getLOD(camera: Camera): Nullable<AbstractMesh>;
  36942. /**
  36943. * Returns 0 by default. Implemented by child classes
  36944. * @returns an integer
  36945. */
  36946. getTotalVertices(): number;
  36947. /**
  36948. * Returns a positive integer : the total number of indices in this mesh geometry.
  36949. * @returns the number of indices or zero if the mesh has no geometry.
  36950. */
  36951. getTotalIndices(): number;
  36952. /**
  36953. * Returns null by default. Implemented by child classes
  36954. * @returns null
  36955. */
  36956. getIndices(): Nullable<IndicesArray>;
  36957. /**
  36958. * Returns the array of the requested vertex data kind. Implemented by child classes
  36959. * @param kind defines the vertex data kind to use
  36960. * @returns null
  36961. */
  36962. getVerticesData(kind: string): Nullable<FloatArray>;
  36963. /**
  36964. * Sets the vertex data of the mesh geometry for the requested `kind`.
  36965. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  36966. * Note that a new underlying VertexBuffer object is created each call.
  36967. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  36968. * @param kind defines vertex data kind:
  36969. * * VertexBuffer.PositionKind
  36970. * * VertexBuffer.UVKind
  36971. * * VertexBuffer.UV2Kind
  36972. * * VertexBuffer.UV3Kind
  36973. * * VertexBuffer.UV4Kind
  36974. * * VertexBuffer.UV5Kind
  36975. * * VertexBuffer.UV6Kind
  36976. * * VertexBuffer.ColorKind
  36977. * * VertexBuffer.MatricesIndicesKind
  36978. * * VertexBuffer.MatricesIndicesExtraKind
  36979. * * VertexBuffer.MatricesWeightsKind
  36980. * * VertexBuffer.MatricesWeightsExtraKind
  36981. * @param data defines the data source
  36982. * @param updatable defines if the data must be flagged as updatable (or static)
  36983. * @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
  36984. * @returns the current mesh
  36985. */
  36986. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  36987. /**
  36988. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  36989. * If the mesh has no geometry, it is simply returned as it is.
  36990. * @param kind defines vertex data kind:
  36991. * * VertexBuffer.PositionKind
  36992. * * VertexBuffer.UVKind
  36993. * * VertexBuffer.UV2Kind
  36994. * * VertexBuffer.UV3Kind
  36995. * * VertexBuffer.UV4Kind
  36996. * * VertexBuffer.UV5Kind
  36997. * * VertexBuffer.UV6Kind
  36998. * * VertexBuffer.ColorKind
  36999. * * VertexBuffer.MatricesIndicesKind
  37000. * * VertexBuffer.MatricesIndicesExtraKind
  37001. * * VertexBuffer.MatricesWeightsKind
  37002. * * VertexBuffer.MatricesWeightsExtraKind
  37003. * @param data defines the data source
  37004. * @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
  37005. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  37006. * @returns the current mesh
  37007. */
  37008. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  37009. /**
  37010. * Sets the mesh indices,
  37011. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  37012. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  37013. * @param totalVertices Defines the total number of vertices
  37014. * @returns the current mesh
  37015. */
  37016. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  37017. /**
  37018. * Gets a boolean indicating if specific vertex data is present
  37019. * @param kind defines the vertex data kind to use
  37020. * @returns true is data kind is present
  37021. */
  37022. isVerticesDataPresent(kind: string): boolean;
  37023. /**
  37024. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  37025. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  37026. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  37027. * @returns a BoundingInfo
  37028. */
  37029. getBoundingInfo(): BoundingInfo;
  37030. /**
  37031. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  37032. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  37033. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  37034. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  37035. * @returns the current mesh
  37036. */
  37037. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  37038. /**
  37039. * Overwrite the current bounding info
  37040. * @param boundingInfo defines the new bounding info
  37041. * @returns the current mesh
  37042. */
  37043. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  37044. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  37045. get useBones(): boolean;
  37046. /** @hidden */
  37047. _preActivate(): void;
  37048. /** @hidden */
  37049. _preActivateForIntermediateRendering(renderId: number): void;
  37050. /** @hidden */
  37051. _activate(renderId: number, intermediateRendering: boolean): boolean;
  37052. /** @hidden */
  37053. _postActivate(): void;
  37054. /** @hidden */
  37055. _freeze(): void;
  37056. /** @hidden */
  37057. _unFreeze(): void;
  37058. /**
  37059. * Gets the current world matrix
  37060. * @returns a Matrix
  37061. */
  37062. getWorldMatrix(): Matrix;
  37063. /** @hidden */
  37064. _getWorldMatrixDeterminant(): number;
  37065. /**
  37066. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  37067. */
  37068. get isAnInstance(): boolean;
  37069. /**
  37070. * Gets a boolean indicating if this mesh has instances
  37071. */
  37072. get hasInstances(): boolean;
  37073. /**
  37074. * Gets a boolean indicating if this mesh has thin instances
  37075. */
  37076. get hasThinInstances(): boolean;
  37077. /**
  37078. * Perform relative position change from the point of view of behind the front of the mesh.
  37079. * This is performed taking into account the meshes current rotation, so you do not have to care.
  37080. * Supports definition of mesh facing forward or backward
  37081. * @param amountRight defines the distance on the right axis
  37082. * @param amountUp defines the distance on the up axis
  37083. * @param amountForward defines the distance on the forward axis
  37084. * @returns the current mesh
  37085. */
  37086. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  37087. /**
  37088. * Calculate relative position change from the point of view of behind the front of the mesh.
  37089. * This is performed taking into account the meshes current rotation, so you do not have to care.
  37090. * Supports definition of mesh facing forward or backward
  37091. * @param amountRight defines the distance on the right axis
  37092. * @param amountUp defines the distance on the up axis
  37093. * @param amountForward defines the distance on the forward axis
  37094. * @returns the new displacement vector
  37095. */
  37096. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  37097. /**
  37098. * Perform relative rotation change from the point of view of behind the front of the mesh.
  37099. * Supports definition of mesh facing forward or backward
  37100. * @param flipBack defines the flip
  37101. * @param twirlClockwise defines the twirl
  37102. * @param tiltRight defines the tilt
  37103. * @returns the current mesh
  37104. */
  37105. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  37106. /**
  37107. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  37108. * Supports definition of mesh facing forward or backward.
  37109. * @param flipBack defines the flip
  37110. * @param twirlClockwise defines the twirl
  37111. * @param tiltRight defines the tilt
  37112. * @returns the new rotation vector
  37113. */
  37114. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  37115. /**
  37116. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  37117. * This means the mesh underlying bounding box and sphere are recomputed.
  37118. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  37119. * @returns the current mesh
  37120. */
  37121. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  37122. /** @hidden */
  37123. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  37124. /** @hidden */
  37125. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  37126. /** @hidden */
  37127. _updateBoundingInfo(): AbstractMesh;
  37128. /** @hidden */
  37129. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  37130. /** @hidden */
  37131. protected _afterComputeWorldMatrix(): void;
  37132. /** @hidden */
  37133. get _effectiveMesh(): AbstractMesh;
  37134. /**
  37135. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  37136. * A mesh is in the frustum if its bounding box intersects the frustum
  37137. * @param frustumPlanes defines the frustum to test
  37138. * @returns true if the mesh is in the frustum planes
  37139. */
  37140. isInFrustum(frustumPlanes: Plane[]): boolean;
  37141. /**
  37142. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  37143. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  37144. * @param frustumPlanes defines the frustum to test
  37145. * @returns true if the mesh is completely in the frustum planes
  37146. */
  37147. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  37148. /**
  37149. * True if the mesh intersects another mesh or a SolidParticle object
  37150. * @param mesh defines a target mesh or SolidParticle to test
  37151. * @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)
  37152. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  37153. * @returns true if there is an intersection
  37154. */
  37155. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  37156. /**
  37157. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  37158. * @param point defines the point to test
  37159. * @returns true if there is an intersection
  37160. */
  37161. intersectsPoint(point: Vector3): boolean;
  37162. /**
  37163. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  37164. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37165. */
  37166. get checkCollisions(): boolean;
  37167. set checkCollisions(collisionEnabled: boolean);
  37168. /**
  37169. * Gets Collider object used to compute collisions (not physics)
  37170. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37171. */
  37172. get collider(): Nullable<Collider>;
  37173. /**
  37174. * Move the mesh using collision engine
  37175. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37176. * @param displacement defines the requested displacement vector
  37177. * @returns the current mesh
  37178. */
  37179. moveWithCollisions(displacement: Vector3): AbstractMesh;
  37180. private _onCollisionPositionChange;
  37181. /** @hidden */
  37182. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  37183. /** @hidden */
  37184. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  37185. /** @hidden */
  37186. _checkCollision(collider: Collider): AbstractMesh;
  37187. /** @hidden */
  37188. _generatePointsArray(): boolean;
  37189. /**
  37190. * Checks if the passed Ray intersects with the mesh
  37191. * @param ray defines the ray to use
  37192. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  37193. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37194. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  37195. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  37196. * @param skipBoundingInfo a boolean indicating if we should skip the bounding info check
  37197. * @returns the picking info
  37198. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  37199. */
  37200. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix, skipBoundingInfo?: boolean): PickingInfo;
  37201. /**
  37202. * Clones the current mesh
  37203. * @param name defines the mesh name
  37204. * @param newParent defines the new mesh parent
  37205. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  37206. * @returns the new mesh
  37207. */
  37208. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  37209. /**
  37210. * Disposes all the submeshes of the current meshnp
  37211. * @returns the current mesh
  37212. */
  37213. releaseSubMeshes(): AbstractMesh;
  37214. /**
  37215. * Releases resources associated with this abstract mesh.
  37216. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  37217. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  37218. */
  37219. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  37220. /**
  37221. * Adds the passed mesh as a child to the current mesh
  37222. * @param mesh defines the child mesh
  37223. * @returns the current mesh
  37224. */
  37225. addChild(mesh: AbstractMesh): AbstractMesh;
  37226. /**
  37227. * Removes the passed mesh from the current mesh children list
  37228. * @param mesh defines the child mesh
  37229. * @returns the current mesh
  37230. */
  37231. removeChild(mesh: AbstractMesh): AbstractMesh;
  37232. /** @hidden */
  37233. private _initFacetData;
  37234. /**
  37235. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  37236. * This method can be called within the render loop.
  37237. * 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
  37238. * @returns the current mesh
  37239. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37240. */
  37241. updateFacetData(): AbstractMesh;
  37242. /**
  37243. * Returns the facetLocalNormals array.
  37244. * The normals are expressed in the mesh local spac
  37245. * @returns an array of Vector3
  37246. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37247. */
  37248. getFacetLocalNormals(): Vector3[];
  37249. /**
  37250. * Returns the facetLocalPositions array.
  37251. * The facet positions are expressed in the mesh local space
  37252. * @returns an array of Vector3
  37253. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37254. */
  37255. getFacetLocalPositions(): Vector3[];
  37256. /**
  37257. * Returns the facetLocalPartitioning array
  37258. * @returns an array of array of numbers
  37259. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37260. */
  37261. getFacetLocalPartitioning(): number[][];
  37262. /**
  37263. * Returns the i-th facet position in the world system.
  37264. * This method allocates a new Vector3 per call
  37265. * @param i defines the facet index
  37266. * @returns a new Vector3
  37267. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37268. */
  37269. getFacetPosition(i: number): Vector3;
  37270. /**
  37271. * Sets the reference Vector3 with the i-th facet position in the world system
  37272. * @param i defines the facet index
  37273. * @param ref defines the target vector
  37274. * @returns the current mesh
  37275. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37276. */
  37277. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  37278. /**
  37279. * Returns the i-th facet normal in the world system.
  37280. * This method allocates a new Vector3 per call
  37281. * @param i defines the facet index
  37282. * @returns a new Vector3
  37283. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37284. */
  37285. getFacetNormal(i: number): Vector3;
  37286. /**
  37287. * Sets the reference Vector3 with the i-th facet normal in the world system
  37288. * @param i defines the facet index
  37289. * @param ref defines the target vector
  37290. * @returns the current mesh
  37291. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37292. */
  37293. getFacetNormalToRef(i: number, ref: Vector3): this;
  37294. /**
  37295. * 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)
  37296. * @param x defines x coordinate
  37297. * @param y defines y coordinate
  37298. * @param z defines z coordinate
  37299. * @returns the array of facet indexes
  37300. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37301. */
  37302. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  37303. /**
  37304. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  37305. * @param projected sets as the (x,y,z) world projection on the facet
  37306. * @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
  37307. * @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
  37308. * @param x defines x coordinate
  37309. * @param y defines y coordinate
  37310. * @param z defines z coordinate
  37311. * @returns the face index if found (or null instead)
  37312. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37313. */
  37314. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  37315. /**
  37316. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  37317. * @param projected sets as the (x,y,z) local projection on the facet
  37318. * @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
  37319. * @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
  37320. * @param x defines x coordinate
  37321. * @param y defines y coordinate
  37322. * @param z defines z coordinate
  37323. * @returns the face index if found (or null instead)
  37324. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37325. */
  37326. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  37327. /**
  37328. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  37329. * @returns the parameters
  37330. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37331. */
  37332. getFacetDataParameters(): any;
  37333. /**
  37334. * Disables the feature FacetData and frees the related memory
  37335. * @returns the current mesh
  37336. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37337. */
  37338. disableFacetData(): AbstractMesh;
  37339. /**
  37340. * Updates the AbstractMesh indices array
  37341. * @param indices defines the data source
  37342. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  37343. * @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)
  37344. * @returns the current mesh
  37345. */
  37346. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  37347. /**
  37348. * Creates new normals data for the mesh
  37349. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  37350. * @returns the current mesh
  37351. */
  37352. createNormals(updatable: boolean): AbstractMesh;
  37353. /**
  37354. * Align the mesh with a normal
  37355. * @param normal defines the normal to use
  37356. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  37357. * @returns the current mesh
  37358. */
  37359. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  37360. /** @hidden */
  37361. _checkOcclusionQuery(): boolean;
  37362. /**
  37363. * Disables the mesh edge rendering mode
  37364. * @returns the currentAbstractMesh
  37365. */
  37366. disableEdgesRendering(): AbstractMesh;
  37367. /**
  37368. * Enables the edge rendering mode on the mesh.
  37369. * This mode makes the mesh edges visible
  37370. * @param epsilon defines the maximal distance between two angles to detect a face
  37371. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  37372. * @param options options to the edge renderer
  37373. * @returns the currentAbstractMesh
  37374. * @see https://www.babylonjs-playground.com/#19O9TU#0
  37375. */
  37376. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean, options?: IEdgesRendererOptions): AbstractMesh;
  37377. /**
  37378. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  37379. * @returns an array of particle systems in the scene that use the mesh as an emitter
  37380. */
  37381. getConnectedParticleSystems(): IParticleSystem[];
  37382. }
  37383. }
  37384. declare module BABYLON {
  37385. /**
  37386. * Interface used to define ActionEvent
  37387. */
  37388. export interface IActionEvent {
  37389. /** The mesh or sprite that triggered the action */
  37390. source: any;
  37391. /** The X mouse cursor position at the time of the event */
  37392. pointerX: number;
  37393. /** The Y mouse cursor position at the time of the event */
  37394. pointerY: number;
  37395. /** The mesh that is currently pointed at (can be null) */
  37396. meshUnderPointer: Nullable<AbstractMesh>;
  37397. /** the original (browser) event that triggered the ActionEvent */
  37398. sourceEvent?: any;
  37399. /** additional data for the event */
  37400. additionalData?: any;
  37401. }
  37402. /**
  37403. * ActionEvent is the event being sent when an action is triggered.
  37404. */
  37405. export class ActionEvent implements IActionEvent {
  37406. /** The mesh or sprite that triggered the action */
  37407. source: any;
  37408. /** The X mouse cursor position at the time of the event */
  37409. pointerX: number;
  37410. /** The Y mouse cursor position at the time of the event */
  37411. pointerY: number;
  37412. /** The mesh that is currently pointed at (can be null) */
  37413. meshUnderPointer: Nullable<AbstractMesh>;
  37414. /** the original (browser) event that triggered the ActionEvent */
  37415. sourceEvent?: any;
  37416. /** additional data for the event */
  37417. additionalData?: any;
  37418. /**
  37419. * Creates a new ActionEvent
  37420. * @param source The mesh or sprite that triggered the action
  37421. * @param pointerX The X mouse cursor position at the time of the event
  37422. * @param pointerY The Y mouse cursor position at the time of the event
  37423. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  37424. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  37425. * @param additionalData additional data for the event
  37426. */
  37427. constructor(
  37428. /** The mesh or sprite that triggered the action */
  37429. source: any,
  37430. /** The X mouse cursor position at the time of the event */
  37431. pointerX: number,
  37432. /** The Y mouse cursor position at the time of the event */
  37433. pointerY: number,
  37434. /** The mesh that is currently pointed at (can be null) */
  37435. meshUnderPointer: Nullable<AbstractMesh>,
  37436. /** the original (browser) event that triggered the ActionEvent */
  37437. sourceEvent?: any,
  37438. /** additional data for the event */
  37439. additionalData?: any);
  37440. /**
  37441. * Helper function to auto-create an ActionEvent from a source mesh.
  37442. * @param source The source mesh that triggered the event
  37443. * @param evt The original (browser) event
  37444. * @param additionalData additional data for the event
  37445. * @returns the new ActionEvent
  37446. */
  37447. static CreateNew(source: AbstractMesh, evt?: IEvent, additionalData?: any): ActionEvent;
  37448. /**
  37449. * Helper function to auto-create an ActionEvent from a source sprite
  37450. * @param source The source sprite that triggered the event
  37451. * @param scene Scene associated with the sprite
  37452. * @param evt The original (browser) event
  37453. * @param additionalData additional data for the event
  37454. * @returns the new ActionEvent
  37455. */
  37456. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: IEvent, additionalData?: any): ActionEvent;
  37457. /**
  37458. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  37459. * @param scene the scene where the event occurred
  37460. * @param evt The original (browser) event
  37461. * @returns the new ActionEvent
  37462. */
  37463. static CreateNewFromScene(scene: Scene, evt: IEvent): ActionEvent;
  37464. /**
  37465. * Helper function to auto-create an ActionEvent from a primitive
  37466. * @param prim defines the target primitive
  37467. * @param pointerPos defines the pointer position
  37468. * @param evt The original (browser) event
  37469. * @param additionalData additional data for the event
  37470. * @returns the new ActionEvent
  37471. */
  37472. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  37473. }
  37474. }
  37475. declare module BABYLON {
  37476. /**
  37477. * Abstract class used to decouple action Manager from scene and meshes.
  37478. * Do not instantiate.
  37479. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  37480. */
  37481. export abstract class AbstractActionManager implements IDisposable {
  37482. /** Gets the list of active triggers */
  37483. static Triggers: {
  37484. [key: string]: number;
  37485. };
  37486. /** Gets the cursor to use when hovering items */
  37487. hoverCursor: string;
  37488. /** Gets the list of actions */
  37489. actions: IAction[];
  37490. /**
  37491. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  37492. */
  37493. isRecursive: boolean;
  37494. /**
  37495. * Releases all associated resources
  37496. */
  37497. abstract dispose(): void;
  37498. /**
  37499. * Does this action manager has pointer triggers
  37500. */
  37501. abstract get hasPointerTriggers(): boolean;
  37502. /**
  37503. * Does this action manager has pick triggers
  37504. */
  37505. abstract get hasPickTriggers(): boolean;
  37506. /**
  37507. * Process a specific trigger
  37508. * @param trigger defines the trigger to process
  37509. * @param evt defines the event details to be processed
  37510. */
  37511. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  37512. /**
  37513. * Does this action manager handles actions of any of the given triggers
  37514. * @param triggers defines the triggers to be tested
  37515. * @return a boolean indicating whether one (or more) of the triggers is handled
  37516. */
  37517. abstract hasSpecificTriggers(triggers: number[]): boolean;
  37518. /**
  37519. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  37520. * speed.
  37521. * @param triggerA defines the trigger to be tested
  37522. * @param triggerB defines the trigger to be tested
  37523. * @return a boolean indicating whether one (or more) of the triggers is handled
  37524. */
  37525. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  37526. /**
  37527. * Does this action manager handles actions of a given trigger
  37528. * @param trigger defines the trigger to be tested
  37529. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  37530. * @return whether the trigger is handled
  37531. */
  37532. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  37533. /**
  37534. * Serialize this manager to a JSON object
  37535. * @param name defines the property name to store this manager
  37536. * @returns a JSON representation of this manager
  37537. */
  37538. abstract serialize(name: string): any;
  37539. /**
  37540. * Registers an action to this action manager
  37541. * @param action defines the action to be registered
  37542. * @return the action amended (prepared) after registration
  37543. */
  37544. abstract registerAction(action: IAction): Nullable<IAction>;
  37545. /**
  37546. * Unregisters an action to this action manager
  37547. * @param action defines the action to be unregistered
  37548. * @return a boolean indicating whether the action has been unregistered
  37549. */
  37550. abstract unregisterAction(action: IAction): Boolean;
  37551. /**
  37552. * Does exist one action manager with at least one trigger
  37553. **/
  37554. static get HasTriggers(): boolean;
  37555. /**
  37556. * Does exist one action manager with at least one pick trigger
  37557. **/
  37558. static get HasPickTriggers(): boolean;
  37559. /**
  37560. * Does exist one action manager that handles actions of a given trigger
  37561. * @param trigger defines the trigger to be tested
  37562. * @return a boolean indicating whether the trigger is handled by at least one action manager
  37563. **/
  37564. static HasSpecificTrigger(trigger: number): boolean;
  37565. }
  37566. }
  37567. declare module BABYLON {
  37568. /**
  37569. * Defines how a node can be built from a string name.
  37570. */
  37571. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  37572. /**
  37573. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  37574. */
  37575. export class Node implements IBehaviorAware<Node> {
  37576. /** @hidden */
  37577. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  37578. private static _NodeConstructors;
  37579. /**
  37580. * Add a new node constructor
  37581. * @param type defines the type name of the node to construct
  37582. * @param constructorFunc defines the constructor function
  37583. */
  37584. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  37585. /**
  37586. * Returns a node constructor based on type name
  37587. * @param type defines the type name
  37588. * @param name defines the new node name
  37589. * @param scene defines the hosting scene
  37590. * @param options defines optional options to transmit to constructors
  37591. * @returns the new constructor or null
  37592. */
  37593. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  37594. /**
  37595. * Gets or sets the name of the node
  37596. */
  37597. name: string;
  37598. /**
  37599. * Gets or sets the id of the node
  37600. */
  37601. id: string;
  37602. /**
  37603. * Gets or sets the unique id of the node
  37604. */
  37605. uniqueId: number;
  37606. /**
  37607. * Gets or sets a string used to store user defined state for the node
  37608. */
  37609. state: string;
  37610. /**
  37611. * Gets or sets an object used to store user defined information for the node
  37612. */
  37613. metadata: any;
  37614. /**
  37615. * For internal use only. Please do not use.
  37616. */
  37617. reservedDataStore: any;
  37618. /**
  37619. * List of inspectable custom properties (used by the Inspector)
  37620. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  37621. */
  37622. inspectableCustomProperties: IInspectable[];
  37623. private _doNotSerialize;
  37624. /**
  37625. * Gets or sets a boolean used to define if the node must be serialized
  37626. */
  37627. get doNotSerialize(): boolean;
  37628. set doNotSerialize(value: boolean);
  37629. /** @hidden */
  37630. _isDisposed: boolean;
  37631. /**
  37632. * Gets a list of Animations associated with the node
  37633. */
  37634. animations: Animation[];
  37635. protected _ranges: {
  37636. [name: string]: Nullable<AnimationRange>;
  37637. };
  37638. /**
  37639. * Callback raised when the node is ready to be used
  37640. */
  37641. onReady: Nullable<(node: Node) => void>;
  37642. private _isEnabled;
  37643. private _isParentEnabled;
  37644. private _isReady;
  37645. /** @hidden */
  37646. _currentRenderId: number;
  37647. private _parentUpdateId;
  37648. /** @hidden */
  37649. _childUpdateId: number;
  37650. /** @hidden */
  37651. _waitingParentId: Nullable<string>;
  37652. /** @hidden */
  37653. _scene: Scene;
  37654. /** @hidden */
  37655. _cache: any;
  37656. private _parentNode;
  37657. private _children;
  37658. /** @hidden */
  37659. _worldMatrix: Matrix;
  37660. /** @hidden */
  37661. _worldMatrixDeterminant: number;
  37662. /** @hidden */
  37663. _worldMatrixDeterminantIsDirty: boolean;
  37664. /** @hidden */
  37665. private _sceneRootNodesIndex;
  37666. /**
  37667. * Gets a boolean indicating if the node has been disposed
  37668. * @returns true if the node was disposed
  37669. */
  37670. isDisposed(): boolean;
  37671. /**
  37672. * Gets or sets the parent of the node (without keeping the current position in the scene)
  37673. * @see https://doc.babylonjs.com/how_to/parenting
  37674. */
  37675. set parent(parent: Nullable<Node>);
  37676. get parent(): Nullable<Node>;
  37677. /** @hidden */
  37678. _addToSceneRootNodes(): void;
  37679. /** @hidden */
  37680. _removeFromSceneRootNodes(): void;
  37681. private _animationPropertiesOverride;
  37682. /**
  37683. * Gets or sets the animation properties override
  37684. */
  37685. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  37686. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  37687. /**
  37688. * Gets a string identifying the name of the class
  37689. * @returns "Node" string
  37690. */
  37691. getClassName(): string;
  37692. /** @hidden */
  37693. readonly _isNode: boolean;
  37694. /**
  37695. * An event triggered when the mesh is disposed
  37696. */
  37697. onDisposeObservable: Observable<Node>;
  37698. private _onDisposeObserver;
  37699. /**
  37700. * Sets a callback that will be raised when the node will be disposed
  37701. */
  37702. set onDispose(callback: () => void);
  37703. /**
  37704. * Creates a new Node
  37705. * @param name the name and id to be given to this node
  37706. * @param scene the scene this node will be added to
  37707. */
  37708. constructor(name: string, scene?: Nullable<Scene>);
  37709. /**
  37710. * Gets the scene of the node
  37711. * @returns a scene
  37712. */
  37713. getScene(): Scene;
  37714. /**
  37715. * Gets the engine of the node
  37716. * @returns a Engine
  37717. */
  37718. getEngine(): Engine;
  37719. private _behaviors;
  37720. /**
  37721. * Attach a behavior to the node
  37722. * @see https://doc.babylonjs.com/features/behaviour
  37723. * @param behavior defines the behavior to attach
  37724. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  37725. * @returns the current Node
  37726. */
  37727. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  37728. /**
  37729. * Remove an attached behavior
  37730. * @see https://doc.babylonjs.com/features/behaviour
  37731. * @param behavior defines the behavior to attach
  37732. * @returns the current Node
  37733. */
  37734. removeBehavior(behavior: Behavior<Node>): Node;
  37735. /**
  37736. * Gets the list of attached behaviors
  37737. * @see https://doc.babylonjs.com/features/behaviour
  37738. */
  37739. get behaviors(): Behavior<Node>[];
  37740. /**
  37741. * Gets an attached behavior by name
  37742. * @param name defines the name of the behavior to look for
  37743. * @see https://doc.babylonjs.com/features/behaviour
  37744. * @returns null if behavior was not found else the requested behavior
  37745. */
  37746. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  37747. /**
  37748. * Returns the latest update of the World matrix
  37749. * @returns a Matrix
  37750. */
  37751. getWorldMatrix(): Matrix;
  37752. /** @hidden */
  37753. _getWorldMatrixDeterminant(): number;
  37754. /**
  37755. * Returns directly the latest state of the mesh World matrix.
  37756. * A Matrix is returned.
  37757. */
  37758. get worldMatrixFromCache(): Matrix;
  37759. /** @hidden */
  37760. _initCache(): void;
  37761. /** @hidden */
  37762. updateCache(force?: boolean): void;
  37763. /** @hidden */
  37764. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  37765. /** @hidden */
  37766. _updateCache(ignoreParentClass?: boolean): void;
  37767. /** @hidden */
  37768. _isSynchronized(): boolean;
  37769. /** @hidden */
  37770. _markSyncedWithParent(): void;
  37771. /** @hidden */
  37772. isSynchronizedWithParent(): boolean;
  37773. /** @hidden */
  37774. isSynchronized(): boolean;
  37775. /**
  37776. * Is this node ready to be used/rendered
  37777. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  37778. * @return true if the node is ready
  37779. */
  37780. isReady(completeCheck?: boolean): boolean;
  37781. /**
  37782. * Is this node enabled?
  37783. * 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
  37784. * @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
  37785. * @return whether this node (and its parent) is enabled
  37786. */
  37787. isEnabled(checkAncestors?: boolean): boolean;
  37788. /** @hidden */
  37789. protected _syncParentEnabledState(): void;
  37790. /**
  37791. * Set the enabled state of this node
  37792. * @param value defines the new enabled state
  37793. */
  37794. setEnabled(value: boolean): void;
  37795. /**
  37796. * Is this node a descendant of the given node?
  37797. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  37798. * @param ancestor defines the parent node to inspect
  37799. * @returns a boolean indicating if this node is a descendant of the given node
  37800. */
  37801. isDescendantOf(ancestor: Node): boolean;
  37802. /** @hidden */
  37803. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  37804. /**
  37805. * Will return all nodes that have this node as ascendant
  37806. * @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
  37807. * @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
  37808. * @return all children nodes of all types
  37809. */
  37810. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  37811. /**
  37812. * Get all child-meshes of this node
  37813. * @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)
  37814. * @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
  37815. * @returns an array of AbstractMesh
  37816. */
  37817. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  37818. /**
  37819. * Get all direct children of this node
  37820. * @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
  37821. * @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)
  37822. * @returns an array of Node
  37823. */
  37824. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  37825. /** @hidden */
  37826. _setReady(state: boolean): void;
  37827. /**
  37828. * Get an animation by name
  37829. * @param name defines the name of the animation to look for
  37830. * @returns null if not found else the requested animation
  37831. */
  37832. getAnimationByName(name: string): Nullable<Animation>;
  37833. /**
  37834. * Creates an animation range for this node
  37835. * @param name defines the name of the range
  37836. * @param from defines the starting key
  37837. * @param to defines the end key
  37838. */
  37839. createAnimationRange(name: string, from: number, to: number): void;
  37840. /**
  37841. * Delete a specific animation range
  37842. * @param name defines the name of the range to delete
  37843. * @param deleteFrames defines if animation frames from the range must be deleted as well
  37844. */
  37845. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  37846. /**
  37847. * Get an animation range by name
  37848. * @param name defines the name of the animation range to look for
  37849. * @returns null if not found else the requested animation range
  37850. */
  37851. getAnimationRange(name: string): Nullable<AnimationRange>;
  37852. /**
  37853. * Gets the list of all animation ranges defined on this node
  37854. * @returns an array
  37855. */
  37856. getAnimationRanges(): Nullable<AnimationRange>[];
  37857. /**
  37858. * Will start the animation sequence
  37859. * @param name defines the range frames for animation sequence
  37860. * @param loop defines if the animation should loop (false by default)
  37861. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  37862. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  37863. * @returns the object created for this animation. If range does not exist, it will return null
  37864. */
  37865. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  37866. /**
  37867. * Serialize animation ranges into a JSON compatible object
  37868. * @returns serialization object
  37869. */
  37870. serializeAnimationRanges(): any;
  37871. /**
  37872. * Computes the world matrix of the node
  37873. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  37874. * @returns the world matrix
  37875. */
  37876. computeWorldMatrix(force?: boolean): Matrix;
  37877. /**
  37878. * Releases resources associated with this node.
  37879. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  37880. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  37881. */
  37882. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  37883. /**
  37884. * Parse animation range data from a serialization object and store them into a given node
  37885. * @param node defines where to store the animation ranges
  37886. * @param parsedNode defines the serialization object to read data from
  37887. * @param scene defines the hosting scene
  37888. */
  37889. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  37890. /**
  37891. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  37892. * @param includeDescendants Include bounding info from descendants as well (true by default)
  37893. * @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
  37894. * @returns the new bounding vectors
  37895. */
  37896. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  37897. min: Vector3;
  37898. max: Vector3;
  37899. };
  37900. }
  37901. }
  37902. declare module BABYLON {
  37903. /**
  37904. * @hidden
  37905. */
  37906. export class _IAnimationState {
  37907. key: number;
  37908. repeatCount: number;
  37909. workValue?: any;
  37910. loopMode?: number;
  37911. offsetValue?: any;
  37912. highLimitValue?: any;
  37913. }
  37914. /**
  37915. * Class used to store any kind of animation
  37916. */
  37917. export class Animation {
  37918. /**Name of the animation */
  37919. name: string;
  37920. /**Property to animate */
  37921. targetProperty: string;
  37922. /**The frames per second of the animation */
  37923. framePerSecond: number;
  37924. /**The data type of the animation */
  37925. dataType: number;
  37926. /**The loop mode of the animation */
  37927. loopMode?: number | undefined;
  37928. /**Specifies if blending should be enabled */
  37929. enableBlending?: boolean | undefined;
  37930. /**
  37931. * Use matrix interpolation instead of using direct key value when animating matrices
  37932. */
  37933. static AllowMatricesInterpolation: boolean;
  37934. /**
  37935. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  37936. */
  37937. static AllowMatrixDecomposeForInterpolation: boolean;
  37938. /** Define the Url to load snippets */
  37939. static SnippetUrl: string;
  37940. /** Snippet ID if the animation was created from the snippet server */
  37941. snippetId: string;
  37942. /**
  37943. * Stores the key frames of the animation
  37944. */
  37945. private _keys;
  37946. /**
  37947. * Stores the easing function of the animation
  37948. */
  37949. private _easingFunction;
  37950. /**
  37951. * @hidden Internal use only
  37952. */
  37953. _runtimeAnimations: RuntimeAnimation[];
  37954. /**
  37955. * The set of event that will be linked to this animation
  37956. */
  37957. private _events;
  37958. /**
  37959. * Stores an array of target property paths
  37960. */
  37961. targetPropertyPath: string[];
  37962. /**
  37963. * Stores the blending speed of the animation
  37964. */
  37965. blendingSpeed: number;
  37966. /**
  37967. * Stores the animation ranges for the animation
  37968. */
  37969. private _ranges;
  37970. /**
  37971. * @hidden Internal use
  37972. */
  37973. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  37974. /**
  37975. * Sets up an animation
  37976. * @param property The property to animate
  37977. * @param animationType The animation type to apply
  37978. * @param framePerSecond The frames per second of the animation
  37979. * @param easingFunction The easing function used in the animation
  37980. * @returns The created animation
  37981. */
  37982. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  37983. /**
  37984. * Create and start an animation on a node
  37985. * @param name defines the name of the global animation that will be run on all nodes
  37986. * @param node defines the root node where the animation will take place
  37987. * @param targetProperty defines property to animate
  37988. * @param framePerSecond defines the number of frame per second yo use
  37989. * @param totalFrame defines the number of frames in total
  37990. * @param from defines the initial value
  37991. * @param to defines the final value
  37992. * @param loopMode defines which loop mode you want to use (off by default)
  37993. * @param easingFunction defines the easing function to use (linear by default)
  37994. * @param onAnimationEnd defines the callback to call when animation end
  37995. * @returns the animatable created for this animation
  37996. */
  37997. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  37998. /**
  37999. * Create and start an animation on a node and its descendants
  38000. * @param name defines the name of the global animation that will be run on all nodes
  38001. * @param node defines the root node where the animation will take place
  38002. * @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
  38003. * @param targetProperty defines property to animate
  38004. * @param framePerSecond defines the number of frame per second to use
  38005. * @param totalFrame defines the number of frames in total
  38006. * @param from defines the initial value
  38007. * @param to defines the final value
  38008. * @param loopMode defines which loop mode you want to use (off by default)
  38009. * @param easingFunction defines the easing function to use (linear by default)
  38010. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  38011. * @returns the list of animatables created for all nodes
  38012. * @example https://www.babylonjs-playground.com/#MH0VLI
  38013. */
  38014. 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[]>;
  38015. /**
  38016. * Creates a new animation, merges it with the existing animations and starts it
  38017. * @param name Name of the animation
  38018. * @param node Node which contains the scene that begins the animations
  38019. * @param targetProperty Specifies which property to animate
  38020. * @param framePerSecond The frames per second of the animation
  38021. * @param totalFrame The total number of frames
  38022. * @param from The frame at the beginning of the animation
  38023. * @param to The frame at the end of the animation
  38024. * @param loopMode Specifies the loop mode of the animation
  38025. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  38026. * @param onAnimationEnd Callback to run once the animation is complete
  38027. * @returns Nullable animation
  38028. */
  38029. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  38030. /**
  38031. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  38032. * @param sourceAnimation defines the Animation containing keyframes to convert
  38033. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  38034. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  38035. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  38036. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  38037. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  38038. */
  38039. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  38040. /**
  38041. * Transition property of an host to the target Value
  38042. * @param property The property to transition
  38043. * @param targetValue The target Value of the property
  38044. * @param host The object where the property to animate belongs
  38045. * @param scene Scene used to run the animation
  38046. * @param frameRate Framerate (in frame/s) to use
  38047. * @param transition The transition type we want to use
  38048. * @param duration The duration of the animation, in milliseconds
  38049. * @param onAnimationEnd Callback trigger at the end of the animation
  38050. * @returns Nullable animation
  38051. */
  38052. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  38053. /**
  38054. * Return the array of runtime animations currently using this animation
  38055. */
  38056. get runtimeAnimations(): RuntimeAnimation[];
  38057. /**
  38058. * Specifies if any of the runtime animations are currently running
  38059. */
  38060. get hasRunningRuntimeAnimations(): boolean;
  38061. /**
  38062. * Initializes the animation
  38063. * @param name Name of the animation
  38064. * @param targetProperty Property to animate
  38065. * @param framePerSecond The frames per second of the animation
  38066. * @param dataType The data type of the animation
  38067. * @param loopMode The loop mode of the animation
  38068. * @param enableBlending Specifies if blending should be enabled
  38069. */
  38070. constructor(
  38071. /**Name of the animation */
  38072. name: string,
  38073. /**Property to animate */
  38074. targetProperty: string,
  38075. /**The frames per second of the animation */
  38076. framePerSecond: number,
  38077. /**The data type of the animation */
  38078. dataType: number,
  38079. /**The loop mode of the animation */
  38080. loopMode?: number | undefined,
  38081. /**Specifies if blending should be enabled */
  38082. enableBlending?: boolean | undefined);
  38083. /**
  38084. * Converts the animation to a string
  38085. * @param fullDetails support for multiple levels of logging within scene loading
  38086. * @returns String form of the animation
  38087. */
  38088. toString(fullDetails?: boolean): string;
  38089. /**
  38090. * Add an event to this animation
  38091. * @param event Event to add
  38092. */
  38093. addEvent(event: AnimationEvent): void;
  38094. /**
  38095. * Remove all events found at the given frame
  38096. * @param frame The frame to remove events from
  38097. */
  38098. removeEvents(frame: number): void;
  38099. /**
  38100. * Retrieves all the events from the animation
  38101. * @returns Events from the animation
  38102. */
  38103. getEvents(): AnimationEvent[];
  38104. /**
  38105. * Creates an animation range
  38106. * @param name Name of the animation range
  38107. * @param from Starting frame of the animation range
  38108. * @param to Ending frame of the animation
  38109. */
  38110. createRange(name: string, from: number, to: number): void;
  38111. /**
  38112. * Deletes an animation range by name
  38113. * @param name Name of the animation range to delete
  38114. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  38115. */
  38116. deleteRange(name: string, deleteFrames?: boolean): void;
  38117. /**
  38118. * Gets the animation range by name, or null if not defined
  38119. * @param name Name of the animation range
  38120. * @returns Nullable animation range
  38121. */
  38122. getRange(name: string): Nullable<AnimationRange>;
  38123. /**
  38124. * Gets the key frames from the animation
  38125. * @returns The key frames of the animation
  38126. */
  38127. getKeys(): Array<IAnimationKey>;
  38128. /**
  38129. * Gets the highest frame rate of the animation
  38130. * @returns Highest frame rate of the animation
  38131. */
  38132. getHighestFrame(): number;
  38133. /**
  38134. * Gets the easing function of the animation
  38135. * @returns Easing function of the animation
  38136. */
  38137. getEasingFunction(): IEasingFunction;
  38138. /**
  38139. * Sets the easing function of the animation
  38140. * @param easingFunction A custom mathematical formula for animation
  38141. */
  38142. setEasingFunction(easingFunction: EasingFunction): void;
  38143. /**
  38144. * Interpolates a scalar linearly
  38145. * @param startValue Start value of the animation curve
  38146. * @param endValue End value of the animation curve
  38147. * @param gradient Scalar amount to interpolate
  38148. * @returns Interpolated scalar value
  38149. */
  38150. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  38151. /**
  38152. * Interpolates a scalar cubically
  38153. * @param startValue Start value of the animation curve
  38154. * @param outTangent End tangent of the animation
  38155. * @param endValue End value of the animation curve
  38156. * @param inTangent Start tangent of the animation curve
  38157. * @param gradient Scalar amount to interpolate
  38158. * @returns Interpolated scalar value
  38159. */
  38160. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  38161. /**
  38162. * Interpolates a quaternion using a spherical linear interpolation
  38163. * @param startValue Start value of the animation curve
  38164. * @param endValue End value of the animation curve
  38165. * @param gradient Scalar amount to interpolate
  38166. * @returns Interpolated quaternion value
  38167. */
  38168. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  38169. /**
  38170. * Interpolates a quaternion cubically
  38171. * @param startValue Start value of the animation curve
  38172. * @param outTangent End tangent of the animation curve
  38173. * @param endValue End value of the animation curve
  38174. * @param inTangent Start tangent of the animation curve
  38175. * @param gradient Scalar amount to interpolate
  38176. * @returns Interpolated quaternion value
  38177. */
  38178. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  38179. /**
  38180. * Interpolates a Vector3 linearly
  38181. * @param startValue Start value of the animation curve
  38182. * @param endValue End value of the animation curve
  38183. * @param gradient Scalar amount to interpolate
  38184. * @returns Interpolated scalar value
  38185. */
  38186. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  38187. /**
  38188. * Interpolates a Vector3 cubically
  38189. * @param startValue Start value of the animation curve
  38190. * @param outTangent End tangent of the animation
  38191. * @param endValue End value of the animation curve
  38192. * @param inTangent Start tangent of the animation curve
  38193. * @param gradient Scalar amount to interpolate
  38194. * @returns InterpolatedVector3 value
  38195. */
  38196. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  38197. /**
  38198. * Interpolates a Vector2 linearly
  38199. * @param startValue Start value of the animation curve
  38200. * @param endValue End value of the animation curve
  38201. * @param gradient Scalar amount to interpolate
  38202. * @returns Interpolated Vector2 value
  38203. */
  38204. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  38205. /**
  38206. * Interpolates a Vector2 cubically
  38207. * @param startValue Start value of the animation curve
  38208. * @param outTangent End tangent of the animation
  38209. * @param endValue End value of the animation curve
  38210. * @param inTangent Start tangent of the animation curve
  38211. * @param gradient Scalar amount to interpolate
  38212. * @returns Interpolated Vector2 value
  38213. */
  38214. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  38215. /**
  38216. * Interpolates a size linearly
  38217. * @param startValue Start value of the animation curve
  38218. * @param endValue End value of the animation curve
  38219. * @param gradient Scalar amount to interpolate
  38220. * @returns Interpolated Size value
  38221. */
  38222. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  38223. /**
  38224. * Interpolates a Color3 linearly
  38225. * @param startValue Start value of the animation curve
  38226. * @param endValue End value of the animation curve
  38227. * @param gradient Scalar amount to interpolate
  38228. * @returns Interpolated Color3 value
  38229. */
  38230. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  38231. /**
  38232. * Interpolates a Color4 linearly
  38233. * @param startValue Start value of the animation curve
  38234. * @param endValue End value of the animation curve
  38235. * @param gradient Scalar amount to interpolate
  38236. * @returns Interpolated Color3 value
  38237. */
  38238. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  38239. /**
  38240. * @hidden Internal use only
  38241. */
  38242. _getKeyValue(value: any): any;
  38243. /**
  38244. * @hidden Internal use only
  38245. */
  38246. _interpolate(currentFrame: number, state: _IAnimationState): any;
  38247. /**
  38248. * Defines the function to use to interpolate matrices
  38249. * @param startValue defines the start matrix
  38250. * @param endValue defines the end matrix
  38251. * @param gradient defines the gradient between both matrices
  38252. * @param result defines an optional target matrix where to store the interpolation
  38253. * @returns the interpolated matrix
  38254. */
  38255. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  38256. /**
  38257. * Makes a copy of the animation
  38258. * @returns Cloned animation
  38259. */
  38260. clone(): Animation;
  38261. /**
  38262. * Sets the key frames of the animation
  38263. * @param values The animation key frames to set
  38264. */
  38265. setKeys(values: Array<IAnimationKey>): void;
  38266. /**
  38267. * Serializes the animation to an object
  38268. * @returns Serialized object
  38269. */
  38270. serialize(): any;
  38271. /**
  38272. * Float animation type
  38273. */
  38274. static readonly ANIMATIONTYPE_FLOAT: number;
  38275. /**
  38276. * Vector3 animation type
  38277. */
  38278. static readonly ANIMATIONTYPE_VECTOR3: number;
  38279. /**
  38280. * Quaternion animation type
  38281. */
  38282. static readonly ANIMATIONTYPE_QUATERNION: number;
  38283. /**
  38284. * Matrix animation type
  38285. */
  38286. static readonly ANIMATIONTYPE_MATRIX: number;
  38287. /**
  38288. * Color3 animation type
  38289. */
  38290. static readonly ANIMATIONTYPE_COLOR3: number;
  38291. /**
  38292. * Color3 animation type
  38293. */
  38294. static readonly ANIMATIONTYPE_COLOR4: number;
  38295. /**
  38296. * Vector2 animation type
  38297. */
  38298. static readonly ANIMATIONTYPE_VECTOR2: number;
  38299. /**
  38300. * Size animation type
  38301. */
  38302. static readonly ANIMATIONTYPE_SIZE: number;
  38303. /**
  38304. * Relative Loop Mode
  38305. */
  38306. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  38307. /**
  38308. * Cycle Loop Mode
  38309. */
  38310. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  38311. /**
  38312. * Constant Loop Mode
  38313. */
  38314. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  38315. /** @hidden */
  38316. static _UniversalLerp(left: any, right: any, amount: number): any;
  38317. /**
  38318. * Parses an animation object and creates an animation
  38319. * @param parsedAnimation Parsed animation object
  38320. * @returns Animation object
  38321. */
  38322. static Parse(parsedAnimation: any): Animation;
  38323. /**
  38324. * Appends the serialized animations from the source animations
  38325. * @param source Source containing the animations
  38326. * @param destination Target to store the animations
  38327. */
  38328. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  38329. /**
  38330. * Creates a new animation or an array of animations from a snippet saved in a remote file
  38331. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  38332. * @param url defines the url to load from
  38333. * @returns a promise that will resolve to the new animation or an array of animations
  38334. */
  38335. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  38336. /**
  38337. * Creates an animation or an array of animations from a snippet saved by the Inspector
  38338. * @param snippetId defines the snippet to load
  38339. * @returns a promise that will resolve to the new animation or a new array of animations
  38340. */
  38341. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  38342. }
  38343. }
  38344. declare module BABYLON {
  38345. /**
  38346. * Interface containing an array of animations
  38347. */
  38348. export interface IAnimatable {
  38349. /**
  38350. * Array of animations
  38351. */
  38352. animations: Nullable<Array<Animation>>;
  38353. }
  38354. }
  38355. declare module BABYLON {
  38356. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  38357. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38358. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38359. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38360. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38361. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38362. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38363. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38364. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38365. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38366. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38367. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38368. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38369. /**
  38370. * Decorator used to define property that can be serialized as reference to a camera
  38371. * @param sourceName defines the name of the property to decorate
  38372. */
  38373. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38374. /**
  38375. * Class used to help serialization objects
  38376. */
  38377. export class SerializationHelper {
  38378. /** @hidden */
  38379. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  38380. /** @hidden */
  38381. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  38382. /** @hidden */
  38383. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  38384. /** @hidden */
  38385. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  38386. /**
  38387. * Appends the serialized animations from the source animations
  38388. * @param source Source containing the animations
  38389. * @param destination Target to store the animations
  38390. */
  38391. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  38392. /**
  38393. * Static function used to serialized a specific entity
  38394. * @param entity defines the entity to serialize
  38395. * @param serializationObject defines the optional target object where serialization data will be stored
  38396. * @returns a JSON compatible object representing the serialization of the entity
  38397. */
  38398. static Serialize<T>(entity: T, serializationObject?: any): any;
  38399. /**
  38400. * Creates a new entity from a serialization data object
  38401. * @param creationFunction defines a function used to instanciated the new entity
  38402. * @param source defines the source serialization data
  38403. * @param scene defines the hosting scene
  38404. * @param rootUrl defines the root url for resources
  38405. * @returns a new entity
  38406. */
  38407. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  38408. /**
  38409. * Clones an object
  38410. * @param creationFunction defines the function used to instanciate the new object
  38411. * @param source defines the source object
  38412. * @returns the cloned object
  38413. */
  38414. static Clone<T>(creationFunction: () => T, source: T): T;
  38415. /**
  38416. * Instanciates a new object based on a source one (some data will be shared between both object)
  38417. * @param creationFunction defines the function used to instanciate the new object
  38418. * @param source defines the source object
  38419. * @returns the new object
  38420. */
  38421. static Instanciate<T>(creationFunction: () => T, source: T): T;
  38422. }
  38423. }
  38424. declare module BABYLON {
  38425. /**
  38426. * This is the base class of all the camera used in the application.
  38427. * @see https://doc.babylonjs.com/features/cameras
  38428. */
  38429. export class Camera extends Node {
  38430. /** @hidden */
  38431. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  38432. /**
  38433. * This is the default projection mode used by the cameras.
  38434. * It helps recreating a feeling of perspective and better appreciate depth.
  38435. * This is the best way to simulate real life cameras.
  38436. */
  38437. static readonly PERSPECTIVE_CAMERA: number;
  38438. /**
  38439. * This helps creating camera with an orthographic mode.
  38440. * 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.
  38441. */
  38442. static readonly ORTHOGRAPHIC_CAMERA: number;
  38443. /**
  38444. * This is the default FOV mode for perspective cameras.
  38445. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  38446. */
  38447. static readonly FOVMODE_VERTICAL_FIXED: number;
  38448. /**
  38449. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  38450. */
  38451. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  38452. /**
  38453. * This specifies there is no need for a camera rig.
  38454. * Basically only one eye is rendered corresponding to the camera.
  38455. */
  38456. static readonly RIG_MODE_NONE: number;
  38457. /**
  38458. * Simulates a camera Rig with one blue eye and one red eye.
  38459. * This can be use with 3d blue and red glasses.
  38460. */
  38461. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  38462. /**
  38463. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  38464. */
  38465. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  38466. /**
  38467. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  38468. */
  38469. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  38470. /**
  38471. * Defines that both eyes of the camera will be rendered over under each other.
  38472. */
  38473. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  38474. /**
  38475. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  38476. */
  38477. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  38478. /**
  38479. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  38480. */
  38481. static readonly RIG_MODE_VR: number;
  38482. /**
  38483. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  38484. */
  38485. static readonly RIG_MODE_WEBVR: number;
  38486. /**
  38487. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  38488. */
  38489. static readonly RIG_MODE_CUSTOM: number;
  38490. /**
  38491. * Defines if by default attaching controls should prevent the default javascript event to continue.
  38492. */
  38493. static ForceAttachControlToAlwaysPreventDefault: boolean;
  38494. /**
  38495. * Define the input manager associated with the camera.
  38496. */
  38497. inputs: CameraInputsManager<Camera>;
  38498. /** @hidden */
  38499. _position: Vector3;
  38500. /**
  38501. * Define the current local position of the camera in the scene
  38502. */
  38503. get position(): Vector3;
  38504. set position(newPosition: Vector3);
  38505. protected _upVector: Vector3;
  38506. /**
  38507. * The vector the camera should consider as up.
  38508. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  38509. */
  38510. set upVector(vec: Vector3);
  38511. get upVector(): Vector3;
  38512. /**
  38513. * Define the current limit on the left side for an orthographic camera
  38514. * In scene unit
  38515. */
  38516. orthoLeft: Nullable<number>;
  38517. /**
  38518. * Define the current limit on the right side for an orthographic camera
  38519. * In scene unit
  38520. */
  38521. orthoRight: Nullable<number>;
  38522. /**
  38523. * Define the current limit on the bottom side for an orthographic camera
  38524. * In scene unit
  38525. */
  38526. orthoBottom: Nullable<number>;
  38527. /**
  38528. * Define the current limit on the top side for an orthographic camera
  38529. * In scene unit
  38530. */
  38531. orthoTop: Nullable<number>;
  38532. /**
  38533. * Field Of View is set in Radians. (default is 0.8)
  38534. */
  38535. fov: number;
  38536. /**
  38537. * Define the minimum distance the camera can see from.
  38538. * This is important to note that the depth buffer are not infinite and the closer it starts
  38539. * the more your scene might encounter depth fighting issue.
  38540. */
  38541. minZ: number;
  38542. /**
  38543. * Define the maximum distance the camera can see to.
  38544. * This is important to note that the depth buffer are not infinite and the further it end
  38545. * the more your scene might encounter depth fighting issue.
  38546. */
  38547. maxZ: number;
  38548. /**
  38549. * Define the default inertia of the camera.
  38550. * This helps giving a smooth feeling to the camera movement.
  38551. */
  38552. inertia: number;
  38553. /**
  38554. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  38555. */
  38556. mode: number;
  38557. /**
  38558. * Define whether the camera is intermediate.
  38559. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  38560. */
  38561. isIntermediate: boolean;
  38562. /**
  38563. * Define the viewport of the camera.
  38564. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  38565. */
  38566. viewport: Viewport;
  38567. /**
  38568. * Restricts the camera to viewing objects with the same layerMask.
  38569. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  38570. */
  38571. layerMask: number;
  38572. /**
  38573. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  38574. */
  38575. fovMode: number;
  38576. /**
  38577. * Rig mode of the camera.
  38578. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  38579. * This is normally controlled byt the camera themselves as internal use.
  38580. */
  38581. cameraRigMode: number;
  38582. /**
  38583. * Defines the distance between both "eyes" in case of a RIG
  38584. */
  38585. interaxialDistance: number;
  38586. /**
  38587. * Defines if stereoscopic rendering is done side by side or over under.
  38588. */
  38589. isStereoscopicSideBySide: boolean;
  38590. /**
  38591. * 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
  38592. * This is pretty helpful if you wish to make a camera render to a texture you could reuse somewhere
  38593. * else in the scene. (Eg. security camera)
  38594. *
  38595. * 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)
  38596. */
  38597. customRenderTargets: RenderTargetTexture[];
  38598. /**
  38599. * When set, the camera will render to this render target instead of the default canvas
  38600. *
  38601. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  38602. */
  38603. outputRenderTarget: Nullable<RenderTargetTexture>;
  38604. /**
  38605. * Observable triggered when the camera view matrix has changed.
  38606. */
  38607. onViewMatrixChangedObservable: Observable<Camera>;
  38608. /**
  38609. * Observable triggered when the camera Projection matrix has changed.
  38610. */
  38611. onProjectionMatrixChangedObservable: Observable<Camera>;
  38612. /**
  38613. * Observable triggered when the inputs have been processed.
  38614. */
  38615. onAfterCheckInputsObservable: Observable<Camera>;
  38616. /**
  38617. * Observable triggered when reset has been called and applied to the camera.
  38618. */
  38619. onRestoreStateObservable: Observable<Camera>;
  38620. /**
  38621. * Is this camera a part of a rig system?
  38622. */
  38623. isRigCamera: boolean;
  38624. /**
  38625. * If isRigCamera set to true this will be set with the parent camera.
  38626. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  38627. */
  38628. rigParent?: Camera;
  38629. /** @hidden */
  38630. _cameraRigParams: any;
  38631. /** @hidden */
  38632. _rigCameras: Camera[];
  38633. /** @hidden */
  38634. _rigPostProcess: Nullable<PostProcess>;
  38635. protected _webvrViewMatrix: Matrix;
  38636. /** @hidden */
  38637. _skipRendering: boolean;
  38638. /** @hidden */
  38639. _projectionMatrix: Matrix;
  38640. /** @hidden */
  38641. _postProcesses: Nullable<PostProcess>[];
  38642. /** @hidden */
  38643. _activeMeshes: SmartArray<AbstractMesh>;
  38644. protected _globalPosition: Vector3;
  38645. /** @hidden */
  38646. _computedViewMatrix: Matrix;
  38647. private _doNotComputeProjectionMatrix;
  38648. private _transformMatrix;
  38649. private _frustumPlanes;
  38650. private _refreshFrustumPlanes;
  38651. private _storedFov;
  38652. private _stateStored;
  38653. /**
  38654. * Instantiates a new camera object.
  38655. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  38656. * @see https://doc.babylonjs.com/features/cameras
  38657. * @param name Defines the name of the camera in the scene
  38658. * @param position Defines the position of the camera
  38659. * @param scene Defines the scene the camera belongs too
  38660. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  38661. */
  38662. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38663. /**
  38664. * Store current camera state (fov, position, etc..)
  38665. * @returns the camera
  38666. */
  38667. storeState(): Camera;
  38668. /**
  38669. * Restores the camera state values if it has been stored. You must call storeState() first
  38670. */
  38671. protected _restoreStateValues(): boolean;
  38672. /**
  38673. * Restored camera state. You must call storeState() first.
  38674. * @returns true if restored and false otherwise
  38675. */
  38676. restoreState(): boolean;
  38677. /**
  38678. * Gets the class name of the camera.
  38679. * @returns the class name
  38680. */
  38681. getClassName(): string;
  38682. /** @hidden */
  38683. readonly _isCamera: boolean;
  38684. /**
  38685. * Gets a string representation of the camera useful for debug purpose.
  38686. * @param fullDetails Defines that a more verboe level of logging is required
  38687. * @returns the string representation
  38688. */
  38689. toString(fullDetails?: boolean): string;
  38690. /**
  38691. * Gets the current world space position of the camera.
  38692. */
  38693. get globalPosition(): Vector3;
  38694. /**
  38695. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  38696. * @returns the active meshe list
  38697. */
  38698. getActiveMeshes(): SmartArray<AbstractMesh>;
  38699. /**
  38700. * Check whether a mesh is part of the current active mesh list of the camera
  38701. * @param mesh Defines the mesh to check
  38702. * @returns true if active, false otherwise
  38703. */
  38704. isActiveMesh(mesh: Mesh): boolean;
  38705. /**
  38706. * Is this camera ready to be used/rendered
  38707. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  38708. * @return true if the camera is ready
  38709. */
  38710. isReady(completeCheck?: boolean): boolean;
  38711. /** @hidden */
  38712. _initCache(): void;
  38713. /** @hidden */
  38714. _updateCache(ignoreParentClass?: boolean): void;
  38715. /** @hidden */
  38716. _isSynchronized(): boolean;
  38717. /** @hidden */
  38718. _isSynchronizedViewMatrix(): boolean;
  38719. /** @hidden */
  38720. _isSynchronizedProjectionMatrix(): boolean;
  38721. /**
  38722. * Attach the input controls to a specific dom element to get the input from.
  38723. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38724. */
  38725. attachControl(noPreventDefault?: boolean): void;
  38726. /**
  38727. * Attach the input controls to a specific dom element to get the input from.
  38728. * @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
  38729. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38730. * BACK COMPAT SIGNATURE ONLY.
  38731. */
  38732. attachControl(ignored: any, noPreventDefault?: boolean): void;
  38733. /**
  38734. * Detach the current controls from the specified dom element.
  38735. */
  38736. detachControl(): void;
  38737. /**
  38738. * Detach the current controls from the specified dom element.
  38739. * @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
  38740. */
  38741. detachControl(ignored: any): void;
  38742. /**
  38743. * Update the camera state according to the different inputs gathered during the frame.
  38744. */
  38745. update(): void;
  38746. /** @hidden */
  38747. _checkInputs(): void;
  38748. /** @hidden */
  38749. get rigCameras(): Camera[];
  38750. /**
  38751. * Gets the post process used by the rig cameras
  38752. */
  38753. get rigPostProcess(): Nullable<PostProcess>;
  38754. /**
  38755. * Internal, gets the first post process.
  38756. * @returns the first post process to be run on this camera.
  38757. */
  38758. _getFirstPostProcess(): Nullable<PostProcess>;
  38759. private _cascadePostProcessesToRigCams;
  38760. /**
  38761. * Attach a post process to the camera.
  38762. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  38763. * @param postProcess The post process to attach to the camera
  38764. * @param insertAt The position of the post process in case several of them are in use in the scene
  38765. * @returns the position the post process has been inserted at
  38766. */
  38767. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  38768. /**
  38769. * Detach a post process to the camera.
  38770. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  38771. * @param postProcess The post process to detach from the camera
  38772. */
  38773. detachPostProcess(postProcess: PostProcess): void;
  38774. /**
  38775. * Gets the current world matrix of the camera
  38776. */
  38777. getWorldMatrix(): Matrix;
  38778. /** @hidden */
  38779. _getViewMatrix(): Matrix;
  38780. /**
  38781. * Gets the current view matrix of the camera.
  38782. * @param force forces the camera to recompute the matrix without looking at the cached state
  38783. * @returns the view matrix
  38784. */
  38785. getViewMatrix(force?: boolean): Matrix;
  38786. /**
  38787. * Freeze the projection matrix.
  38788. * It will prevent the cache check of the camera projection compute and can speed up perf
  38789. * if no parameter of the camera are meant to change
  38790. * @param projection Defines manually a projection if necessary
  38791. */
  38792. freezeProjectionMatrix(projection?: Matrix): void;
  38793. /**
  38794. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  38795. */
  38796. unfreezeProjectionMatrix(): void;
  38797. /**
  38798. * Gets the current projection matrix of the camera.
  38799. * @param force forces the camera to recompute the matrix without looking at the cached state
  38800. * @returns the projection matrix
  38801. */
  38802. getProjectionMatrix(force?: boolean): Matrix;
  38803. /**
  38804. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  38805. * @returns a Matrix
  38806. */
  38807. getTransformationMatrix(): Matrix;
  38808. private _updateFrustumPlanes;
  38809. /**
  38810. * Checks if a cullable object (mesh...) is in the camera frustum
  38811. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  38812. * @param target The object to check
  38813. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  38814. * @returns true if the object is in frustum otherwise false
  38815. */
  38816. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  38817. /**
  38818. * Checks if a cullable object (mesh...) is in the camera frustum
  38819. * Unlike isInFrustum this checks the full bounding box
  38820. * @param target The object to check
  38821. * @returns true if the object is in frustum otherwise false
  38822. */
  38823. isCompletelyInFrustum(target: ICullable): boolean;
  38824. /**
  38825. * Gets a ray in the forward direction from the camera.
  38826. * @param length Defines the length of the ray to create
  38827. * @param transform Defines the transform to apply to the ray, by default the world matrix is used to create a workd space ray
  38828. * @param origin Defines the start point of the ray which defaults to the camera position
  38829. * @returns the forward ray
  38830. */
  38831. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  38832. /**
  38833. * Gets a ray in the forward direction from the camera.
  38834. * @param refRay the ray to (re)use when setting the values
  38835. * @param length Defines the length of the ray to create
  38836. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  38837. * @param origin Defines the start point of the ray which defaults to the camera position
  38838. * @returns the forward ray
  38839. */
  38840. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  38841. /**
  38842. * Releases resources associated with this node.
  38843. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  38844. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  38845. */
  38846. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  38847. /** @hidden */
  38848. _isLeftCamera: boolean;
  38849. /**
  38850. * Gets the left camera of a rig setup in case of Rigged Camera
  38851. */
  38852. get isLeftCamera(): boolean;
  38853. /** @hidden */
  38854. _isRightCamera: boolean;
  38855. /**
  38856. * Gets the right camera of a rig setup in case of Rigged Camera
  38857. */
  38858. get isRightCamera(): boolean;
  38859. /**
  38860. * Gets the left camera of a rig setup in case of Rigged Camera
  38861. */
  38862. get leftCamera(): Nullable<FreeCamera>;
  38863. /**
  38864. * Gets the right camera of a rig setup in case of Rigged Camera
  38865. */
  38866. get rightCamera(): Nullable<FreeCamera>;
  38867. /**
  38868. * Gets the left camera target of a rig setup in case of Rigged Camera
  38869. * @returns the target position
  38870. */
  38871. getLeftTarget(): Nullable<Vector3>;
  38872. /**
  38873. * Gets the right camera target of a rig setup in case of Rigged Camera
  38874. * @returns the target position
  38875. */
  38876. getRightTarget(): Nullable<Vector3>;
  38877. /**
  38878. * @hidden
  38879. */
  38880. setCameraRigMode(mode: number, rigParams: any): void;
  38881. /** @hidden */
  38882. static _setStereoscopicRigMode(camera: Camera): void;
  38883. /** @hidden */
  38884. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  38885. /** @hidden */
  38886. static _setVRRigMode(camera: Camera, rigParams: any): void;
  38887. /** @hidden */
  38888. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  38889. /** @hidden */
  38890. _getVRProjectionMatrix(): Matrix;
  38891. protected _updateCameraRotationMatrix(): void;
  38892. protected _updateWebVRCameraRotationMatrix(): void;
  38893. /**
  38894. * This function MUST be overwritten by the different WebVR cameras available.
  38895. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  38896. * @hidden
  38897. */
  38898. _getWebVRProjectionMatrix(): Matrix;
  38899. /**
  38900. * This function MUST be overwritten by the different WebVR cameras available.
  38901. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  38902. * @hidden
  38903. */
  38904. _getWebVRViewMatrix(): Matrix;
  38905. /** @hidden */
  38906. setCameraRigParameter(name: string, value: any): void;
  38907. /**
  38908. * needs to be overridden by children so sub has required properties to be copied
  38909. * @hidden
  38910. */
  38911. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  38912. /**
  38913. * May need to be overridden by children
  38914. * @hidden
  38915. */
  38916. _updateRigCameras(): void;
  38917. /** @hidden */
  38918. _setupInputs(): void;
  38919. /**
  38920. * Serialiaze the camera setup to a json representation
  38921. * @returns the JSON representation
  38922. */
  38923. serialize(): any;
  38924. /**
  38925. * Clones the current camera.
  38926. * @param name The cloned camera name
  38927. * @returns the cloned camera
  38928. */
  38929. clone(name: string): Camera;
  38930. /**
  38931. * Gets the direction of the camera relative to a given local axis.
  38932. * @param localAxis Defines the reference axis to provide a relative direction.
  38933. * @return the direction
  38934. */
  38935. getDirection(localAxis: Vector3): Vector3;
  38936. /**
  38937. * Returns the current camera absolute rotation
  38938. */
  38939. get absoluteRotation(): Quaternion;
  38940. /**
  38941. * Gets the direction of the camera relative to a given local axis into a passed vector.
  38942. * @param localAxis Defines the reference axis to provide a relative direction.
  38943. * @param result Defines the vector to store the result in
  38944. */
  38945. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  38946. /**
  38947. * Gets a camera constructor for a given camera type
  38948. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  38949. * @param name The name of the camera the result will be able to instantiate
  38950. * @param scene The scene the result will construct the camera in
  38951. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  38952. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  38953. * @returns a factory method to construct the camera
  38954. */
  38955. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  38956. /**
  38957. * Compute the world matrix of the camera.
  38958. * @returns the camera world matrix
  38959. */
  38960. computeWorldMatrix(): Matrix;
  38961. /**
  38962. * Parse a JSON and creates the camera from the parsed information
  38963. * @param parsedCamera The JSON to parse
  38964. * @param scene The scene to instantiate the camera in
  38965. * @returns the newly constructed camera
  38966. */
  38967. static Parse(parsedCamera: any, scene: Scene): Camera;
  38968. }
  38969. }
  38970. declare module BABYLON {
  38971. /**
  38972. * PostProcessManager is used to manage one or more post processes or post process pipelines
  38973. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  38974. */
  38975. export class PostProcessManager {
  38976. private _scene;
  38977. private _indexBuffer;
  38978. private _vertexBuffers;
  38979. /**
  38980. * Creates a new instance PostProcess
  38981. * @param scene The scene that the post process is associated with.
  38982. */
  38983. constructor(scene: Scene);
  38984. private _prepareBuffers;
  38985. private _buildIndexBuffer;
  38986. /**
  38987. * Rebuilds the vertex buffers of the manager.
  38988. * @hidden
  38989. */
  38990. _rebuild(): void;
  38991. /**
  38992. * Prepares a frame to be run through a post process.
  38993. * @param sourceTexture The input texture to the post processes. (default: null)
  38994. * @param postProcesses An array of post processes to be run. (default: null)
  38995. * @returns True if the post processes were able to be run.
  38996. * @hidden
  38997. */
  38998. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  38999. /**
  39000. * Manually render a set of post processes to a texture.
  39001. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  39002. * @param postProcesses An array of post processes to be run.
  39003. * @param targetTexture The target texture to render to.
  39004. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  39005. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  39006. * @param lodLevel defines which lod of the texture to render to
  39007. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  39008. */
  39009. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  39010. /**
  39011. * Finalize the result of the output of the postprocesses.
  39012. * @param doNotPresent If true the result will not be displayed to the screen.
  39013. * @param targetTexture The target texture to render to.
  39014. * @param faceIndex The index of the face to bind the target texture to.
  39015. * @param postProcesses The array of post processes to render.
  39016. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  39017. * @hidden
  39018. */
  39019. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  39020. /**
  39021. * Disposes of the post process manager.
  39022. */
  39023. dispose(): void;
  39024. }
  39025. }
  39026. declare module BABYLON {
  39027. /**
  39028. * This Helps creating a texture that will be created from a camera in your scene.
  39029. * It is basically a dynamic texture that could be used to create special effects for instance.
  39030. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  39031. */
  39032. export class RenderTargetTexture extends Texture {
  39033. /**
  39034. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  39035. */
  39036. static readonly REFRESHRATE_RENDER_ONCE: number;
  39037. /**
  39038. * The texture will only be rendered rendered every frame and is recommended for dynamic contents.
  39039. */
  39040. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  39041. /**
  39042. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  39043. * the central point of your effect and can save a lot of performances.
  39044. */
  39045. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  39046. /**
  39047. * Use this predicate to dynamically define the list of mesh you want to render.
  39048. * If set, the renderList property will be overwritten.
  39049. */
  39050. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  39051. private _renderList;
  39052. /**
  39053. * Use this list to define the list of mesh you want to render.
  39054. */
  39055. get renderList(): Nullable<Array<AbstractMesh>>;
  39056. set renderList(value: Nullable<Array<AbstractMesh>>);
  39057. /**
  39058. * Use this function to overload the renderList array at rendering time.
  39059. * Return null to render with the current renderList, else return the list of meshes to use for rendering.
  39060. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  39061. * the cube (if the RTT is a cube, else layerOrFace=0).
  39062. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  39063. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  39064. * hold dummy elements!
  39065. */
  39066. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  39067. private _hookArray;
  39068. /**
  39069. * Define if particles should be rendered in your texture.
  39070. */
  39071. renderParticles: boolean;
  39072. /**
  39073. * Define if sprites should be rendered in your texture.
  39074. */
  39075. renderSprites: boolean;
  39076. /**
  39077. * Define the camera used to render the texture.
  39078. */
  39079. activeCamera: Nullable<Camera>;
  39080. /**
  39081. * Override the mesh isReady function with your own one.
  39082. */
  39083. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  39084. /**
  39085. * Override the render function of the texture with your own one.
  39086. */
  39087. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  39088. /**
  39089. * Define if camera post processes should be use while rendering the texture.
  39090. */
  39091. useCameraPostProcesses: boolean;
  39092. /**
  39093. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  39094. */
  39095. ignoreCameraViewport: boolean;
  39096. private _postProcessManager;
  39097. /**
  39098. * Post-processes for this render target
  39099. */
  39100. get postProcesses(): PostProcess[];
  39101. private _postProcesses;
  39102. private _resizeObserver;
  39103. private get _prePassEnabled();
  39104. /**
  39105. * An event triggered when the texture is unbind.
  39106. */
  39107. onBeforeBindObservable: Observable<RenderTargetTexture>;
  39108. /**
  39109. * An event triggered when the texture is unbind.
  39110. */
  39111. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  39112. private _onAfterUnbindObserver;
  39113. /**
  39114. * Set a after unbind callback in the texture.
  39115. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  39116. */
  39117. set onAfterUnbind(callback: () => void);
  39118. /**
  39119. * An event triggered before rendering the texture
  39120. */
  39121. onBeforeRenderObservable: Observable<number>;
  39122. private _onBeforeRenderObserver;
  39123. /**
  39124. * Set a before render callback in the texture.
  39125. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  39126. */
  39127. set onBeforeRender(callback: (faceIndex: number) => void);
  39128. /**
  39129. * An event triggered after rendering the texture
  39130. */
  39131. onAfterRenderObservable: Observable<number>;
  39132. private _onAfterRenderObserver;
  39133. /**
  39134. * Set a after render callback in the texture.
  39135. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  39136. */
  39137. set onAfterRender(callback: (faceIndex: number) => void);
  39138. /**
  39139. * An event triggered after the texture clear
  39140. */
  39141. onClearObservable: Observable<Engine>;
  39142. private _onClearObserver;
  39143. /**
  39144. * Set a clear callback in the texture.
  39145. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  39146. */
  39147. set onClear(callback: (Engine: Engine) => void);
  39148. /**
  39149. * An event triggered when the texture is resized.
  39150. */
  39151. onResizeObservable: Observable<RenderTargetTexture>;
  39152. /**
  39153. * Define the clear color of the Render Target if it should be different from the scene.
  39154. */
  39155. clearColor: Color4;
  39156. protected _size: number | {
  39157. width: number;
  39158. height: number;
  39159. layers?: number;
  39160. };
  39161. protected _initialSizeParameter: number | {
  39162. width: number;
  39163. height: number;
  39164. } | {
  39165. ratio: number;
  39166. };
  39167. protected _sizeRatio: Nullable<number>;
  39168. /** @hidden */
  39169. _generateMipMaps: boolean;
  39170. protected _renderingManager: RenderingManager;
  39171. /** @hidden */
  39172. _waitingRenderList?: string[];
  39173. protected _doNotChangeAspectRatio: boolean;
  39174. protected _currentRefreshId: number;
  39175. protected _refreshRate: number;
  39176. protected _textureMatrix: Matrix;
  39177. protected _samples: number;
  39178. protected _renderTargetOptions: RenderTargetCreationOptions;
  39179. /**
  39180. * Gets render target creation options that were used.
  39181. */
  39182. get renderTargetOptions(): RenderTargetCreationOptions;
  39183. protected _onRatioRescale(): void;
  39184. /**
  39185. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  39186. * It must define where the camera used to render the texture is set
  39187. */
  39188. boundingBoxPosition: Vector3;
  39189. private _boundingBoxSize;
  39190. /**
  39191. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  39192. * When defined, the cubemap will switch to local mode
  39193. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  39194. * @example https://www.babylonjs-playground.com/#RNASML
  39195. */
  39196. set boundingBoxSize(value: Vector3);
  39197. get boundingBoxSize(): Vector3;
  39198. /**
  39199. * In case the RTT has been created with a depth texture, get the associated
  39200. * depth texture.
  39201. * Otherwise, return null.
  39202. */
  39203. get depthStencilTexture(): Nullable<InternalTexture>;
  39204. /**
  39205. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post process
  39206. * or used a shadow, depth texture...
  39207. * @param name The friendly name of the texture
  39208. * @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)
  39209. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  39210. * @param generateMipMaps True if mip maps need to be generated after render.
  39211. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  39212. * @param type The type of the buffer in the RTT (int, half float, float...)
  39213. * @param isCube True if a cube texture needs to be created
  39214. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  39215. * @param generateDepthBuffer True to generate a depth buffer
  39216. * @param generateStencilBuffer True to generate a stencil buffer
  39217. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  39218. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  39219. * @param delayAllocation if the texture allocation should be delayed (default: false)
  39220. * @param samples sample count to use when creating the RTT
  39221. */
  39222. constructor(name: string, size: number | {
  39223. width: number;
  39224. height: number;
  39225. layers?: number;
  39226. } | {
  39227. ratio: number;
  39228. }, 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);
  39229. /**
  39230. * Creates a depth stencil texture.
  39231. * This is only available in WebGL 2 or with the depth texture extension available.
  39232. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  39233. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  39234. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  39235. * @param samples sample count of the depth/stencil texture
  39236. */
  39237. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean, samples?: number): void;
  39238. private _processSizeParameter;
  39239. /**
  39240. * Define the number of samples to use in case of MSAA.
  39241. * It defaults to one meaning no MSAA has been enabled.
  39242. */
  39243. get samples(): number;
  39244. set samples(value: number);
  39245. /**
  39246. * Resets the refresh counter of the texture and start bak from scratch.
  39247. * Could be useful to regenerate the texture if it is setup to render only once.
  39248. */
  39249. resetRefreshCounter(): void;
  39250. /**
  39251. * Define the refresh rate of the texture or the rendering frequency.
  39252. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  39253. */
  39254. get refreshRate(): number;
  39255. set refreshRate(value: number);
  39256. /**
  39257. * Adds a post process to the render target rendering passes.
  39258. * @param postProcess define the post process to add
  39259. */
  39260. addPostProcess(postProcess: PostProcess): void;
  39261. /**
  39262. * Clear all the post processes attached to the render target
  39263. * @param dispose define if the cleared post processes should also be disposed (false by default)
  39264. */
  39265. clearPostProcesses(dispose?: boolean): void;
  39266. /**
  39267. * Remove one of the post process from the list of attached post processes to the texture
  39268. * @param postProcess define the post process to remove from the list
  39269. */
  39270. removePostProcess(postProcess: PostProcess): void;
  39271. /** @hidden */
  39272. _shouldRender(): boolean;
  39273. /**
  39274. * Gets the actual render size of the texture.
  39275. * @returns the width of the render size
  39276. */
  39277. getRenderSize(): number;
  39278. /**
  39279. * Gets the actual render width of the texture.
  39280. * @returns the width of the render size
  39281. */
  39282. getRenderWidth(): number;
  39283. /**
  39284. * Gets the actual render height of the texture.
  39285. * @returns the height of the render size
  39286. */
  39287. getRenderHeight(): number;
  39288. /**
  39289. * Gets the actual number of layers of the texture.
  39290. * @returns the number of layers
  39291. */
  39292. getRenderLayers(): number;
  39293. /**
  39294. * Get if the texture can be rescaled or not.
  39295. */
  39296. get canRescale(): boolean;
  39297. /**
  39298. * Resize the texture using a ratio.
  39299. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  39300. */
  39301. scale(ratio: number): void;
  39302. /**
  39303. * Get the texture reflection matrix used to rotate/transform the reflection.
  39304. * @returns the reflection matrix
  39305. */
  39306. getReflectionTextureMatrix(): Matrix;
  39307. /**
  39308. * Resize the texture to a new desired size.
  39309. * Be careful as it will recreate all the data in the new texture.
  39310. * @param size Define the new size. It can be:
  39311. * - a number for squared texture,
  39312. * - an object containing { width: number, height: number }
  39313. * - or an object containing a ratio { ratio: number }
  39314. */
  39315. resize(size: number | {
  39316. width: number;
  39317. height: number;
  39318. } | {
  39319. ratio: number;
  39320. }): void;
  39321. private _defaultRenderListPrepared;
  39322. /**
  39323. * Renders all the objects from the render list into the texture.
  39324. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  39325. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  39326. */
  39327. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  39328. private _bestReflectionRenderTargetDimension;
  39329. private _prepareRenderingManager;
  39330. /**
  39331. * @hidden
  39332. * @param faceIndex face index to bind to if this is a cubetexture
  39333. * @param layer defines the index of the texture to bind in the array
  39334. */
  39335. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  39336. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  39337. /**
  39338. * @hidden
  39339. */
  39340. _prepareFrame(scene: Scene, faceIndex?: number, layer?: number, useCameraPostProcess?: boolean): void;
  39341. private renderToTarget;
  39342. /**
  39343. * Overrides the default sort function applied in the rendering group to prepare the meshes.
  39344. * This allowed control for front to back rendering or reversely depending of the special needs.
  39345. *
  39346. * @param renderingGroupId The rendering group id corresponding to its index
  39347. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  39348. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  39349. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  39350. */
  39351. 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;
  39352. /**
  39353. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  39354. *
  39355. * @param renderingGroupId The rendering group id corresponding to its index
  39356. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  39357. */
  39358. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  39359. /**
  39360. * Clones the texture.
  39361. * @returns the cloned texture
  39362. */
  39363. clone(): RenderTargetTexture;
  39364. /**
  39365. * Serialize the texture to a JSON representation we can easily use in the respective Parse function.
  39366. * @returns The JSON representation of the texture
  39367. */
  39368. serialize(): any;
  39369. /**
  39370. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  39371. */
  39372. disposeFramebufferObjects(): void;
  39373. /**
  39374. * Dispose the texture and release its associated resources.
  39375. */
  39376. dispose(): void;
  39377. /** @hidden */
  39378. _rebuild(): void;
  39379. /**
  39380. * Clear the info related to rendering groups preventing retention point in material dispose.
  39381. */
  39382. freeRenderingGroups(): void;
  39383. /**
  39384. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  39385. * @returns the view count
  39386. */
  39387. getViewCount(): number;
  39388. }
  39389. }
  39390. declare module BABYLON {
  39391. /**
  39392. * Options to be used when creating an effect.
  39393. */
  39394. export interface IEffectCreationOptions {
  39395. /**
  39396. * Attributes that will be used in the shader.
  39397. */
  39398. attributes: string[];
  39399. /**
  39400. * Uniform variable names that will be set in the shader.
  39401. */
  39402. uniformsNames: string[];
  39403. /**
  39404. * Uniform buffer variable names that will be set in the shader.
  39405. */
  39406. uniformBuffersNames: string[];
  39407. /**
  39408. * Sampler texture variable names that will be set in the shader.
  39409. */
  39410. samplers: string[];
  39411. /**
  39412. * Define statements that will be set in the shader.
  39413. */
  39414. defines: any;
  39415. /**
  39416. * Possible fallbacks for this effect to improve performance when needed.
  39417. */
  39418. fallbacks: Nullable<IEffectFallbacks>;
  39419. /**
  39420. * Callback that will be called when the shader is compiled.
  39421. */
  39422. onCompiled: Nullable<(effect: Effect) => void>;
  39423. /**
  39424. * Callback that will be called if an error occurs during shader compilation.
  39425. */
  39426. onError: Nullable<(effect: Effect, errors: string) => void>;
  39427. /**
  39428. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  39429. */
  39430. indexParameters?: any;
  39431. /**
  39432. * Max number of lights that can be used in the shader.
  39433. */
  39434. maxSimultaneousLights?: number;
  39435. /**
  39436. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  39437. */
  39438. transformFeedbackVaryings?: Nullable<string[]>;
  39439. /**
  39440. * 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
  39441. */
  39442. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  39443. /**
  39444. * Is this effect rendering to several color attachments ?
  39445. */
  39446. multiTarget?: boolean;
  39447. }
  39448. /**
  39449. * Effect containing vertex and fragment shader that can be executed on an object.
  39450. */
  39451. export class Effect implements IDisposable {
  39452. /**
  39453. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  39454. */
  39455. static ShadersRepository: string;
  39456. /**
  39457. * Enable logging of the shader code when a compilation error occurs
  39458. */
  39459. static LogShaderCodeOnCompilationError: boolean;
  39460. /**
  39461. * Name of the effect.
  39462. */
  39463. name: any;
  39464. /**
  39465. * String container all the define statements that should be set on the shader.
  39466. */
  39467. defines: string;
  39468. /**
  39469. * Callback that will be called when the shader is compiled.
  39470. */
  39471. onCompiled: Nullable<(effect: Effect) => void>;
  39472. /**
  39473. * Callback that will be called if an error occurs during shader compilation.
  39474. */
  39475. onError: Nullable<(effect: Effect, errors: string) => void>;
  39476. /**
  39477. * Callback that will be called when effect is bound.
  39478. */
  39479. onBind: Nullable<(effect: Effect) => void>;
  39480. /**
  39481. * Unique ID of the effect.
  39482. */
  39483. uniqueId: number;
  39484. /**
  39485. * Observable that will be called when the shader is compiled.
  39486. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  39487. */
  39488. onCompileObservable: Observable<Effect>;
  39489. /**
  39490. * Observable that will be called if an error occurs during shader compilation.
  39491. */
  39492. onErrorObservable: Observable<Effect>;
  39493. /** @hidden */
  39494. _onBindObservable: Nullable<Observable<Effect>>;
  39495. /**
  39496. * @hidden
  39497. * Specifies if the effect was previously ready
  39498. */
  39499. _wasPreviouslyReady: boolean;
  39500. /**
  39501. * Observable that will be called when effect is bound.
  39502. */
  39503. get onBindObservable(): Observable<Effect>;
  39504. /** @hidden */
  39505. _bonesComputationForcedToCPU: boolean;
  39506. /** @hidden */
  39507. _uniformBuffersNames: {
  39508. [key: string]: number;
  39509. };
  39510. /** @hidden */
  39511. _samplerList: string[];
  39512. /** @hidden */
  39513. _multiTarget: boolean;
  39514. private static _uniqueIdSeed;
  39515. private _engine;
  39516. private _uniformBuffersNamesList;
  39517. private _uniformsNames;
  39518. private _samplers;
  39519. private _isReady;
  39520. private _compilationError;
  39521. private _allFallbacksProcessed;
  39522. private _attributesNames;
  39523. private _attributes;
  39524. private _attributeLocationByName;
  39525. private _uniforms;
  39526. /**
  39527. * Key for the effect.
  39528. * @hidden
  39529. */
  39530. _key: string;
  39531. private _indexParameters;
  39532. private _fallbacks;
  39533. private _vertexSourceCodeOverride;
  39534. private _fragmentSourceCodeOverride;
  39535. private _transformFeedbackVaryings;
  39536. /**
  39537. * Compiled shader to webGL program.
  39538. * @hidden
  39539. */
  39540. _pipelineContext: Nullable<IPipelineContext>;
  39541. /** @hidden */
  39542. _vertexSourceCode: string;
  39543. /** @hidden */
  39544. _fragmentSourceCode: string;
  39545. /** @hidden */
  39546. private _rawVertexSourceCode;
  39547. /** @hidden */
  39548. private _rawFragmentSourceCode;
  39549. private static _baseCache;
  39550. private _processingContext;
  39551. /**
  39552. * Instantiates an effect.
  39553. * An effect can be used to create/manage/execute vertex and fragment shaders.
  39554. * @param baseName Name of the effect.
  39555. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  39556. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  39557. * @param samplers List of sampler variables that will be passed to the shader.
  39558. * @param engine Engine to be used to render the effect
  39559. * @param defines Define statements to be added to the shader.
  39560. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  39561. * @param onCompiled Callback that will be called when the shader is compiled.
  39562. * @param onError Callback that will be called if an error occurs during shader compilation.
  39563. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  39564. * @param key Effect Key identifying uniquely compiled shader variants
  39565. */
  39566. 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);
  39567. private _useFinalCode;
  39568. /**
  39569. * Unique key for this effect
  39570. */
  39571. get key(): string;
  39572. /**
  39573. * If the effect has been compiled and prepared.
  39574. * @returns if the effect is compiled and prepared.
  39575. */
  39576. isReady(): boolean;
  39577. private _isReadyInternal;
  39578. /**
  39579. * The engine the effect was initialized with.
  39580. * @returns the engine.
  39581. */
  39582. getEngine(): Engine;
  39583. /**
  39584. * The pipeline context for this effect
  39585. * @returns the associated pipeline context
  39586. */
  39587. getPipelineContext(): Nullable<IPipelineContext>;
  39588. /**
  39589. * The set of names of attribute variables for the shader.
  39590. * @returns An array of attribute names.
  39591. */
  39592. getAttributesNames(): string[];
  39593. /**
  39594. * Returns the attribute at the given index.
  39595. * @param index The index of the attribute.
  39596. * @returns The location of the attribute.
  39597. */
  39598. getAttributeLocation(index: number): number;
  39599. /**
  39600. * Returns the attribute based on the name of the variable.
  39601. * @param name of the attribute to look up.
  39602. * @returns the attribute location.
  39603. */
  39604. getAttributeLocationByName(name: string): number;
  39605. /**
  39606. * The number of attributes.
  39607. * @returns the number of attributes.
  39608. */
  39609. getAttributesCount(): number;
  39610. /**
  39611. * Gets the index of a uniform variable.
  39612. * @param uniformName of the uniform to look up.
  39613. * @returns the index.
  39614. */
  39615. getUniformIndex(uniformName: string): number;
  39616. /**
  39617. * Returns the attribute based on the name of the variable.
  39618. * @param uniformName of the uniform to look up.
  39619. * @returns the location of the uniform.
  39620. */
  39621. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  39622. /**
  39623. * Returns an array of sampler variable names
  39624. * @returns The array of sampler variable names.
  39625. */
  39626. getSamplers(): string[];
  39627. /**
  39628. * Returns an array of uniform variable names
  39629. * @returns The array of uniform variable names.
  39630. */
  39631. getUniformNames(): string[];
  39632. /**
  39633. * Returns an array of uniform buffer variable names
  39634. * @returns The array of uniform buffer variable names.
  39635. */
  39636. getUniformBuffersNames(): string[];
  39637. /**
  39638. * Returns the index parameters used to create the effect
  39639. * @returns The index parameters object
  39640. */
  39641. getIndexParameters(): any;
  39642. /**
  39643. * The error from the last compilation.
  39644. * @returns the error string.
  39645. */
  39646. getCompilationError(): string;
  39647. /**
  39648. * Gets a boolean indicating that all fallbacks were used during compilation
  39649. * @returns true if all fallbacks were used
  39650. */
  39651. allFallbacksProcessed(): boolean;
  39652. /**
  39653. * Adds a callback to the onCompiled observable and call the callback immediately if already ready.
  39654. * @param func The callback to be used.
  39655. */
  39656. executeWhenCompiled(func: (effect: Effect) => void): void;
  39657. private _checkIsReady;
  39658. private _loadShader;
  39659. /**
  39660. * Gets the vertex shader source code of this effect
  39661. */
  39662. get vertexSourceCode(): string;
  39663. /**
  39664. * Gets the fragment shader source code of this effect
  39665. */
  39666. get fragmentSourceCode(): string;
  39667. /**
  39668. * Gets the vertex shader source code before it has been processed by the preprocessor
  39669. */
  39670. get rawVertexSourceCode(): string;
  39671. /**
  39672. * Gets the fragment shader source code before it has been processed by the preprocessor
  39673. */
  39674. get rawFragmentSourceCode(): string;
  39675. /**
  39676. * Recompiles the webGL program
  39677. * @param vertexSourceCode The source code for the vertex shader.
  39678. * @param fragmentSourceCode The source code for the fragment shader.
  39679. * @param onCompiled Callback called when completed.
  39680. * @param onError Callback called on error.
  39681. * @hidden
  39682. */
  39683. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  39684. /**
  39685. * Prepares the effect
  39686. * @hidden
  39687. */
  39688. _prepareEffect(): void;
  39689. private _getShaderCodeAndErrorLine;
  39690. private _processCompilationErrors;
  39691. /**
  39692. * Checks if the effect is supported. (Must be called after compilation)
  39693. */
  39694. get isSupported(): boolean;
  39695. /**
  39696. * Binds a texture to the engine to be used as output of the shader.
  39697. * @param channel Name of the output variable.
  39698. * @param texture Texture to bind.
  39699. * @hidden
  39700. */
  39701. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  39702. /**
  39703. * Sets a texture on the engine to be used in the shader.
  39704. * @param channel Name of the sampler variable.
  39705. * @param texture Texture to set.
  39706. */
  39707. setTexture(channel: string, texture: Nullable<ThinTexture>): void;
  39708. /**
  39709. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  39710. * @param channel Name of the sampler variable.
  39711. * @param texture Texture to set.
  39712. */
  39713. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  39714. /**
  39715. * Sets an array of textures on the engine to be used in the shader.
  39716. * @param channel Name of the variable.
  39717. * @param textures Textures to set.
  39718. */
  39719. setTextureArray(channel: string, textures: ThinTexture[]): void;
  39720. /**
  39721. * 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)
  39722. * @param channel Name of the sampler variable.
  39723. * @param postProcess Post process to get the input texture from.
  39724. */
  39725. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  39726. /**
  39727. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  39728. * 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)
  39729. * @param channel Name of the sampler variable.
  39730. * @param postProcess Post process to get the output texture from.
  39731. */
  39732. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  39733. /**
  39734. * Binds a buffer to a uniform.
  39735. * @param buffer Buffer to bind.
  39736. * @param name Name of the uniform variable to bind to.
  39737. */
  39738. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  39739. /**
  39740. * Binds block to a uniform.
  39741. * @param blockName Name of the block to bind.
  39742. * @param index Index to bind.
  39743. */
  39744. bindUniformBlock(blockName: string, index: number): void;
  39745. /**
  39746. * Sets an integer value on a uniform variable.
  39747. * @param uniformName Name of the variable.
  39748. * @param value Value to be set.
  39749. * @returns this effect.
  39750. */
  39751. setInt(uniformName: string, value: number): Effect;
  39752. /**
  39753. * Sets an int2 value on a uniform variable.
  39754. * @param uniformName Name of the variable.
  39755. * @param x First int in int2.
  39756. * @param y Second int in int2.
  39757. * @returns this effect.
  39758. */
  39759. setInt2(uniformName: string, x: number, y: number): Effect;
  39760. /**
  39761. * Sets an int3 value on a uniform variable.
  39762. * @param uniformName Name of the variable.
  39763. * @param x First int in int3.
  39764. * @param y Second int in int3.
  39765. * @param z Third int in int3.
  39766. * @returns this effect.
  39767. */
  39768. setInt3(uniformName: string, x: number, y: number, z: number): Effect;
  39769. /**
  39770. * Sets an int4 value on a uniform variable.
  39771. * @param uniformName Name of the variable.
  39772. * @param x First int in int4.
  39773. * @param y Second int in int4.
  39774. * @param z Third int in int4.
  39775. * @param w Fourth int in int4.
  39776. * @returns this effect.
  39777. */
  39778. setInt4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  39779. /**
  39780. * Sets an int array on a uniform variable.
  39781. * @param uniformName Name of the variable.
  39782. * @param array array to be set.
  39783. * @returns this effect.
  39784. */
  39785. setIntArray(uniformName: string, array: Int32Array): Effect;
  39786. /**
  39787. * 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)
  39788. * @param uniformName Name of the variable.
  39789. * @param array array to be set.
  39790. * @returns this effect.
  39791. */
  39792. setIntArray2(uniformName: string, array: Int32Array): Effect;
  39793. /**
  39794. * 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)
  39795. * @param uniformName Name of the variable.
  39796. * @param array array to be set.
  39797. * @returns this effect.
  39798. */
  39799. setIntArray3(uniformName: string, array: Int32Array): Effect;
  39800. /**
  39801. * 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)
  39802. * @param uniformName Name of the variable.
  39803. * @param array array to be set.
  39804. * @returns this effect.
  39805. */
  39806. setIntArray4(uniformName: string, array: Int32Array): Effect;
  39807. /**
  39808. * Sets an float array on a uniform variable.
  39809. * @param uniformName Name of the variable.
  39810. * @param array array to be set.
  39811. * @returns this effect.
  39812. */
  39813. setFloatArray(uniformName: string, array: FloatArray): Effect;
  39814. /**
  39815. * 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)
  39816. * @param uniformName Name of the variable.
  39817. * @param array array to be set.
  39818. * @returns this effect.
  39819. */
  39820. setFloatArray2(uniformName: string, array: FloatArray): Effect;
  39821. /**
  39822. * 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)
  39823. * @param uniformName Name of the variable.
  39824. * @param array array to be set.
  39825. * @returns this effect.
  39826. */
  39827. setFloatArray3(uniformName: string, array: FloatArray): Effect;
  39828. /**
  39829. * 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)
  39830. * @param uniformName Name of the variable.
  39831. * @param array array to be set.
  39832. * @returns this effect.
  39833. */
  39834. setFloatArray4(uniformName: string, array: FloatArray): Effect;
  39835. /**
  39836. * Sets an array on a uniform variable.
  39837. * @param uniformName Name of the variable.
  39838. * @param array array to be set.
  39839. * @returns this effect.
  39840. */
  39841. setArray(uniformName: string, array: number[]): Effect;
  39842. /**
  39843. * 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)
  39844. * @param uniformName Name of the variable.
  39845. * @param array array to be set.
  39846. * @returns this effect.
  39847. */
  39848. setArray2(uniformName: string, array: number[]): Effect;
  39849. /**
  39850. * 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)
  39851. * @param uniformName Name of the variable.
  39852. * @param array array to be set.
  39853. * @returns this effect.
  39854. */
  39855. setArray3(uniformName: string, array: number[]): Effect;
  39856. /**
  39857. * 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)
  39858. * @param uniformName Name of the variable.
  39859. * @param array array to be set.
  39860. * @returns this effect.
  39861. */
  39862. setArray4(uniformName: string, array: number[]): Effect;
  39863. /**
  39864. * Sets matrices on a uniform variable.
  39865. * @param uniformName Name of the variable.
  39866. * @param matrices matrices to be set.
  39867. * @returns this effect.
  39868. */
  39869. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  39870. /**
  39871. * Sets matrix on a uniform variable.
  39872. * @param uniformName Name of the variable.
  39873. * @param matrix matrix to be set.
  39874. * @returns this effect.
  39875. */
  39876. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  39877. /**
  39878. * 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)
  39879. * @param uniformName Name of the variable.
  39880. * @param matrix matrix to be set.
  39881. * @returns this effect.
  39882. */
  39883. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  39884. /**
  39885. * Sets a 2x2 matrix on a uniform variable. (Specified as [1,2,3,4] will result in [1,2][3,4] matrix)
  39886. * @param uniformName Name of the variable.
  39887. * @param matrix matrix to be set.
  39888. * @returns this effect.
  39889. */
  39890. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  39891. /**
  39892. * Sets a float on a uniform variable.
  39893. * @param uniformName Name of the variable.
  39894. * @param value value to be set.
  39895. * @returns this effect.
  39896. */
  39897. setFloat(uniformName: string, value: number): Effect;
  39898. /**
  39899. * Sets a boolean on a uniform variable.
  39900. * @param uniformName Name of the variable.
  39901. * @param bool value to be set.
  39902. * @returns this effect.
  39903. */
  39904. setBool(uniformName: string, bool: boolean): Effect;
  39905. /**
  39906. * Sets a Vector2 on a uniform variable.
  39907. * @param uniformName Name of the variable.
  39908. * @param vector2 vector2 to be set.
  39909. * @returns this effect.
  39910. */
  39911. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  39912. /**
  39913. * Sets a float2 on a uniform variable.
  39914. * @param uniformName Name of the variable.
  39915. * @param x First float in float2.
  39916. * @param y Second float in float2.
  39917. * @returns this effect.
  39918. */
  39919. setFloat2(uniformName: string, x: number, y: number): Effect;
  39920. /**
  39921. * Sets a Vector3 on a uniform variable.
  39922. * @param uniformName Name of the variable.
  39923. * @param vector3 Value to be set.
  39924. * @returns this effect.
  39925. */
  39926. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  39927. /**
  39928. * Sets a float3 on a uniform variable.
  39929. * @param uniformName Name of the variable.
  39930. * @param x First float in float3.
  39931. * @param y Second float in float3.
  39932. * @param z Third float in float3.
  39933. * @returns this effect.
  39934. */
  39935. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  39936. /**
  39937. * Sets a Vector4 on a uniform variable.
  39938. * @param uniformName Name of the variable.
  39939. * @param vector4 Value to be set.
  39940. * @returns this effect.
  39941. */
  39942. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  39943. /**
  39944. * Sets a float4 on a uniform variable.
  39945. * @param uniformName Name of the variable.
  39946. * @param x First float in float4.
  39947. * @param y Second float in float4.
  39948. * @param z Third float in float4.
  39949. * @param w Fourth float in float4.
  39950. * @returns this effect.
  39951. */
  39952. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  39953. /**
  39954. * Sets a Color3 on a uniform variable.
  39955. * @param uniformName Name of the variable.
  39956. * @param color3 Value to be set.
  39957. * @returns this effect.
  39958. */
  39959. setColor3(uniformName: string, color3: IColor3Like): Effect;
  39960. /**
  39961. * Sets a Color4 on a uniform variable.
  39962. * @param uniformName Name of the variable.
  39963. * @param color3 Value to be set.
  39964. * @param alpha Alpha value to be set.
  39965. * @returns this effect.
  39966. */
  39967. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  39968. /**
  39969. * Sets a Color4 on a uniform variable
  39970. * @param uniformName defines the name of the variable
  39971. * @param color4 defines the value to be set
  39972. * @returns this effect.
  39973. */
  39974. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  39975. /**
  39976. * Release all associated resources.
  39977. **/
  39978. dispose(): void;
  39979. /**
  39980. * This function will add a new shader to the shader store
  39981. * @param name the name of the shader
  39982. * @param pixelShader optional pixel shader content
  39983. * @param vertexShader optional vertex shader content
  39984. */
  39985. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  39986. /**
  39987. * Store of each shader (The can be looked up using effect.key)
  39988. */
  39989. static ShadersStore: {
  39990. [key: string]: string;
  39991. };
  39992. /**
  39993. * Store of each included file for a shader (The can be looked up using effect.key)
  39994. */
  39995. static IncludesShadersStore: {
  39996. [key: string]: string;
  39997. };
  39998. /**
  39999. * Resets the cache of effects.
  40000. */
  40001. static ResetCache(): void;
  40002. }
  40003. }
  40004. declare module BABYLON {
  40005. /**
  40006. * Interface used to describe the capabilities of the engine relatively to the current browser
  40007. */
  40008. export interface EngineCapabilities {
  40009. /** Maximum textures units per fragment shader */
  40010. maxTexturesImageUnits: number;
  40011. /** Maximum texture units per vertex shader */
  40012. maxVertexTextureImageUnits: number;
  40013. /** Maximum textures units in the entire pipeline */
  40014. maxCombinedTexturesImageUnits: number;
  40015. /** Maximum texture size */
  40016. maxTextureSize: number;
  40017. /** Maximum texture samples */
  40018. maxSamples?: number;
  40019. /** Maximum cube texture size */
  40020. maxCubemapTextureSize: number;
  40021. /** Maximum render texture size */
  40022. maxRenderTextureSize: number;
  40023. /** Maximum number of vertex attributes */
  40024. maxVertexAttribs: number;
  40025. /** Maximum number of varyings */
  40026. maxVaryingVectors: number;
  40027. /** Maximum number of uniforms per vertex shader */
  40028. maxVertexUniformVectors: number;
  40029. /** Maximum number of uniforms per fragment shader */
  40030. maxFragmentUniformVectors: number;
  40031. /** Defines if standard derivatives (dx/dy) are supported */
  40032. standardDerivatives: boolean;
  40033. /** Defines if s3tc texture compression is supported */
  40034. s3tc?: WEBGL_compressed_texture_s3tc;
  40035. /** Defines if pvrtc texture compression is supported */
  40036. pvrtc: any;
  40037. /** Defines if etc1 texture compression is supported */
  40038. etc1: any;
  40039. /** Defines if etc2 texture compression is supported */
  40040. etc2: any;
  40041. /** Defines if astc texture compression is supported */
  40042. astc: any;
  40043. /** Defines if bptc texture compression is supported */
  40044. bptc: any;
  40045. /** Defines if float textures are supported */
  40046. textureFloat: boolean;
  40047. /** Defines if vertex array objects are supported */
  40048. vertexArrayObject: boolean;
  40049. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  40050. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  40051. /** Gets the maximum level of anisotropy supported */
  40052. maxAnisotropy: number;
  40053. /** Defines if instancing is supported */
  40054. instancedArrays: boolean;
  40055. /** Defines if 32 bits indices are supported */
  40056. uintIndices: boolean;
  40057. /** Defines if high precision shaders are supported */
  40058. highPrecisionShaderSupported: boolean;
  40059. /** Defines if depth reading in the fragment shader is supported */
  40060. fragmentDepthSupported: boolean;
  40061. /** Defines if float texture linear filtering is supported*/
  40062. textureFloatLinearFiltering: boolean;
  40063. /** Defines if rendering to float textures is supported */
  40064. textureFloatRender: boolean;
  40065. /** Defines if half float textures are supported*/
  40066. textureHalfFloat: boolean;
  40067. /** Defines if half float texture linear filtering is supported*/
  40068. textureHalfFloatLinearFiltering: boolean;
  40069. /** Defines if rendering to half float textures is supported */
  40070. textureHalfFloatRender: boolean;
  40071. /** Defines if textureLOD shader command is supported */
  40072. textureLOD: boolean;
  40073. /** Defines if draw buffers extension is supported */
  40074. drawBuffersExtension: boolean;
  40075. /** Defines if depth textures are supported */
  40076. depthTextureExtension: boolean;
  40077. /** Defines if float color buffer are supported */
  40078. colorBufferFloat: boolean;
  40079. /** Gets disjoint timer query extension (null if not supported) */
  40080. timerQuery?: EXT_disjoint_timer_query;
  40081. /** Defines if timestamp can be used with timer query */
  40082. canUseTimestampForTimerQuery: boolean;
  40083. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  40084. multiview?: any;
  40085. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  40086. oculusMultiview?: any;
  40087. /** Function used to let the system compiles shaders in background */
  40088. parallelShaderCompile?: {
  40089. COMPLETION_STATUS_KHR: number;
  40090. };
  40091. /** Max number of texture samples for MSAA */
  40092. maxMSAASamples: number;
  40093. /** Defines if the blend min max extension is supported */
  40094. blendMinMax: boolean;
  40095. /** 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 */
  40096. canUseGLInstanceID: boolean;
  40097. /** Defines if gl_vertexID is available */
  40098. canUseGLVertexID: boolean;
  40099. }
  40100. }
  40101. declare module BABYLON {
  40102. /**
  40103. * @hidden
  40104. **/
  40105. export class DepthCullingState {
  40106. protected _isDepthTestDirty: boolean;
  40107. protected _isDepthMaskDirty: boolean;
  40108. protected _isDepthFuncDirty: boolean;
  40109. protected _isCullFaceDirty: boolean;
  40110. protected _isCullDirty: boolean;
  40111. protected _isZOffsetDirty: boolean;
  40112. protected _isFrontFaceDirty: boolean;
  40113. protected _depthTest: boolean;
  40114. protected _depthMask: boolean;
  40115. protected _depthFunc: Nullable<number>;
  40116. protected _cull: Nullable<boolean>;
  40117. protected _cullFace: Nullable<number>;
  40118. protected _zOffset: number;
  40119. protected _frontFace: Nullable<number>;
  40120. /**
  40121. * Initializes the state.
  40122. */
  40123. constructor(reset?: boolean);
  40124. get isDirty(): boolean;
  40125. get zOffset(): number;
  40126. set zOffset(value: number);
  40127. get cullFace(): Nullable<number>;
  40128. set cullFace(value: Nullable<number>);
  40129. get cull(): Nullable<boolean>;
  40130. set cull(value: Nullable<boolean>);
  40131. get depthFunc(): Nullable<number>;
  40132. set depthFunc(value: Nullable<number>);
  40133. get depthMask(): boolean;
  40134. set depthMask(value: boolean);
  40135. get depthTest(): boolean;
  40136. set depthTest(value: boolean);
  40137. get frontFace(): Nullable<number>;
  40138. set frontFace(value: Nullable<number>);
  40139. reset(): void;
  40140. apply(gl: WebGLRenderingContext): void;
  40141. }
  40142. }
  40143. declare module BABYLON {
  40144. /**
  40145. * @hidden
  40146. **/
  40147. export class StencilState {
  40148. /** 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 */
  40149. static readonly ALWAYS: number;
  40150. /** Passed to stencilOperation to specify that stencil value must be kept */
  40151. static readonly KEEP: number;
  40152. /** Passed to stencilOperation to specify that stencil value must be replaced */
  40153. static readonly REPLACE: number;
  40154. protected _isStencilTestDirty: boolean;
  40155. protected _isStencilMaskDirty: boolean;
  40156. protected _isStencilFuncDirty: boolean;
  40157. protected _isStencilOpDirty: boolean;
  40158. protected _stencilTest: boolean;
  40159. protected _stencilMask: number;
  40160. protected _stencilFunc: number;
  40161. protected _stencilFuncRef: number;
  40162. protected _stencilFuncMask: number;
  40163. protected _stencilOpStencilFail: number;
  40164. protected _stencilOpDepthFail: number;
  40165. protected _stencilOpStencilDepthPass: number;
  40166. get isDirty(): boolean;
  40167. get stencilFunc(): number;
  40168. set stencilFunc(value: number);
  40169. get stencilFuncRef(): number;
  40170. set stencilFuncRef(value: number);
  40171. get stencilFuncMask(): number;
  40172. set stencilFuncMask(value: number);
  40173. get stencilOpStencilFail(): number;
  40174. set stencilOpStencilFail(value: number);
  40175. get stencilOpDepthFail(): number;
  40176. set stencilOpDepthFail(value: number);
  40177. get stencilOpStencilDepthPass(): number;
  40178. set stencilOpStencilDepthPass(value: number);
  40179. get stencilMask(): number;
  40180. set stencilMask(value: number);
  40181. get stencilTest(): boolean;
  40182. set stencilTest(value: boolean);
  40183. constructor(reset?: boolean);
  40184. reset(): void;
  40185. apply(gl: WebGLRenderingContext): void;
  40186. }
  40187. }
  40188. declare module BABYLON {
  40189. /**
  40190. * @hidden
  40191. **/
  40192. export class AlphaState {
  40193. _blendFunctionParameters: Nullable<number>[];
  40194. _blendEquationParameters: Nullable<number>[];
  40195. _blendConstants: Nullable<number>[];
  40196. _isBlendConstantsDirty: boolean;
  40197. private _alphaBlend;
  40198. private _isAlphaBlendDirty;
  40199. private _isBlendFunctionParametersDirty;
  40200. private _isBlendEquationParametersDirty;
  40201. /**
  40202. * Initializes the state.
  40203. */
  40204. constructor();
  40205. get isDirty(): boolean;
  40206. get alphaBlend(): boolean;
  40207. set alphaBlend(value: boolean);
  40208. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  40209. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  40210. setAlphaEquationParameters(rgb: number, alpha: number): void;
  40211. reset(): void;
  40212. apply(gl: WebGLRenderingContext): void;
  40213. }
  40214. }
  40215. declare module BABYLON {
  40216. /** @hidden */
  40217. export class WebGLShaderProcessor implements IShaderProcessor {
  40218. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>, engine: ThinEngine): string;
  40219. }
  40220. }
  40221. declare module BABYLON {
  40222. /** @hidden */
  40223. export class WebGL2ShaderProcessor implements IShaderProcessor {
  40224. attributeProcessor(attribute: string): string;
  40225. varyingProcessor(varying: string, isFragment: boolean): string;
  40226. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>, engine: ThinEngine): string;
  40227. }
  40228. }
  40229. declare module BABYLON {
  40230. /**
  40231. * Interface for attribute information associated with buffer instantiation
  40232. */
  40233. export interface InstancingAttributeInfo {
  40234. /**
  40235. * Name of the GLSL attribute
  40236. * if attribute index is not specified, this is used to retrieve the index from the effect
  40237. */
  40238. attributeName: string;
  40239. /**
  40240. * Index/offset of the attribute in the vertex shader
  40241. * if not specified, this will be computes from the name.
  40242. */
  40243. index?: number;
  40244. /**
  40245. * size of the attribute, 1, 2, 3 or 4
  40246. */
  40247. attributeSize: number;
  40248. /**
  40249. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  40250. */
  40251. offset: number;
  40252. /**
  40253. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  40254. * default to 1
  40255. */
  40256. divisor?: number;
  40257. /**
  40258. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  40259. * default is FLOAT
  40260. */
  40261. attributeType?: number;
  40262. /**
  40263. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  40264. */
  40265. normalized?: boolean;
  40266. }
  40267. }
  40268. declare module BABYLON {
  40269. /** @hidden */
  40270. export interface EngineFeatures {
  40271. /** Force using Bitmap when Bitmap or HTMLImageElement can be used */
  40272. forceBitmapOverHTMLImageElement: boolean;
  40273. /** Indicates that the engine support rendering to as well as copying to lod float textures */
  40274. supportRenderAndCopyToLodForFloatTextures: boolean;
  40275. /** Indicates that the engine support handling depth/stencil textures */
  40276. supportDepthStencilTexture: boolean;
  40277. /** Indicates that the engine support shadow samplers */
  40278. supportShadowSamplers: boolean;
  40279. /** 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 */
  40280. uniformBufferHardCheckMatrix: boolean;
  40281. /** Indicates that prefiltered mipmaps can be generated in some processes (for eg when loading an HDR cube texture) */
  40282. allowTexturePrefiltering: boolean;
  40283. /** Indicates to track the usage of ubos and to create new ones as necessary during a frame duration */
  40284. trackUbosInFrame: boolean;
  40285. /** Indicates that the Cascaded Shadow Map technic is supported */
  40286. supportCSM: boolean;
  40287. /** Indicates that the textures transcoded by the basis transcoder must have power of 2 width and height */
  40288. basisNeedsPOT: boolean;
  40289. /** Indicates that the engine supports 3D textures */
  40290. support3DTextures: boolean;
  40291. /** Indicates that constants need a type suffix in shaders (used by realtime filtering...) */
  40292. needTypeSuffixInShaderConstants: boolean;
  40293. /** Indicates that MSAA is supported */
  40294. supportMSAA: boolean;
  40295. /** Indicates that SSAO2 is supported */
  40296. supportSSAO2: boolean;
  40297. /** Indicates that some additional texture formats are supported (like TEXTUREFORMAT_R for eg) */
  40298. supportExtendedTextureFormats: boolean;
  40299. /** Indicates that the switch/case construct is supported in shaders */
  40300. supportSwitchCaseInShader: boolean;
  40301. /** Indicates that synchronous texture reading is supported */
  40302. supportSyncTextureRead: boolean;
  40303. /** Indicates that y should be inverted when dealing with bitmaps (notably in environment tools) */
  40304. needsInvertingBitmap: boolean;
  40305. /** @hidden */
  40306. _collectUbosUpdatedInFrame: boolean;
  40307. }
  40308. }
  40309. declare module BABYLON {
  40310. /** @hidden */
  40311. export class WebGLHardwareTexture implements HardwareTextureWrapper {
  40312. private _webGLTexture;
  40313. private _context;
  40314. get underlyingResource(): Nullable<WebGLTexture>;
  40315. constructor(existingTexture: WebGLTexture | null | undefined, context: WebGLRenderingContext);
  40316. setUsage(textureSource: number, generateMipMaps: boolean, isCube: boolean, width: number, height: number): void;
  40317. set(hardwareTexture: WebGLTexture): void;
  40318. reset(): void;
  40319. release(): void;
  40320. }
  40321. }
  40322. declare module BABYLON {
  40323. interface ThinEngine {
  40324. /**
  40325. * Update a video texture
  40326. * @param texture defines the texture to update
  40327. * @param video defines the video element to use
  40328. * @param invertY defines if data must be stored with Y axis inverted
  40329. */
  40330. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  40331. }
  40332. }
  40333. declare module BABYLON {
  40334. interface ThinEngine {
  40335. /**
  40336. * Creates a dynamic texture
  40337. * @param width defines the width of the texture
  40338. * @param height defines the height of the texture
  40339. * @param generateMipMaps defines if the engine should generate the mip levels
  40340. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  40341. * @returns the dynamic texture inside an InternalTexture
  40342. */
  40343. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  40344. /**
  40345. * Update the content of a dynamic texture
  40346. * @param texture defines the texture to update
  40347. * @param source defines the source containing the data
  40348. * @param invertY defines if data must be stored with Y axis inverted
  40349. * @param premulAlpha defines if alpha is stored as premultiplied
  40350. * @param format defines the format of the data
  40351. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  40352. */
  40353. updateDynamicTexture(texture: Nullable<InternalTexture>, source: ImageBitmap | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | OffscreenCanvas, invertY?: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  40354. }
  40355. }
  40356. declare module BABYLON {
  40357. /**
  40358. * Settings for finer control over video usage
  40359. */
  40360. export interface VideoTextureSettings {
  40361. /**
  40362. * Applies `autoplay` to video, if specified
  40363. */
  40364. autoPlay?: boolean;
  40365. /**
  40366. * Applies `muted` to video, if specified
  40367. */
  40368. muted?: boolean;
  40369. /**
  40370. * Applies `loop` to video, if specified
  40371. */
  40372. loop?: boolean;
  40373. /**
  40374. * Automatically updates internal texture from video at every frame in the render loop
  40375. */
  40376. autoUpdateTexture: boolean;
  40377. /**
  40378. * Image src displayed during the video loading or until the user interacts with the video.
  40379. */
  40380. poster?: string;
  40381. }
  40382. /**
  40383. * If you want to display a video in your scene, this is the special texture for that.
  40384. * This special texture works similar to other textures, with the exception of a few parameters.
  40385. * @see https://doc.babylonjs.com/how_to/video_texture
  40386. */
  40387. export class VideoTexture extends Texture {
  40388. /**
  40389. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  40390. */
  40391. readonly autoUpdateTexture: boolean;
  40392. /**
  40393. * The video instance used by the texture internally
  40394. */
  40395. readonly video: HTMLVideoElement;
  40396. private _onUserActionRequestedObservable;
  40397. /**
  40398. * Event triggered when a dom action is required by the user to play the video.
  40399. * This happens due to recent changes in browser policies preventing video to auto start.
  40400. */
  40401. get onUserActionRequestedObservable(): Observable<Texture>;
  40402. private _generateMipMaps;
  40403. private _stillImageCaptured;
  40404. private _displayingPosterTexture;
  40405. private _settings;
  40406. private _createInternalTextureOnEvent;
  40407. private _frameId;
  40408. private _currentSrc;
  40409. /**
  40410. * Creates a video texture.
  40411. * If you want to display a video in your scene, this is the special texture for that.
  40412. * This special texture works similar to other textures, with the exception of a few parameters.
  40413. * @see https://doc.babylonjs.com/how_to/video_texture
  40414. * @param name optional name, will detect from video source, if not defined
  40415. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  40416. * @param scene is obviously the current scene.
  40417. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  40418. * @param invertY is false by default but can be used to invert video on Y axis
  40419. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  40420. * @param settings allows finer control over video usage
  40421. */
  40422. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  40423. private _getName;
  40424. private _getVideo;
  40425. private _createInternalTexture;
  40426. private reset;
  40427. /**
  40428. * @hidden Internal method to initiate `update`.
  40429. */
  40430. _rebuild(): void;
  40431. /**
  40432. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  40433. */
  40434. update(): void;
  40435. /**
  40436. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  40437. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or otherwise.
  40438. */
  40439. updateTexture(isVisible: boolean): void;
  40440. protected _updateInternalTexture: () => void;
  40441. /**
  40442. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  40443. * @param url New url.
  40444. */
  40445. updateURL(url: string): void;
  40446. /**
  40447. * Clones the texture.
  40448. * @returns the cloned texture
  40449. */
  40450. clone(): VideoTexture;
  40451. /**
  40452. * Dispose the texture and release its associated resources.
  40453. */
  40454. dispose(): void;
  40455. /**
  40456. * Creates a video texture straight from a stream.
  40457. * @param scene Define the scene the texture should be created in
  40458. * @param stream Define the stream the texture should be created from
  40459. * @returns The created video texture as a promise
  40460. */
  40461. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  40462. /**
  40463. * Creates a video texture straight from your WebCam video feed.
  40464. * @param scene Define the scene the texture should be created in
  40465. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  40466. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  40467. * @returns The created video texture as a promise
  40468. */
  40469. static CreateFromWebCamAsync(scene: Scene, constraints: {
  40470. minWidth: number;
  40471. maxWidth: number;
  40472. minHeight: number;
  40473. maxHeight: number;
  40474. deviceId: string;
  40475. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  40476. /**
  40477. * Creates a video texture straight from your WebCam video feed.
  40478. * @param scene Define the scene the texture should be created in
  40479. * @param onReady Define a callback to triggered once the texture will be ready
  40480. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  40481. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  40482. */
  40483. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  40484. minWidth: number;
  40485. maxWidth: number;
  40486. minHeight: number;
  40487. maxHeight: number;
  40488. deviceId: string;
  40489. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  40490. }
  40491. }
  40492. declare module BABYLON {
  40493. /**
  40494. * Defines the interface used by objects working like Scene
  40495. * @hidden
  40496. */
  40497. export interface ISceneLike {
  40498. _addPendingData(data: any): void;
  40499. _removePendingData(data: any): void;
  40500. offlineProvider: IOfflineProvider;
  40501. }
  40502. /**
  40503. * Information about the current host
  40504. */
  40505. export interface HostInformation {
  40506. /**
  40507. * Defines if the current host is a mobile
  40508. */
  40509. isMobile: boolean;
  40510. }
  40511. /** Interface defining initialization parameters for Engine class */
  40512. export interface EngineOptions extends WebGLContextAttributes {
  40513. /**
  40514. * Defines if the engine should no exceed a specified device ratio
  40515. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  40516. */
  40517. limitDeviceRatio?: number;
  40518. /**
  40519. * Defines if webvr should be enabled automatically
  40520. * @see https://doc.babylonjs.com/how_to/webvr_camera
  40521. */
  40522. autoEnableWebVR?: boolean;
  40523. /**
  40524. * Defines if webgl2 should be turned off even if supported
  40525. * @see https://doc.babylonjs.com/features/webgl2
  40526. */
  40527. disableWebGL2Support?: boolean;
  40528. /**
  40529. * Defines if webaudio should be initialized as well
  40530. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  40531. */
  40532. audioEngine?: boolean;
  40533. /**
  40534. * Defines if animations should run using a deterministic lock step
  40535. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40536. */
  40537. deterministicLockstep?: boolean;
  40538. /** Defines the maximum steps to use with deterministic lock step mode */
  40539. lockstepMaxSteps?: number;
  40540. /** Defines the seconds between each deterministic lock step */
  40541. timeStep?: number;
  40542. /**
  40543. * Defines that engine should ignore context lost events
  40544. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  40545. */
  40546. doNotHandleContextLost?: boolean;
  40547. /**
  40548. * Defines that engine should ignore modifying touch action attribute and style
  40549. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  40550. */
  40551. doNotHandleTouchAction?: boolean;
  40552. /**
  40553. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  40554. */
  40555. useHighPrecisionFloats?: boolean;
  40556. /**
  40557. * Make the canvas XR Compatible for XR sessions
  40558. */
  40559. xrCompatible?: boolean;
  40560. /**
  40561. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  40562. */
  40563. useHighPrecisionMatrix?: boolean;
  40564. /**
  40565. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  40566. */
  40567. failIfMajorPerformanceCaveat?: boolean;
  40568. /**
  40569. * Defines whether to adapt to the device's viewport characteristics (default: false)
  40570. */
  40571. adaptToDeviceRatio?: boolean;
  40572. }
  40573. /**
  40574. * The base engine class (root of all engines)
  40575. */
  40576. export class ThinEngine {
  40577. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  40578. static ExceptionList: ({
  40579. key: string;
  40580. capture: string;
  40581. captureConstraint: number;
  40582. targets: string[];
  40583. } | {
  40584. key: string;
  40585. capture: null;
  40586. captureConstraint: null;
  40587. targets: string[];
  40588. })[];
  40589. /** @hidden */
  40590. static _TextureLoaders: IInternalTextureLoader[];
  40591. /**
  40592. * Returns the current npm package of the sdk
  40593. */
  40594. static get NpmPackage(): string;
  40595. /**
  40596. * Returns the current version of the framework
  40597. */
  40598. static get Version(): string;
  40599. /**
  40600. * Returns a string describing the current engine
  40601. */
  40602. get description(): string;
  40603. /**
  40604. * Returns the name of the engine
  40605. */
  40606. get name(): string;
  40607. /**
  40608. * Returns the version of the engine
  40609. */
  40610. get version(): number;
  40611. /**
  40612. * Gets or sets the epsilon value used by collision engine
  40613. */
  40614. static CollisionsEpsilon: number;
  40615. /**
  40616. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  40617. */
  40618. static get ShadersRepository(): string;
  40619. static set ShadersRepository(value: string);
  40620. /** @hidden */
  40621. _shaderProcessor: Nullable<IShaderProcessor>;
  40622. /**
  40623. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  40624. */
  40625. forcePOTTextures: boolean;
  40626. /**
  40627. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  40628. */
  40629. isFullscreen: boolean;
  40630. /**
  40631. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  40632. */
  40633. cullBackFaces: boolean;
  40634. /**
  40635. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  40636. */
  40637. renderEvenInBackground: boolean;
  40638. /**
  40639. * Gets or sets a boolean indicating that cache can be kept between frames
  40640. */
  40641. preventCacheWipeBetweenFrames: boolean;
  40642. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  40643. validateShaderPrograms: boolean;
  40644. /**
  40645. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  40646. * This can provide greater z depth for distant objects.
  40647. */
  40648. useReverseDepthBuffer: boolean;
  40649. /**
  40650. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  40651. */
  40652. disableUniformBuffers: boolean;
  40653. private _frameId;
  40654. /**
  40655. * Gets the current frame id
  40656. */
  40657. get frameId(): number;
  40658. /** @hidden */
  40659. _uniformBuffers: UniformBuffer[];
  40660. /**
  40661. * Gets a boolean indicating that the engine supports uniform buffers
  40662. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  40663. */
  40664. get supportsUniformBuffers(): boolean;
  40665. /** @hidden */
  40666. _gl: WebGLRenderingContext;
  40667. /** @hidden */
  40668. _webGLVersion: number;
  40669. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  40670. protected _windowIsBackground: boolean;
  40671. protected _creationOptions: EngineOptions;
  40672. protected _highPrecisionShadersAllowed: boolean;
  40673. /** @hidden */
  40674. get _shouldUseHighPrecisionShader(): boolean;
  40675. /**
  40676. * Gets a boolean indicating that only power of 2 textures are supported
  40677. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  40678. */
  40679. get needPOTTextures(): boolean;
  40680. /** @hidden */
  40681. _badOS: boolean;
  40682. /** @hidden */
  40683. _badDesktopOS: boolean;
  40684. protected _hardwareScalingLevel: number;
  40685. /** @hidden */
  40686. _caps: EngineCapabilities;
  40687. /** @hidden */
  40688. _features: EngineFeatures;
  40689. protected _isStencilEnable: boolean;
  40690. private _glVersion;
  40691. private _glRenderer;
  40692. private _glVendor;
  40693. /** @hidden */
  40694. _videoTextureSupported: boolean;
  40695. protected _renderingQueueLaunched: boolean;
  40696. protected _activeRenderLoops: (() => void)[];
  40697. /**
  40698. * Observable signaled when a context lost event is raised
  40699. */
  40700. onContextLostObservable: Observable<ThinEngine>;
  40701. /**
  40702. * Observable signaled when a context restored event is raised
  40703. */
  40704. onContextRestoredObservable: Observable<ThinEngine>;
  40705. private _onContextLost;
  40706. private _onContextRestored;
  40707. protected _contextWasLost: boolean;
  40708. /** @hidden */
  40709. _doNotHandleContextLost: boolean;
  40710. /**
  40711. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  40712. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  40713. */
  40714. get doNotHandleContextLost(): boolean;
  40715. set doNotHandleContextLost(value: boolean);
  40716. /**
  40717. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  40718. */
  40719. disableVertexArrayObjects: boolean;
  40720. /** @hidden */
  40721. protected _colorWrite: boolean;
  40722. /** @hidden */
  40723. protected _colorWriteChanged: boolean;
  40724. /** @hidden */
  40725. protected _depthCullingState: DepthCullingState;
  40726. /** @hidden */
  40727. protected _stencilState: StencilState;
  40728. /** @hidden */
  40729. _alphaState: AlphaState;
  40730. /** @hidden */
  40731. _alphaMode: number;
  40732. /** @hidden */
  40733. _alphaEquation: number;
  40734. /** @hidden */
  40735. _internalTexturesCache: InternalTexture[];
  40736. /** @hidden */
  40737. protected _activeChannel: number;
  40738. private _currentTextureChannel;
  40739. /** @hidden */
  40740. protected _boundTexturesCache: {
  40741. [key: string]: Nullable<InternalTexture>;
  40742. };
  40743. /** @hidden */
  40744. protected _currentEffect: Nullable<Effect>;
  40745. /** @hidden */
  40746. protected _currentProgram: Nullable<WebGLProgram>;
  40747. protected _compiledEffects: {
  40748. [key: string]: Effect;
  40749. };
  40750. private _vertexAttribArraysEnabled;
  40751. /** @hidden */
  40752. protected _cachedViewport: Nullable<IViewportLike>;
  40753. private _cachedVertexArrayObject;
  40754. /** @hidden */
  40755. protected _cachedVertexBuffers: any;
  40756. /** @hidden */
  40757. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  40758. /** @hidden */
  40759. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  40760. /** @hidden */
  40761. _currentRenderTarget: Nullable<InternalTexture>;
  40762. private _uintIndicesCurrentlySet;
  40763. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  40764. /** @hidden */
  40765. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  40766. /** @hidden */
  40767. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  40768. private _currentBufferPointers;
  40769. private _currentInstanceLocations;
  40770. private _currentInstanceBuffers;
  40771. private _textureUnits;
  40772. /** @hidden */
  40773. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  40774. /** @hidden */
  40775. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  40776. /** @hidden */
  40777. _boundRenderFunction: any;
  40778. private _vaoRecordInProgress;
  40779. private _mustWipeVertexAttributes;
  40780. private _emptyTexture;
  40781. private _emptyCubeTexture;
  40782. private _emptyTexture3D;
  40783. private _emptyTexture2DArray;
  40784. /** @hidden */
  40785. _frameHandler: number;
  40786. private _nextFreeTextureSlots;
  40787. private _maxSimultaneousTextures;
  40788. private _activeRequests;
  40789. /** @hidden */
  40790. _transformTextureUrl: Nullable<(url: string) => string>;
  40791. /**
  40792. * Gets information about the current host
  40793. */
  40794. hostInformation: HostInformation;
  40795. protected get _supportsHardwareTextureRescaling(): boolean;
  40796. private _framebufferDimensionsObject;
  40797. /**
  40798. * sets the object from which width and height will be taken from when getting render width and height
  40799. * Will fallback to the gl object
  40800. * @param dimensions the framebuffer width and height that will be used.
  40801. */
  40802. set framebufferDimensionsObject(dimensions: Nullable<{
  40803. framebufferWidth: number;
  40804. framebufferHeight: number;
  40805. }>);
  40806. /**
  40807. * Gets the current viewport
  40808. */
  40809. get currentViewport(): Nullable<IViewportLike>;
  40810. /**
  40811. * Gets the default empty texture
  40812. */
  40813. get emptyTexture(): InternalTexture;
  40814. /**
  40815. * Gets the default empty 3D texture
  40816. */
  40817. get emptyTexture3D(): InternalTexture;
  40818. /**
  40819. * Gets the default empty 2D array texture
  40820. */
  40821. get emptyTexture2DArray(): InternalTexture;
  40822. /**
  40823. * Gets the default empty cube texture
  40824. */
  40825. get emptyCubeTexture(): InternalTexture;
  40826. /**
  40827. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  40828. */
  40829. premultipliedAlpha: boolean;
  40830. /**
  40831. * Observable event triggered before each texture is initialized
  40832. */
  40833. onBeforeTextureInitObservable: Observable<Texture>;
  40834. /** @hidden */
  40835. protected _isWebGPU: boolean;
  40836. /**
  40837. * Gets a boolean indicating if the engine runs in WebGPU or not.
  40838. */
  40839. get isWebGPU(): boolean;
  40840. /** @hidden */
  40841. protected _shaderPlatformName: string;
  40842. /**
  40843. * Gets the shader platfrom name used by the effects.
  40844. */
  40845. get shaderPlatformName(): string;
  40846. /**
  40847. * Creates a new engine
  40848. * @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
  40849. * @param antialias defines enable antialiasing (default: false)
  40850. * @param options defines further options to be sent to the getContext() function
  40851. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  40852. */
  40853. constructor(canvasOrContext: Nullable<HTMLCanvasElement | OffscreenCanvas | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  40854. /**
  40855. * @hidden
  40856. */
  40857. _debugPushGroup(groupName: string, targetObject?: number): void;
  40858. /**
  40859. * @hidden
  40860. */
  40861. _debugPopGroup(targetObject?: number): void;
  40862. /**
  40863. * @hidden
  40864. */
  40865. _debugInsertMarker(text: string, targetObject?: number): void;
  40866. /**
  40867. * Shared initialization across engines types.
  40868. * @param canvas The canvas associated with this instance of the engine.
  40869. * @param doNotHandleTouchAction Defines that engine should ignore modifying touch action attribute and style
  40870. * @param audioEngine Defines if an audio engine should be created by default
  40871. */
  40872. protected _sharedInit(canvas: HTMLCanvasElement, doNotHandleTouchAction: boolean, audioEngine: boolean): void;
  40873. /**
  40874. * Gets a shader processor implementation fitting with the current engine type.
  40875. * @returns The shader processor implementation.
  40876. */
  40877. protected _getShaderProcessor(): Nullable<IShaderProcessor>;
  40878. /** @hidden */
  40879. _getShaderProcessingContext(): Nullable<ShaderProcessingContext>;
  40880. private _rebuildInternalTextures;
  40881. private _rebuildEffects;
  40882. /**
  40883. * Gets a boolean indicating if all created effects are ready
  40884. * @returns true if all effects are ready
  40885. */
  40886. areAllEffectsReady(): boolean;
  40887. protected _rebuildBuffers(): void;
  40888. protected _initGLContext(): void;
  40889. protected _initFeatures(): void;
  40890. /**
  40891. * Gets version of the current webGL context
  40892. * Keep it for back compat - use version instead
  40893. */
  40894. get webGLVersion(): number;
  40895. /**
  40896. * Gets a string identifying the name of the class
  40897. * @returns "Engine" string
  40898. */
  40899. getClassName(): string;
  40900. /**
  40901. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  40902. */
  40903. get isStencilEnable(): boolean;
  40904. /** @hidden */
  40905. _prepareWorkingCanvas(): void;
  40906. /**
  40907. * Reset the texture cache to empty state
  40908. */
  40909. resetTextureCache(): void;
  40910. /**
  40911. * Gets an object containing information about the current webGL context
  40912. * @returns an object containing the vendor, the renderer and the version of the current webGL context
  40913. */
  40914. getGlInfo(): {
  40915. vendor: string;
  40916. renderer: string;
  40917. version: string;
  40918. };
  40919. /**
  40920. * Defines the hardware scaling level.
  40921. * By default the hardware scaling level is computed from the window device ratio.
  40922. * 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.
  40923. * @param level defines the level to use
  40924. */
  40925. setHardwareScalingLevel(level: number): void;
  40926. /**
  40927. * Gets the current hardware scaling level.
  40928. * By default the hardware scaling level is computed from the window device ratio.
  40929. * 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.
  40930. * @returns a number indicating the current hardware scaling level
  40931. */
  40932. getHardwareScalingLevel(): number;
  40933. /**
  40934. * Gets the list of loaded textures
  40935. * @returns an array containing all loaded textures
  40936. */
  40937. getLoadedTexturesCache(): InternalTexture[];
  40938. /**
  40939. * Gets the object containing all engine capabilities
  40940. * @returns the EngineCapabilities object
  40941. */
  40942. getCaps(): EngineCapabilities;
  40943. /**
  40944. * stop executing a render loop function and remove it from the execution array
  40945. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  40946. */
  40947. stopRenderLoop(renderFunction?: () => void): void;
  40948. /** @hidden */
  40949. _renderLoop(): void;
  40950. /**
  40951. * Gets the HTML canvas attached with the current webGL context
  40952. * @returns a HTML canvas
  40953. */
  40954. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  40955. /**
  40956. * Gets host window
  40957. * @returns the host window object
  40958. */
  40959. getHostWindow(): Nullable<Window>;
  40960. /**
  40961. * Gets the current render width
  40962. * @param useScreen defines if screen size must be used (or the current render target if any)
  40963. * @returns a number defining the current render width
  40964. */
  40965. getRenderWidth(useScreen?: boolean): number;
  40966. /**
  40967. * Gets the current render height
  40968. * @param useScreen defines if screen size must be used (or the current render target if any)
  40969. * @returns a number defining the current render height
  40970. */
  40971. getRenderHeight(useScreen?: boolean): number;
  40972. /**
  40973. * Can be used to override the current requestAnimationFrame requester.
  40974. * @hidden
  40975. */
  40976. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  40977. /**
  40978. * Register and execute a render loop. The engine can have more than one render function
  40979. * @param renderFunction defines the function to continuously execute
  40980. */
  40981. runRenderLoop(renderFunction: () => void): void;
  40982. /**
  40983. * Clear the current render buffer or the current render target (if any is set up)
  40984. * @param color defines the color to use
  40985. * @param backBuffer defines if the back buffer must be cleared
  40986. * @param depth defines if the depth buffer must be cleared
  40987. * @param stencil defines if the stencil buffer must be cleared
  40988. */
  40989. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  40990. protected _viewportCached: {
  40991. x: number;
  40992. y: number;
  40993. z: number;
  40994. w: number;
  40995. };
  40996. /** @hidden */
  40997. _viewport(x: number, y: number, width: number, height: number): void;
  40998. /**
  40999. * Set the WebGL's viewport
  41000. * @param viewport defines the viewport element to be used
  41001. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  41002. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  41003. */
  41004. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  41005. /**
  41006. * Begin a new frame
  41007. */
  41008. beginFrame(): void;
  41009. /**
  41010. * Enf the current frame
  41011. */
  41012. endFrame(): void;
  41013. /**
  41014. * Resize the view according to the canvas' size
  41015. * @param forceSetSize true to force setting the sizes of the underlying canvas
  41016. */
  41017. resize(forceSetSize?: boolean): void;
  41018. /**
  41019. * Force a specific size of the canvas
  41020. * @param width defines the new canvas' width
  41021. * @param height defines the new canvas' height
  41022. * @param forceSetSize true to force setting the sizes of the underlying canvas
  41023. * @returns true if the size was changed
  41024. */
  41025. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  41026. /**
  41027. * Binds the frame buffer to the specified texture.
  41028. * @param texture The texture to render to or null for the default canvas
  41029. * @param faceIndex The face of the texture to render to in case of cube texture
  41030. * @param requiredWidth The width of the target to render to
  41031. * @param requiredHeight The height of the target to render to
  41032. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  41033. * @param lodLevel defines the lod level to bind to the frame buffer
  41034. * @param layer defines the 2d array index to bind to frame buffer to
  41035. */
  41036. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  41037. /** @hidden */
  41038. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  41039. /**
  41040. * Unbind the current render target texture from the webGL context
  41041. * @param texture defines the render target texture to unbind
  41042. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  41043. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  41044. */
  41045. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  41046. /**
  41047. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  41048. */
  41049. flushFramebuffer(): void;
  41050. /**
  41051. * Unbind the current render target and bind the default framebuffer
  41052. */
  41053. restoreDefaultFramebuffer(): void;
  41054. /** @hidden */
  41055. protected _resetVertexBufferBinding(): void;
  41056. /**
  41057. * Creates a vertex buffer
  41058. * @param data the data for the vertex buffer
  41059. * @returns the new WebGL static buffer
  41060. */
  41061. createVertexBuffer(data: DataArray): DataBuffer;
  41062. private _createVertexBuffer;
  41063. /**
  41064. * Creates a dynamic vertex buffer
  41065. * @param data the data for the dynamic vertex buffer
  41066. * @returns the new WebGL dynamic buffer
  41067. */
  41068. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  41069. protected _resetIndexBufferBinding(): void;
  41070. /**
  41071. * Creates a new index buffer
  41072. * @param indices defines the content of the index buffer
  41073. * @param updatable defines if the index buffer must be updatable
  41074. * @returns a new webGL buffer
  41075. */
  41076. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  41077. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  41078. /**
  41079. * Bind a webGL buffer to the webGL context
  41080. * @param buffer defines the buffer to bind
  41081. */
  41082. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  41083. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  41084. private bindBuffer;
  41085. /**
  41086. * update the bound buffer with the given data
  41087. * @param data defines the data to update
  41088. */
  41089. updateArrayBuffer(data: Float32Array): void;
  41090. private _vertexAttribPointer;
  41091. /** @hidden */
  41092. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  41093. private _bindVertexBuffersAttributes;
  41094. /**
  41095. * Records a vertex array object
  41096. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  41097. * @param vertexBuffers defines the list of vertex buffers to store
  41098. * @param indexBuffer defines the index buffer to store
  41099. * @param effect defines the effect to store
  41100. * @param overrideVertexBuffers defines optional list of avertex buffers that overrides the entries in vertexBuffers
  41101. * @returns the new vertex array object
  41102. */
  41103. recordVertexArrayObject(vertexBuffers: {
  41104. [key: string]: VertexBuffer;
  41105. }, indexBuffer: Nullable<DataBuffer>, effect: Effect, overrideVertexBuffers?: {
  41106. [kind: string]: Nullable<VertexBuffer>;
  41107. }): WebGLVertexArrayObject;
  41108. /**
  41109. * Bind a specific vertex array object
  41110. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  41111. * @param vertexArrayObject defines the vertex array object to bind
  41112. * @param indexBuffer defines the index buffer to bind
  41113. */
  41114. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  41115. /**
  41116. * Bind webGl buffers directly to the webGL context
  41117. * @param vertexBuffer defines the vertex buffer to bind
  41118. * @param indexBuffer defines the index buffer to bind
  41119. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  41120. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  41121. * @param effect defines the effect associated with the vertex buffer
  41122. */
  41123. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  41124. private _unbindVertexArrayObject;
  41125. /**
  41126. * Bind a list of vertex buffers to the webGL context
  41127. * @param vertexBuffers defines the list of vertex buffers to bind
  41128. * @param indexBuffer defines the index buffer to bind
  41129. * @param effect defines the effect associated with the vertex buffers
  41130. * @param overrideVertexBuffers defines optional list of avertex buffers that overrides the entries in vertexBuffers
  41131. */
  41132. bindBuffers(vertexBuffers: {
  41133. [key: string]: Nullable<VertexBuffer>;
  41134. }, indexBuffer: Nullable<DataBuffer>, effect: Effect, overrideVertexBuffers?: {
  41135. [kind: string]: Nullable<VertexBuffer>;
  41136. }): void;
  41137. /**
  41138. * Unbind all instance attributes
  41139. */
  41140. unbindInstanceAttributes(): void;
  41141. /**
  41142. * Release and free the memory of a vertex array object
  41143. * @param vao defines the vertex array object to delete
  41144. */
  41145. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  41146. /** @hidden */
  41147. _releaseBuffer(buffer: DataBuffer): boolean;
  41148. protected _deleteBuffer(buffer: DataBuffer): void;
  41149. /**
  41150. * Update the content of a webGL buffer used with instantiation and bind it to the webGL context
  41151. * @param instancesBuffer defines the webGL buffer to update and bind
  41152. * @param data defines the data to store in the buffer
  41153. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  41154. */
  41155. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  41156. /**
  41157. * Bind the content of a webGL buffer used with instantiation
  41158. * @param instancesBuffer defines the webGL buffer to bind
  41159. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  41160. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  41161. */
  41162. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  41163. /**
  41164. * Disable the instance attribute corresponding to the name in parameter
  41165. * @param name defines the name of the attribute to disable
  41166. */
  41167. disableInstanceAttributeByName(name: string): void;
  41168. /**
  41169. * Disable the instance attribute corresponding to the location in parameter
  41170. * @param attributeLocation defines the attribute location of the attribute to disable
  41171. */
  41172. disableInstanceAttribute(attributeLocation: number): void;
  41173. /**
  41174. * Disable the attribute corresponding to the location in parameter
  41175. * @param attributeLocation defines the attribute location of the attribute to disable
  41176. */
  41177. disableAttributeByIndex(attributeLocation: number): void;
  41178. /**
  41179. * Send a draw order
  41180. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  41181. * @param indexStart defines the starting index
  41182. * @param indexCount defines the number of index to draw
  41183. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  41184. */
  41185. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  41186. /**
  41187. * Draw a list of points
  41188. * @param verticesStart defines the index of first vertex to draw
  41189. * @param verticesCount defines the count of vertices to draw
  41190. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  41191. */
  41192. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  41193. /**
  41194. * Draw a list of unindexed primitives
  41195. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  41196. * @param verticesStart defines the index of first vertex to draw
  41197. * @param verticesCount defines the count of vertices to draw
  41198. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  41199. */
  41200. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  41201. /**
  41202. * Draw a list of indexed primitives
  41203. * @param fillMode defines the primitive to use
  41204. * @param indexStart defines the starting index
  41205. * @param indexCount defines the number of index to draw
  41206. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  41207. */
  41208. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  41209. /**
  41210. * Draw a list of unindexed primitives
  41211. * @param fillMode defines the primitive to use
  41212. * @param verticesStart defines the index of first vertex to draw
  41213. * @param verticesCount defines the count of vertices to draw
  41214. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  41215. */
  41216. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  41217. private _drawMode;
  41218. /** @hidden */
  41219. protected _reportDrawCall(): void;
  41220. /** @hidden */
  41221. _releaseEffect(effect: Effect): void;
  41222. /** @hidden */
  41223. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  41224. /**
  41225. * Create a new effect (used to store vertex/fragment shaders)
  41226. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  41227. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  41228. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  41229. * @param samplers defines an array of string used to represent textures
  41230. * @param defines defines the string containing the defines to use to compile the shaders
  41231. * @param fallbacks defines the list of potential fallbacks to use if shader compilation fails
  41232. * @param onCompiled defines a function to call when the effect creation is successful
  41233. * @param onError defines a function to call when the effect creation has failed
  41234. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  41235. * @returns the new Effect
  41236. */
  41237. 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;
  41238. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  41239. private _compileShader;
  41240. private _compileRawShader;
  41241. /** @hidden */
  41242. _getShaderSource(shader: WebGLShader): Nullable<string>;
  41243. /**
  41244. * Directly creates a webGL program
  41245. * @param pipelineContext defines the pipeline context to attach to
  41246. * @param vertexCode defines the vertex shader code to use
  41247. * @param fragmentCode defines the fragment shader code to use
  41248. * @param context defines the webGL context to use (if not set, the current one will be used)
  41249. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  41250. * @returns the new webGL program
  41251. */
  41252. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  41253. /**
  41254. * Creates a webGL program
  41255. * @param pipelineContext defines the pipeline context to attach to
  41256. * @param vertexCode defines the vertex shader code to use
  41257. * @param fragmentCode defines the fragment shader code to use
  41258. * @param defines defines the string containing the defines to use to compile the shaders
  41259. * @param context defines the webGL context to use (if not set, the current one will be used)
  41260. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  41261. * @returns the new webGL program
  41262. */
  41263. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  41264. /**
  41265. * Creates a new pipeline context
  41266. * @param shaderProcessingContext defines the shader processing context used during the processing if available
  41267. * @returns the new pipeline
  41268. */
  41269. createPipelineContext(shaderProcessingContext: Nullable<ShaderProcessingContext>): IPipelineContext;
  41270. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  41271. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  41272. /** @hidden */
  41273. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>, key: string): void;
  41274. /** @hidden */
  41275. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  41276. /** @hidden */
  41277. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  41278. /**
  41279. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  41280. * @param pipelineContext defines the pipeline context to use
  41281. * @param uniformsNames defines the list of uniform names
  41282. * @returns an array of webGL uniform locations
  41283. */
  41284. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  41285. /**
  41286. * Gets the list of active attributes for a given webGL program
  41287. * @param pipelineContext defines the pipeline context to use
  41288. * @param attributesNames defines the list of attribute names to get
  41289. * @returns an array of indices indicating the offset of each attribute
  41290. */
  41291. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  41292. /**
  41293. * Activates an effect, making it the current one (ie. the one used for rendering)
  41294. * @param effect defines the effect to activate
  41295. */
  41296. enableEffect(effect: Nullable<Effect>): void;
  41297. /**
  41298. * Set the value of an uniform to a number (int)
  41299. * @param uniform defines the webGL uniform location where to store the value
  41300. * @param value defines the int number to store
  41301. * @returns true if the value was set
  41302. */
  41303. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  41304. /**
  41305. * Set the value of an uniform to a int2
  41306. * @param uniform defines the webGL uniform location where to store the value
  41307. * @param x defines the 1st component of the value
  41308. * @param y defines the 2nd component of the value
  41309. * @returns true if the value was set
  41310. */
  41311. setInt2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  41312. /**
  41313. * Set the value of an uniform to a int3
  41314. * @param uniform defines the webGL uniform location where to store the value
  41315. * @param x defines the 1st component of the value
  41316. * @param y defines the 2nd component of the value
  41317. * @param z defines the 3rd component of the value
  41318. * @returns true if the value was set
  41319. */
  41320. setInt3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  41321. /**
  41322. * Set the value of an uniform to a int4
  41323. * @param uniform defines the webGL uniform location where to store the value
  41324. * @param x defines the 1st component of the value
  41325. * @param y defines the 2nd component of the value
  41326. * @param z defines the 3rd component of the value
  41327. * @param w defines the 4th component of the value
  41328. * @returns true if the value was set
  41329. */
  41330. setInt4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  41331. /**
  41332. * Set the value of an uniform to an array of int32
  41333. * @param uniform defines the webGL uniform location where to store the value
  41334. * @param array defines the array of int32 to store
  41335. * @returns true if the value was set
  41336. */
  41337. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  41338. /**
  41339. * Set the value of an uniform to an array of int32 (stored as vec2)
  41340. * @param uniform defines the webGL uniform location where to store the value
  41341. * @param array defines the array of int32 to store
  41342. * @returns true if the value was set
  41343. */
  41344. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  41345. /**
  41346. * Set the value of an uniform to an array of int32 (stored as vec3)
  41347. * @param uniform defines the webGL uniform location where to store the value
  41348. * @param array defines the array of int32 to store
  41349. * @returns true if the value was set
  41350. */
  41351. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  41352. /**
  41353. * Set the value of an uniform to an array of int32 (stored as vec4)
  41354. * @param uniform defines the webGL uniform location where to store the value
  41355. * @param array defines the array of int32 to store
  41356. * @returns true if the value was set
  41357. */
  41358. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  41359. /**
  41360. * Set the value of an uniform to an array of number
  41361. * @param uniform defines the webGL uniform location where to store the value
  41362. * @param array defines the array of number to store
  41363. * @returns true if the value was set
  41364. */
  41365. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  41366. /**
  41367. * Set the value of an uniform to an array of number (stored as vec2)
  41368. * @param uniform defines the webGL uniform location where to store the value
  41369. * @param array defines the array of number to store
  41370. * @returns true if the value was set
  41371. */
  41372. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  41373. /**
  41374. * Set the value of an uniform to an array of number (stored as vec3)
  41375. * @param uniform defines the webGL uniform location where to store the value
  41376. * @param array defines the array of number to store
  41377. * @returns true if the value was set
  41378. */
  41379. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  41380. /**
  41381. * Set the value of an uniform to an array of number (stored as vec4)
  41382. * @param uniform defines the webGL uniform location where to store the value
  41383. * @param array defines the array of number to store
  41384. * @returns true if the value was set
  41385. */
  41386. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  41387. /**
  41388. * Set the value of an uniform to an array of float32 (stored as matrices)
  41389. * @param uniform defines the webGL uniform location where to store the value
  41390. * @param matrices defines the array of float32 to store
  41391. * @returns true if the value was set
  41392. */
  41393. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  41394. /**
  41395. * Set the value of an uniform to a matrix (3x3)
  41396. * @param uniform defines the webGL uniform location where to store the value
  41397. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  41398. * @returns true if the value was set
  41399. */
  41400. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  41401. /**
  41402. * Set the value of an uniform to a matrix (2x2)
  41403. * @param uniform defines the webGL uniform location where to store the value
  41404. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  41405. * @returns true if the value was set
  41406. */
  41407. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  41408. /**
  41409. * Set the value of an uniform to a number (float)
  41410. * @param uniform defines the webGL uniform location where to store the value
  41411. * @param value defines the float number to store
  41412. * @returns true if the value was transferred
  41413. */
  41414. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  41415. /**
  41416. * Set the value of an uniform to a vec2
  41417. * @param uniform defines the webGL uniform location where to store the value
  41418. * @param x defines the 1st component of the value
  41419. * @param y defines the 2nd component of the value
  41420. * @returns true if the value was set
  41421. */
  41422. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  41423. /**
  41424. * Set the value of an uniform to a vec3
  41425. * @param uniform defines the webGL uniform location where to store the value
  41426. * @param x defines the 1st component of the value
  41427. * @param y defines the 2nd component of the value
  41428. * @param z defines the 3rd component of the value
  41429. * @returns true if the value was set
  41430. */
  41431. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  41432. /**
  41433. * Set the value of an uniform to a vec4
  41434. * @param uniform defines the webGL uniform location where to store the value
  41435. * @param x defines the 1st component of the value
  41436. * @param y defines the 2nd component of the value
  41437. * @param z defines the 3rd component of the value
  41438. * @param w defines the 4th component of the value
  41439. * @returns true if the value was set
  41440. */
  41441. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  41442. /**
  41443. * Apply all cached states (depth, culling, stencil and alpha)
  41444. */
  41445. applyStates(): void;
  41446. /**
  41447. * Enable or disable color writing
  41448. * @param enable defines the state to set
  41449. */
  41450. setColorWrite(enable: boolean): void;
  41451. /**
  41452. * Gets a boolean indicating if color writing is enabled
  41453. * @returns the current color writing state
  41454. */
  41455. getColorWrite(): boolean;
  41456. /**
  41457. * Gets the depth culling state manager
  41458. */
  41459. get depthCullingState(): DepthCullingState;
  41460. /**
  41461. * Gets the alpha state manager
  41462. */
  41463. get alphaState(): AlphaState;
  41464. /**
  41465. * Gets the stencil state manager
  41466. */
  41467. get stencilState(): StencilState;
  41468. /**
  41469. * Clears the list of texture accessible through engine.
  41470. * This can help preventing texture load conflict due to name collision.
  41471. */
  41472. clearInternalTexturesCache(): void;
  41473. /**
  41474. * Force the entire cache to be cleared
  41475. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  41476. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  41477. */
  41478. wipeCaches(bruteForce?: boolean): void;
  41479. /** @hidden */
  41480. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  41481. min: number;
  41482. mag: number;
  41483. };
  41484. /** @hidden */
  41485. protected _createTexture(): WebGLTexture;
  41486. /** @hidden */
  41487. _createHardwareTexture(): HardwareTextureWrapper;
  41488. 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 | {
  41489. width: number;
  41490. height: number;
  41491. }, invertY: boolean, noMipmap: boolean, isCompressed: boolean, processFunction: (width: number, height: number, img: HTMLImageElement | ImageBitmap | {
  41492. width: number;
  41493. height: number;
  41494. }, extension: string, texture: InternalTexture, continuationCallback: () => void) => boolean, samplingMode: number) => void, prepareTextureProcessFunction: (width: number, height: number, img: HTMLImageElement | ImageBitmap | {
  41495. width: number;
  41496. height: number;
  41497. }, 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;
  41498. /**
  41499. * Usually called from Texture.ts.
  41500. * Passed information to create a WebGLTexture
  41501. * @param url defines a value which contains one of the following:
  41502. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  41503. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  41504. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  41505. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  41506. * @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)
  41507. * @param scene needed for loading to the correct scene
  41508. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  41509. * @param onLoad optional callback to be called upon successful completion
  41510. * @param onError optional callback to be called upon failure
  41511. * @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
  41512. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  41513. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  41514. * @param forcedExtension defines the extension to use to pick the right loader
  41515. * @param mimeType defines an optional mime type
  41516. * @param loaderOptions options to be passed to the loader
  41517. * @returns a InternalTexture for assignment back into BABYLON.Texture
  41518. */
  41519. 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;
  41520. /**
  41521. * Loads an image as an HTMLImageElement.
  41522. * @param input url string, ArrayBuffer, or Blob to load
  41523. * @param onLoad callback called when the image successfully loads
  41524. * @param onError callback called when the image fails to load
  41525. * @param offlineProvider offline provider for caching
  41526. * @param mimeType optional mime type
  41527. * @returns the HTMLImageElement of the loaded image
  41528. * @hidden
  41529. */
  41530. 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>;
  41531. /**
  41532. * @hidden
  41533. */
  41534. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  41535. private _unpackFlipYCached;
  41536. /**
  41537. * In case you are sharing the context with other applications, it might
  41538. * be interested to not cache the unpack flip y state to ensure a consistent
  41539. * value would be set.
  41540. */
  41541. enableUnpackFlipYCached: boolean;
  41542. /** @hidden */
  41543. _unpackFlipY(value: boolean): void;
  41544. /** @hidden */
  41545. _getUnpackAlignement(): number;
  41546. private _getTextureTarget;
  41547. /**
  41548. * Update the sampling mode of a given texture
  41549. * @param samplingMode defines the required sampling mode
  41550. * @param texture defines the texture to update
  41551. * @param generateMipMaps defines whether to generate mipmaps for the texture
  41552. */
  41553. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  41554. /**
  41555. * Update the dimensions of a texture
  41556. * @param texture texture to update
  41557. * @param width new width of the texture
  41558. * @param height new height of the texture
  41559. * @param depth new depth of the texture
  41560. */
  41561. updateTextureDimensions(texture: InternalTexture, width: number, height: number, depth?: number): void;
  41562. /**
  41563. * Update the sampling mode of a given texture
  41564. * @param texture defines the texture to update
  41565. * @param wrapU defines the texture wrap mode of the u coordinates
  41566. * @param wrapV defines the texture wrap mode of the v coordinates
  41567. * @param wrapR defines the texture wrap mode of the r coordinates
  41568. */
  41569. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  41570. /** @hidden */
  41571. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  41572. width: number;
  41573. height: number;
  41574. layers?: number;
  41575. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number, samples?: number): void;
  41576. /** @hidden */
  41577. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41578. /** @hidden */
  41579. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  41580. /**
  41581. * Update a portion of an internal texture
  41582. * @param texture defines the texture to update
  41583. * @param imageData defines the data to store into the texture
  41584. * @param xOffset defines the x coordinates of the update rectangle
  41585. * @param yOffset defines the y coordinates of the update rectangle
  41586. * @param width defines the width of the update rectangle
  41587. * @param height defines the height of the update rectangle
  41588. * @param faceIndex defines the face index if texture is a cube (0 by default)
  41589. * @param lod defines the lod level to update (0 by default)
  41590. */
  41591. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  41592. /** @hidden */
  41593. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41594. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  41595. private _prepareWebGLTexture;
  41596. /** @hidden */
  41597. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  41598. private _getDepthStencilBuffer;
  41599. /** @hidden */
  41600. _releaseFramebufferObjects(texture: InternalTexture): void;
  41601. /** @hidden */
  41602. _releaseTexture(texture: InternalTexture): void;
  41603. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  41604. protected _setProgram(program: WebGLProgram): void;
  41605. protected _boundUniforms: {
  41606. [key: number]: WebGLUniformLocation;
  41607. };
  41608. /**
  41609. * Binds an effect to the webGL context
  41610. * @param effect defines the effect to bind
  41611. */
  41612. bindSamplers(effect: Effect): void;
  41613. private _activateCurrentTexture;
  41614. /** @hidden */
  41615. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  41616. /** @hidden */
  41617. _bindTexture(channel: number, texture: Nullable<InternalTexture>, name: string): void;
  41618. /**
  41619. * Unbind all textures from the webGL context
  41620. */
  41621. unbindAllTextures(): void;
  41622. /**
  41623. * Sets a texture to the according uniform.
  41624. * @param channel The texture channel
  41625. * @param uniform The uniform to set
  41626. * @param texture The texture to apply
  41627. * @param name The name of the uniform in the effect
  41628. */
  41629. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<ThinTexture>, name: string): void;
  41630. private _bindSamplerUniformToChannel;
  41631. private _getTextureWrapMode;
  41632. protected _setTexture(channel: number, texture: Nullable<ThinTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean, name?: string): boolean;
  41633. /**
  41634. * Sets an array of texture to the webGL context
  41635. * @param channel defines the channel where the texture array must be set
  41636. * @param uniform defines the associated uniform location
  41637. * @param textures defines the array of textures to bind
  41638. * @param name name of the channel
  41639. */
  41640. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: ThinTexture[], name: string): void;
  41641. /** @hidden */
  41642. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  41643. private _setTextureParameterFloat;
  41644. private _setTextureParameterInteger;
  41645. /**
  41646. * Unbind all vertex attributes from the webGL context
  41647. */
  41648. unbindAllAttributes(): void;
  41649. /**
  41650. * 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
  41651. */
  41652. releaseEffects(): void;
  41653. /**
  41654. * Dispose and release all associated resources
  41655. */
  41656. dispose(): void;
  41657. /**
  41658. * Attach a new callback raised when context lost event is fired
  41659. * @param callback defines the callback to call
  41660. */
  41661. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  41662. /**
  41663. * Attach a new callback raised when context restored event is fired
  41664. * @param callback defines the callback to call
  41665. */
  41666. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  41667. /**
  41668. * Get the current error code of the webGL context
  41669. * @returns the error code
  41670. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  41671. */
  41672. getError(): number;
  41673. private _canRenderToFloatFramebuffer;
  41674. private _canRenderToHalfFloatFramebuffer;
  41675. private _canRenderToFramebuffer;
  41676. /** @hidden */
  41677. _getWebGLTextureType(type: number): number;
  41678. /** @hidden */
  41679. _getInternalFormat(format: number): number;
  41680. /** @hidden */
  41681. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  41682. /** @hidden */
  41683. _getRGBAMultiSampleBufferFormat(type: number): number;
  41684. /** @hidden */
  41685. _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;
  41686. /**
  41687. * Loads a file from a url
  41688. * @param url url to load
  41689. * @param onSuccess callback called when the file successfully loads
  41690. * @param onProgress callback called while file is loading (if the server supports this mode)
  41691. * @param offlineProvider defines the offline provider for caching
  41692. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  41693. * @param onError callback called when the file fails to load
  41694. * @returns a file request object
  41695. * @hidden
  41696. */
  41697. 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;
  41698. /**
  41699. * Reads pixels from the current frame buffer. Please note that this function can be slow
  41700. * @param x defines the x coordinate of the rectangle where pixels must be read
  41701. * @param y defines the y coordinate of the rectangle where pixels must be read
  41702. * @param width defines the width of the rectangle where pixels must be read
  41703. * @param height defines the height of the rectangle where pixels must be read
  41704. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  41705. * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels
  41706. * @returns a ArrayBufferView promise (Uint8Array) containing RGBA colors
  41707. */
  41708. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean, flushRenderer?: boolean): Promise<ArrayBufferView>;
  41709. private static _IsSupported;
  41710. private static _HasMajorPerformanceCaveat;
  41711. /**
  41712. * Gets a boolean indicating if the engine can be instantiated (ie. if a webGL context can be found)
  41713. */
  41714. static get IsSupported(): boolean;
  41715. /**
  41716. * Gets a boolean indicating if the engine can be instantiated (ie. if a webGL context can be found)
  41717. * @returns true if the engine can be created
  41718. * @ignorenaming
  41719. */
  41720. static isSupported(): boolean;
  41721. /**
  41722. * 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)
  41723. */
  41724. static get HasMajorPerformanceCaveat(): boolean;
  41725. /**
  41726. * Find the next highest power of two.
  41727. * @param x Number to start search from.
  41728. * @return Next highest power of two.
  41729. */
  41730. static CeilingPOT(x: number): number;
  41731. /**
  41732. * Find the next lowest power of two.
  41733. * @param x Number to start search from.
  41734. * @return Next lowest power of two.
  41735. */
  41736. static FloorPOT(x: number): number;
  41737. /**
  41738. * Find the nearest power of two.
  41739. * @param x Number to start search from.
  41740. * @return Next nearest power of two.
  41741. */
  41742. static NearestPOT(x: number): number;
  41743. /**
  41744. * Get the closest exponent of two
  41745. * @param value defines the value to approximate
  41746. * @param max defines the maximum value to return
  41747. * @param mode defines how to define the closest value
  41748. * @returns closest exponent of two of the given value
  41749. */
  41750. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  41751. /**
  41752. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  41753. * @param func - the function to be called
  41754. * @param requester - the object that will request the next frame. Falls back to window.
  41755. * @returns frame number
  41756. */
  41757. static QueueNewFrame(func: () => void, requester?: any): number;
  41758. /**
  41759. * Gets host document
  41760. * @returns the host document object
  41761. */
  41762. getHostDocument(): Nullable<Document>;
  41763. }
  41764. }
  41765. declare module BABYLON {
  41766. /**
  41767. * Defines the source of the internal texture
  41768. */
  41769. export enum InternalTextureSource {
  41770. /**
  41771. * The source of the texture data is unknown
  41772. */
  41773. Unknown = 0,
  41774. /**
  41775. * Texture data comes from an URL
  41776. */
  41777. Url = 1,
  41778. /**
  41779. * Texture data is only used for temporary storage
  41780. */
  41781. Temp = 2,
  41782. /**
  41783. * Texture data comes from raw data (ArrayBuffer)
  41784. */
  41785. Raw = 3,
  41786. /**
  41787. * Texture content is dynamic (video or dynamic texture)
  41788. */
  41789. Dynamic = 4,
  41790. /**
  41791. * Texture content is generated by rendering to it
  41792. */
  41793. RenderTarget = 5,
  41794. /**
  41795. * Texture content is part of a multi render target process
  41796. */
  41797. MultiRenderTarget = 6,
  41798. /**
  41799. * Texture data comes from a cube data file
  41800. */
  41801. Cube = 7,
  41802. /**
  41803. * Texture data comes from a raw cube data
  41804. */
  41805. CubeRaw = 8,
  41806. /**
  41807. * Texture data come from a prefiltered cube data file
  41808. */
  41809. CubePrefiltered = 9,
  41810. /**
  41811. * Texture content is raw 3D data
  41812. */
  41813. Raw3D = 10,
  41814. /**
  41815. * Texture content is raw 2D array data
  41816. */
  41817. Raw2DArray = 11,
  41818. /**
  41819. * Texture content is a depth texture
  41820. */
  41821. Depth = 12,
  41822. /**
  41823. * Texture data comes from a raw cube data encoded with RGBD
  41824. */
  41825. CubeRawRGBD = 13
  41826. }
  41827. /**
  41828. * Class used to store data associated with WebGL texture data for the engine
  41829. * This class should not be used directly
  41830. */
  41831. export class InternalTexture {
  41832. /** @hidden */
  41833. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  41834. /**
  41835. * Defines if the texture is ready
  41836. */
  41837. isReady: boolean;
  41838. /**
  41839. * Defines if the texture is a cube texture
  41840. */
  41841. isCube: boolean;
  41842. /**
  41843. * Defines if the texture contains 3D data
  41844. */
  41845. is3D: boolean;
  41846. /**
  41847. * Defines if the texture contains 2D array data
  41848. */
  41849. is2DArray: boolean;
  41850. /**
  41851. * Defines if the texture contains multiview data
  41852. */
  41853. isMultiview: boolean;
  41854. /**
  41855. * Gets the URL used to load this texture
  41856. */
  41857. url: string;
  41858. /** @hidden */
  41859. _originalUrl: string;
  41860. /**
  41861. * Gets the sampling mode of the texture
  41862. */
  41863. samplingMode: number;
  41864. /**
  41865. * Gets a boolean indicating if the texture needs mipmaps generation
  41866. */
  41867. generateMipMaps: boolean;
  41868. /**
  41869. * Gets the number of samples used by the texture (WebGL2+ only)
  41870. */
  41871. samples: number;
  41872. /**
  41873. * Gets the type of the texture (int, float...)
  41874. */
  41875. type: number;
  41876. /**
  41877. * Gets the format of the texture (RGB, RGBA...)
  41878. */
  41879. format: number;
  41880. /**
  41881. * Observable called when the texture is loaded
  41882. */
  41883. onLoadedObservable: Observable<InternalTexture>;
  41884. /**
  41885. * Gets the width of the texture
  41886. */
  41887. width: number;
  41888. /**
  41889. * Gets the height of the texture
  41890. */
  41891. height: number;
  41892. /**
  41893. * Gets the depth of the texture
  41894. */
  41895. depth: number;
  41896. /**
  41897. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  41898. */
  41899. baseWidth: number;
  41900. /**
  41901. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  41902. */
  41903. baseHeight: number;
  41904. /**
  41905. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  41906. */
  41907. baseDepth: number;
  41908. /**
  41909. * Gets a boolean indicating if the texture is inverted on Y axis
  41910. */
  41911. invertY: boolean;
  41912. /** @hidden */
  41913. _invertVScale: boolean;
  41914. /** @hidden */
  41915. _associatedChannel: number;
  41916. /** @hidden */
  41917. _source: InternalTextureSource;
  41918. /** @hidden */
  41919. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  41920. /** @hidden */
  41921. _bufferView: Nullable<ArrayBufferView>;
  41922. /** @hidden */
  41923. _bufferViewArray: Nullable<ArrayBufferView[]>;
  41924. /** @hidden */
  41925. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  41926. /** @hidden */
  41927. _size: number;
  41928. /** @hidden */
  41929. _extension: string;
  41930. /** @hidden */
  41931. _files: Nullable<string[]>;
  41932. /** @hidden */
  41933. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  41934. /** @hidden */
  41935. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  41936. /** @hidden */
  41937. _framebuffer: Nullable<WebGLFramebuffer>;
  41938. /** @hidden */
  41939. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  41940. /** @hidden */
  41941. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  41942. /** @hidden */
  41943. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  41944. /** @hidden */
  41945. _attachments: Nullable<number[]>;
  41946. /** @hidden */
  41947. _textureArray: Nullable<InternalTexture[]>;
  41948. /** @hidden */
  41949. _cachedCoordinatesMode: Nullable<number>;
  41950. /** @hidden */
  41951. _cachedWrapU: Nullable<number>;
  41952. /** @hidden */
  41953. _cachedWrapV: Nullable<number>;
  41954. /** @hidden */
  41955. _cachedWrapR: Nullable<number>;
  41956. /** @hidden */
  41957. _cachedAnisotropicFilteringLevel: Nullable<number>;
  41958. /** @hidden */
  41959. _isDisabled: boolean;
  41960. /** @hidden */
  41961. _compression: Nullable<string>;
  41962. /** @hidden */
  41963. _generateStencilBuffer: boolean;
  41964. /** @hidden */
  41965. _generateDepthBuffer: boolean;
  41966. /** @hidden */
  41967. _comparisonFunction: number;
  41968. /** @hidden */
  41969. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  41970. /** @hidden */
  41971. _sphericalPolynomialPromise: Nullable<Promise<SphericalPolynomial>>;
  41972. /** @hidden */
  41973. _sphericalPolynomialComputed: boolean;
  41974. /** @hidden */
  41975. _lodGenerationScale: number;
  41976. /** @hidden */
  41977. _lodGenerationOffset: number;
  41978. /** @hidden */
  41979. _depthStencilTexture: Nullable<InternalTexture>;
  41980. /** @hidden */
  41981. _colorTextureArray: Nullable<WebGLTexture>;
  41982. /** @hidden */
  41983. _depthStencilTextureArray: Nullable<WebGLTexture>;
  41984. /** @hidden */
  41985. _lodTextureHigh: Nullable<BaseTexture>;
  41986. /** @hidden */
  41987. _lodTextureMid: Nullable<BaseTexture>;
  41988. /** @hidden */
  41989. _lodTextureLow: Nullable<BaseTexture>;
  41990. /** @hidden */
  41991. _isRGBD: boolean;
  41992. /** @hidden */
  41993. _linearSpecularLOD: boolean;
  41994. /** @hidden */
  41995. _irradianceTexture: Nullable<BaseTexture>;
  41996. /** @hidden */
  41997. _hardwareTexture: Nullable<HardwareTextureWrapper>;
  41998. /** @hidden */
  41999. _references: number;
  42000. /** @hidden */
  42001. _gammaSpace: Nullable<boolean>;
  42002. private _engine;
  42003. private _uniqueId;
  42004. private static _Counter;
  42005. /** Gets the unique id of the internal texture */
  42006. get uniqueId(): number;
  42007. /**
  42008. * Gets the Engine the texture belongs to.
  42009. * @returns The babylon engine
  42010. */
  42011. getEngine(): ThinEngine;
  42012. /**
  42013. * Gets the data source type of the texture
  42014. */
  42015. get source(): InternalTextureSource;
  42016. /**
  42017. * Creates a new InternalTexture
  42018. * @param engine defines the engine to use
  42019. * @param source defines the type of data that will be used
  42020. * @param delayAllocation if the texture allocation should be delayed (default: false)
  42021. */
  42022. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  42023. /**
  42024. * Increments the number of references (ie. the number of Texture that point to it)
  42025. */
  42026. incrementReferences(): void;
  42027. /**
  42028. * Change the size of the texture (not the size of the content)
  42029. * @param width defines the new width
  42030. * @param height defines the new height
  42031. * @param depth defines the new depth (1 by default)
  42032. */
  42033. updateSize(width: int, height: int, depth?: int): void;
  42034. /** @hidden */
  42035. _rebuild(): void;
  42036. /** @hidden */
  42037. _swapAndDie(target: InternalTexture): void;
  42038. /**
  42039. * Dispose the current allocated resources
  42040. */
  42041. dispose(): void;
  42042. }
  42043. }
  42044. declare module BABYLON {
  42045. /**
  42046. * Interface used to present a loading screen while loading a scene
  42047. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42048. */
  42049. export interface ILoadingScreen {
  42050. /**
  42051. * Function called to display the loading screen
  42052. */
  42053. displayLoadingUI: () => void;
  42054. /**
  42055. * Function called to hide the loading screen
  42056. */
  42057. hideLoadingUI: () => void;
  42058. /**
  42059. * Gets or sets the color to use for the background
  42060. */
  42061. loadingUIBackgroundColor: string;
  42062. /**
  42063. * Gets or sets the text to display while loading
  42064. */
  42065. loadingUIText: string;
  42066. }
  42067. /**
  42068. * Class used for the default loading screen
  42069. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42070. */
  42071. export class DefaultLoadingScreen implements ILoadingScreen {
  42072. private _renderingCanvas;
  42073. private _loadingText;
  42074. private _loadingDivBackgroundColor;
  42075. private _loadingDiv;
  42076. private _loadingTextDiv;
  42077. /** Gets or sets the logo url to use for the default loading screen */
  42078. static DefaultLogoUrl: string;
  42079. /** Gets or sets the spinner url to use for the default loading screen */
  42080. static DefaultSpinnerUrl: string;
  42081. /**
  42082. * Creates a new default loading screen
  42083. * @param _renderingCanvas defines the canvas used to render the scene
  42084. * @param _loadingText defines the default text to display
  42085. * @param _loadingDivBackgroundColor defines the default background color
  42086. */
  42087. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  42088. /**
  42089. * Function called to display the loading screen
  42090. */
  42091. displayLoadingUI(): void;
  42092. /**
  42093. * Function called to hide the loading screen
  42094. */
  42095. hideLoadingUI(): void;
  42096. /**
  42097. * Gets or sets the text to display while loading
  42098. */
  42099. set loadingUIText(text: string);
  42100. get loadingUIText(): string;
  42101. /**
  42102. * Gets or sets the color to use for the background
  42103. */
  42104. get loadingUIBackgroundColor(): string;
  42105. set loadingUIBackgroundColor(color: string);
  42106. private _resizeLoadingUI;
  42107. }
  42108. }
  42109. declare module BABYLON {
  42110. /**
  42111. * Interface for any object that can request an animation frame
  42112. */
  42113. export interface ICustomAnimationFrameRequester {
  42114. /**
  42115. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  42116. */
  42117. renderFunction?: Function;
  42118. /**
  42119. * Called to request the next frame to render to
  42120. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  42121. */
  42122. requestAnimationFrame: Function;
  42123. /**
  42124. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  42125. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  42126. */
  42127. requestID?: number;
  42128. }
  42129. }
  42130. declare module BABYLON {
  42131. /**
  42132. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  42133. */
  42134. export class PerformanceMonitor {
  42135. private _enabled;
  42136. private _rollingFrameTime;
  42137. private _lastFrameTimeMs;
  42138. /**
  42139. * constructor
  42140. * @param frameSampleSize The number of samples required to saturate the sliding window
  42141. */
  42142. constructor(frameSampleSize?: number);
  42143. /**
  42144. * Samples current frame
  42145. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  42146. */
  42147. sampleFrame(timeMs?: number): void;
  42148. /**
  42149. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  42150. */
  42151. get averageFrameTime(): number;
  42152. /**
  42153. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  42154. */
  42155. get averageFrameTimeVariance(): number;
  42156. /**
  42157. * Returns the frame time of the most recent frame
  42158. */
  42159. get instantaneousFrameTime(): number;
  42160. /**
  42161. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  42162. */
  42163. get averageFPS(): number;
  42164. /**
  42165. * Returns the average framerate in frames per second using the most recent frame time
  42166. */
  42167. get instantaneousFPS(): number;
  42168. /**
  42169. * Returns true if enough samples have been taken to completely fill the sliding window
  42170. */
  42171. get isSaturated(): boolean;
  42172. /**
  42173. * Enables contributions to the sliding window sample set
  42174. */
  42175. enable(): void;
  42176. /**
  42177. * Disables contributions to the sliding window sample set
  42178. * Samples will not be interpolated over the disabled period
  42179. */
  42180. disable(): void;
  42181. /**
  42182. * Returns true if sampling is enabled
  42183. */
  42184. get isEnabled(): boolean;
  42185. /**
  42186. * Resets performance monitor
  42187. */
  42188. reset(): void;
  42189. }
  42190. /**
  42191. * RollingAverage
  42192. *
  42193. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  42194. */
  42195. export class RollingAverage {
  42196. /**
  42197. * Current average
  42198. */
  42199. average: number;
  42200. /**
  42201. * Current variance
  42202. */
  42203. variance: number;
  42204. protected _samples: Array<number>;
  42205. protected _sampleCount: number;
  42206. protected _pos: number;
  42207. protected _m2: number;
  42208. /**
  42209. * constructor
  42210. * @param length The number of samples required to saturate the sliding window
  42211. */
  42212. constructor(length: number);
  42213. /**
  42214. * Adds a sample to the sample set
  42215. * @param v The sample value
  42216. */
  42217. add(v: number): void;
  42218. /**
  42219. * Returns previously added values or null if outside of history or outside the sliding window domain
  42220. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  42221. * @return Value previously recorded with add() or null if outside of range
  42222. */
  42223. history(i: number): number;
  42224. /**
  42225. * Returns true if enough samples have been taken to completely fill the sliding window
  42226. * @return true if sample-set saturated
  42227. */
  42228. isSaturated(): boolean;
  42229. /**
  42230. * Resets the rolling average (equivalent to 0 samples taken so far)
  42231. */
  42232. reset(): void;
  42233. /**
  42234. * Wraps a value around the sample range boundaries
  42235. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  42236. * @return Wrapped position in sample range
  42237. */
  42238. protected _wrapPosition(i: number): number;
  42239. }
  42240. }
  42241. declare module BABYLON {
  42242. /**
  42243. * This class is used to track a performance counter which is number based.
  42244. * The user has access to many properties which give statistics of different nature.
  42245. *
  42246. * The implementer can track two kinds of Performance Counter: time and count.
  42247. * 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.
  42248. * 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.
  42249. */
  42250. export class PerfCounter {
  42251. /**
  42252. * Gets or sets a global boolean to turn on and off all the counters
  42253. */
  42254. static Enabled: boolean;
  42255. /**
  42256. * Returns the smallest value ever
  42257. */
  42258. get min(): number;
  42259. /**
  42260. * Returns the biggest value ever
  42261. */
  42262. get max(): number;
  42263. /**
  42264. * Returns the average value since the performance counter is running
  42265. */
  42266. get average(): number;
  42267. /**
  42268. * Returns the average value of the last second the counter was monitored
  42269. */
  42270. get lastSecAverage(): number;
  42271. /**
  42272. * Returns the current value
  42273. */
  42274. get current(): number;
  42275. /**
  42276. * Gets the accumulated total
  42277. */
  42278. get total(): number;
  42279. /**
  42280. * Gets the total value count
  42281. */
  42282. get count(): number;
  42283. /**
  42284. * Creates a new counter
  42285. */
  42286. constructor();
  42287. /**
  42288. * Call this method to start monitoring a new frame.
  42289. * 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.
  42290. */
  42291. fetchNewFrame(): void;
  42292. /**
  42293. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  42294. * @param newCount the count value to add to the monitored count
  42295. * @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.
  42296. */
  42297. addCount(newCount: number, fetchResult: boolean): void;
  42298. /**
  42299. * Start monitoring this performance counter
  42300. */
  42301. beginMonitoring(): void;
  42302. /**
  42303. * Compute the time lapsed since the previous beginMonitoring() call.
  42304. * @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
  42305. */
  42306. endMonitoring(newFrame?: boolean): void;
  42307. private _fetchResult;
  42308. private _startMonitoringTime;
  42309. private _min;
  42310. private _max;
  42311. private _average;
  42312. private _current;
  42313. private _totalValueCount;
  42314. private _totalAccumulated;
  42315. private _lastSecAverage;
  42316. private _lastSecAccumulated;
  42317. private _lastSecTime;
  42318. private _lastSecValueCount;
  42319. }
  42320. }
  42321. declare module BABYLON {
  42322. interface ThinEngine {
  42323. /** @hidden */
  42324. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Promise<ArrayBufferView>;
  42325. /** @hidden */
  42326. _readTexturePixelsSync(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): ArrayBufferView;
  42327. }
  42328. }
  42329. declare module BABYLON {
  42330. /**
  42331. * Class used to work with sound analyzer using fast fourier transform (FFT)
  42332. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42333. */
  42334. export class Analyser {
  42335. /**
  42336. * Gets or sets the smoothing
  42337. * @ignorenaming
  42338. */
  42339. SMOOTHING: number;
  42340. /**
  42341. * Gets or sets the FFT table size
  42342. * @ignorenaming
  42343. */
  42344. FFT_SIZE: number;
  42345. /**
  42346. * Gets or sets the bar graph amplitude
  42347. * @ignorenaming
  42348. */
  42349. BARGRAPHAMPLITUDE: number;
  42350. /**
  42351. * Gets or sets the position of the debug canvas
  42352. * @ignorenaming
  42353. */
  42354. DEBUGCANVASPOS: {
  42355. x: number;
  42356. y: number;
  42357. };
  42358. /**
  42359. * Gets or sets the debug canvas size
  42360. * @ignorenaming
  42361. */
  42362. DEBUGCANVASSIZE: {
  42363. width: number;
  42364. height: number;
  42365. };
  42366. private _byteFreqs;
  42367. private _byteTime;
  42368. private _floatFreqs;
  42369. private _webAudioAnalyser;
  42370. private _debugCanvas;
  42371. private _debugCanvasContext;
  42372. private _scene;
  42373. private _registerFunc;
  42374. private _audioEngine;
  42375. /**
  42376. * Creates a new analyser
  42377. * @param scene defines hosting scene
  42378. */
  42379. constructor(scene: Scene);
  42380. /**
  42381. * Get the number of data values you will have to play with for the visualization
  42382. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  42383. * @returns a number
  42384. */
  42385. getFrequencyBinCount(): number;
  42386. /**
  42387. * Gets the current frequency data as a byte array
  42388. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  42389. * @returns a Uint8Array
  42390. */
  42391. getByteFrequencyData(): Uint8Array;
  42392. /**
  42393. * Gets the current waveform as a byte array
  42394. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  42395. * @returns a Uint8Array
  42396. */
  42397. getByteTimeDomainData(): Uint8Array;
  42398. /**
  42399. * Gets the current frequency data as a float array
  42400. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  42401. * @returns a Float32Array
  42402. */
  42403. getFloatFrequencyData(): Float32Array;
  42404. /**
  42405. * Renders the debug canvas
  42406. */
  42407. drawDebugCanvas(): void;
  42408. /**
  42409. * Stops rendering the debug canvas and removes it
  42410. */
  42411. stopDebugCanvas(): void;
  42412. /**
  42413. * Connects two audio nodes
  42414. * @param inputAudioNode defines first node to connect
  42415. * @param outputAudioNode defines second node to connect
  42416. */
  42417. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  42418. /**
  42419. * Releases all associated resources
  42420. */
  42421. dispose(): void;
  42422. }
  42423. }
  42424. declare module BABYLON {
  42425. /**
  42426. * This represents an audio engine and it is responsible
  42427. * to play, synchronize and analyse sounds throughout the application.
  42428. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42429. */
  42430. export interface IAudioEngine extends IDisposable {
  42431. /**
  42432. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  42433. */
  42434. readonly canUseWebAudio: boolean;
  42435. /**
  42436. * Gets the current AudioContext if available.
  42437. */
  42438. readonly audioContext: Nullable<AudioContext>;
  42439. /**
  42440. * The master gain node defines the global audio volume of your audio engine.
  42441. */
  42442. readonly masterGain: GainNode;
  42443. /**
  42444. * Gets whether or not mp3 are supported by your browser.
  42445. */
  42446. readonly isMP3supported: boolean;
  42447. /**
  42448. * Gets whether or not ogg are supported by your browser.
  42449. */
  42450. readonly isOGGsupported: boolean;
  42451. /**
  42452. * Defines if Babylon should emit a warning if WebAudio is not supported.
  42453. * @ignoreNaming
  42454. */
  42455. WarnedWebAudioUnsupported: boolean;
  42456. /**
  42457. * Defines if the audio engine relies on a custom unlocked button.
  42458. * In this case, the embedded button will not be displayed.
  42459. */
  42460. useCustomUnlockedButton: boolean;
  42461. /**
  42462. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  42463. */
  42464. readonly unlocked: boolean;
  42465. /**
  42466. * Event raised when audio has been unlocked on the browser.
  42467. */
  42468. onAudioUnlockedObservable: Observable<IAudioEngine>;
  42469. /**
  42470. * Event raised when audio has been locked on the browser.
  42471. */
  42472. onAudioLockedObservable: Observable<IAudioEngine>;
  42473. /**
  42474. * Flags the audio engine in Locked state.
  42475. * This happens due to new browser policies preventing audio to autoplay.
  42476. */
  42477. lock(): void;
  42478. /**
  42479. * Unlocks the audio engine once a user action has been done on the dom.
  42480. * This is helpful to resume play once browser policies have been satisfied.
  42481. */
  42482. unlock(): void;
  42483. /**
  42484. * Gets the global volume sets on the master gain.
  42485. * @returns the global volume if set or -1 otherwise
  42486. */
  42487. getGlobalVolume(): number;
  42488. /**
  42489. * Sets the global volume of your experience (sets on the master gain).
  42490. * @param newVolume Defines the new global volume of the application
  42491. */
  42492. setGlobalVolume(newVolume: number): void;
  42493. /**
  42494. * Connect the audio engine to an audio analyser allowing some amazing
  42495. * synchronization between the sounds/music and your visualization (VuMeter for instance).
  42496. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  42497. * @param analyser The analyser to connect to the engine
  42498. */
  42499. connectToAnalyser(analyser: Analyser): void;
  42500. }
  42501. }
  42502. declare module BABYLON {
  42503. /**
  42504. * Defines the interface used by display changed events
  42505. */
  42506. export interface IDisplayChangedEventArgs {
  42507. /** Gets the vrDisplay object (if any) */
  42508. vrDisplay: Nullable<any>;
  42509. /** Gets a boolean indicating if webVR is supported */
  42510. vrSupported: boolean;
  42511. }
  42512. /**
  42513. * Defines the interface used by objects containing a viewport (like a camera)
  42514. */
  42515. interface IViewportOwnerLike {
  42516. /**
  42517. * Gets or sets the viewport
  42518. */
  42519. viewport: IViewportLike;
  42520. }
  42521. /**
  42522. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  42523. */
  42524. export class Engine extends ThinEngine {
  42525. /** Defines that alpha blending is disabled */
  42526. static readonly ALPHA_DISABLE: number;
  42527. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  42528. static readonly ALPHA_ADD: number;
  42529. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  42530. static readonly ALPHA_COMBINE: number;
  42531. /** Defines that alpha blending to DEST - SRC * DEST */
  42532. static readonly ALPHA_SUBTRACT: number;
  42533. /** Defines that alpha blending to SRC * DEST */
  42534. static readonly ALPHA_MULTIPLY: number;
  42535. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  42536. static readonly ALPHA_MAXIMIZED: number;
  42537. /** Defines that alpha blending to SRC + DEST */
  42538. static readonly ALPHA_ONEONE: number;
  42539. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  42540. static readonly ALPHA_PREMULTIPLIED: number;
  42541. /**
  42542. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  42543. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  42544. */
  42545. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  42546. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  42547. static readonly ALPHA_INTERPOLATE: number;
  42548. /**
  42549. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  42550. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  42551. */
  42552. static readonly ALPHA_SCREENMODE: number;
  42553. /** Defines that the resource is not delayed*/
  42554. static readonly DELAYLOADSTATE_NONE: number;
  42555. /** Defines that the resource was successfully delay loaded */
  42556. static readonly DELAYLOADSTATE_LOADED: number;
  42557. /** Defines that the resource is currently delay loading */
  42558. static readonly DELAYLOADSTATE_LOADING: number;
  42559. /** Defines that the resource is delayed and has not started loading */
  42560. static readonly DELAYLOADSTATE_NOTLOADED: number;
  42561. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  42562. static readonly NEVER: number;
  42563. /** 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 */
  42564. static readonly ALWAYS: number;
  42565. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  42566. static readonly LESS: number;
  42567. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  42568. static readonly EQUAL: number;
  42569. /** 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 */
  42570. static readonly LEQUAL: number;
  42571. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  42572. static readonly GREATER: number;
  42573. /** 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 */
  42574. static readonly GEQUAL: number;
  42575. /** 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 */
  42576. static readonly NOTEQUAL: number;
  42577. /** Passed to stencilOperation to specify that stencil value must be kept */
  42578. static readonly KEEP: number;
  42579. /** Passed to stencilOperation to specify that stencil value must be replaced */
  42580. static readonly REPLACE: number;
  42581. /** Passed to stencilOperation to specify that stencil value must be incremented */
  42582. static readonly INCR: number;
  42583. /** Passed to stencilOperation to specify that stencil value must be decremented */
  42584. static readonly DECR: number;
  42585. /** Passed to stencilOperation to specify that stencil value must be inverted */
  42586. static readonly INVERT: number;
  42587. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  42588. static readonly INCR_WRAP: number;
  42589. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  42590. static readonly DECR_WRAP: number;
  42591. /** Texture is not repeating outside of 0..1 UVs */
  42592. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  42593. /** Texture is repeating outside of 0..1 UVs */
  42594. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  42595. /** Texture is repeating and mirrored */
  42596. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  42597. /** ALPHA */
  42598. static readonly TEXTUREFORMAT_ALPHA: number;
  42599. /** LUMINANCE */
  42600. static readonly TEXTUREFORMAT_LUMINANCE: number;
  42601. /** LUMINANCE_ALPHA */
  42602. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  42603. /** RGB */
  42604. static readonly TEXTUREFORMAT_RGB: number;
  42605. /** RGBA */
  42606. static readonly TEXTUREFORMAT_RGBA: number;
  42607. /** RED */
  42608. static readonly TEXTUREFORMAT_RED: number;
  42609. /** RED (2nd reference) */
  42610. static readonly TEXTUREFORMAT_R: number;
  42611. /** RG */
  42612. static readonly TEXTUREFORMAT_RG: number;
  42613. /** RED_INTEGER */
  42614. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  42615. /** RED_INTEGER (2nd reference) */
  42616. static readonly TEXTUREFORMAT_R_INTEGER: number;
  42617. /** RG_INTEGER */
  42618. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  42619. /** RGB_INTEGER */
  42620. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  42621. /** RGBA_INTEGER */
  42622. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  42623. /** UNSIGNED_BYTE */
  42624. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  42625. /** UNSIGNED_BYTE (2nd reference) */
  42626. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  42627. /** FLOAT */
  42628. static readonly TEXTURETYPE_FLOAT: number;
  42629. /** HALF_FLOAT */
  42630. static readonly TEXTURETYPE_HALF_FLOAT: number;
  42631. /** BYTE */
  42632. static readonly TEXTURETYPE_BYTE: number;
  42633. /** SHORT */
  42634. static readonly TEXTURETYPE_SHORT: number;
  42635. /** UNSIGNED_SHORT */
  42636. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  42637. /** INT */
  42638. static readonly TEXTURETYPE_INT: number;
  42639. /** UNSIGNED_INT */
  42640. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  42641. /** UNSIGNED_SHORT_4_4_4_4 */
  42642. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  42643. /** UNSIGNED_SHORT_5_5_5_1 */
  42644. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  42645. /** UNSIGNED_SHORT_5_6_5 */
  42646. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  42647. /** UNSIGNED_INT_2_10_10_10_REV */
  42648. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  42649. /** UNSIGNED_INT_24_8 */
  42650. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  42651. /** UNSIGNED_INT_10F_11F_11F_REV */
  42652. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  42653. /** UNSIGNED_INT_5_9_9_9_REV */
  42654. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  42655. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  42656. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  42657. /** nearest is mag = nearest and min = nearest and mip = none */
  42658. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  42659. /** Bilinear is mag = linear and min = linear and mip = nearest */
  42660. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  42661. /** Trilinear is mag = linear and min = linear and mip = linear */
  42662. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  42663. /** nearest is mag = nearest and min = nearest and mip = linear */
  42664. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  42665. /** Bilinear is mag = linear and min = linear and mip = nearest */
  42666. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  42667. /** Trilinear is mag = linear and min = linear and mip = linear */
  42668. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  42669. /** mag = nearest and min = nearest and mip = nearest */
  42670. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  42671. /** mag = nearest and min = linear and mip = nearest */
  42672. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  42673. /** mag = nearest and min = linear and mip = linear */
  42674. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  42675. /** mag = nearest and min = linear and mip = none */
  42676. static readonly TEXTURE_NEAREST_LINEAR: number;
  42677. /** mag = nearest and min = nearest and mip = none */
  42678. static readonly TEXTURE_NEAREST_NEAREST: number;
  42679. /** mag = linear and min = nearest and mip = nearest */
  42680. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  42681. /** mag = linear and min = nearest and mip = linear */
  42682. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  42683. /** mag = linear and min = linear and mip = none */
  42684. static readonly TEXTURE_LINEAR_LINEAR: number;
  42685. /** mag = linear and min = nearest and mip = none */
  42686. static readonly TEXTURE_LINEAR_NEAREST: number;
  42687. /** Explicit coordinates mode */
  42688. static readonly TEXTURE_EXPLICIT_MODE: number;
  42689. /** Spherical coordinates mode */
  42690. static readonly TEXTURE_SPHERICAL_MODE: number;
  42691. /** Planar coordinates mode */
  42692. static readonly TEXTURE_PLANAR_MODE: number;
  42693. /** Cubic coordinates mode */
  42694. static readonly TEXTURE_CUBIC_MODE: number;
  42695. /** Projection coordinates mode */
  42696. static readonly TEXTURE_PROJECTION_MODE: number;
  42697. /** Skybox coordinates mode */
  42698. static readonly TEXTURE_SKYBOX_MODE: number;
  42699. /** Inverse Cubic coordinates mode */
  42700. static readonly TEXTURE_INVCUBIC_MODE: number;
  42701. /** Equirectangular coordinates mode */
  42702. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  42703. /** Equirectangular Fixed coordinates mode */
  42704. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  42705. /** Equirectangular Fixed Mirrored coordinates mode */
  42706. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  42707. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  42708. static readonly SCALEMODE_FLOOR: number;
  42709. /** Defines that texture rescaling will look for the nearest power of 2 size */
  42710. static readonly SCALEMODE_NEAREST: number;
  42711. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  42712. static readonly SCALEMODE_CEILING: number;
  42713. /**
  42714. * Returns the current npm package of the sdk
  42715. */
  42716. static get NpmPackage(): string;
  42717. /**
  42718. * Returns the current version of the framework
  42719. */
  42720. static get Version(): string;
  42721. /** Gets the list of created engines */
  42722. static get Instances(): Engine[];
  42723. /**
  42724. * Gets the latest created engine
  42725. */
  42726. static get LastCreatedEngine(): Nullable<Engine>;
  42727. /**
  42728. * Gets the latest created scene
  42729. */
  42730. static get LastCreatedScene(): Nullable<Scene>;
  42731. /**
  42732. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  42733. * @param flag defines which part of the materials must be marked as dirty
  42734. * @param predicate defines a predicate used to filter which materials should be affected
  42735. */
  42736. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  42737. /**
  42738. * Method called to create the default loading screen.
  42739. * This can be overridden in your own app.
  42740. * @param canvas The rendering canvas element
  42741. * @returns The loading screen
  42742. */
  42743. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  42744. /**
  42745. * Method called to create the default rescale post process on each engine.
  42746. */
  42747. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  42748. /**
  42749. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  42750. **/
  42751. enableOfflineSupport: boolean;
  42752. /**
  42753. * 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)
  42754. **/
  42755. disableManifestCheck: boolean;
  42756. /**
  42757. * Gets the list of created scenes
  42758. */
  42759. scenes: Scene[];
  42760. /**
  42761. * Event raised when a new scene is created
  42762. */
  42763. onNewSceneAddedObservable: Observable<Scene>;
  42764. /**
  42765. * Gets the list of created postprocesses
  42766. */
  42767. postProcesses: PostProcess[];
  42768. /**
  42769. * Gets a boolean indicating if the pointer is currently locked
  42770. */
  42771. isPointerLock: boolean;
  42772. /**
  42773. * Observable event triggered each time the rendering canvas is resized
  42774. */
  42775. onResizeObservable: Observable<Engine>;
  42776. /**
  42777. * Observable event triggered each time the canvas loses focus
  42778. */
  42779. onCanvasBlurObservable: Observable<Engine>;
  42780. /**
  42781. * Observable event triggered each time the canvas gains focus
  42782. */
  42783. onCanvasFocusObservable: Observable<Engine>;
  42784. /**
  42785. * Observable event triggered each time the canvas receives pointerout event
  42786. */
  42787. onCanvasPointerOutObservable: Observable<IPointerEvent>;
  42788. /**
  42789. * Observable raised when the engine begins a new frame
  42790. */
  42791. onBeginFrameObservable: Observable<Engine>;
  42792. /**
  42793. * If set, will be used to request the next animation frame for the render loop
  42794. */
  42795. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  42796. /**
  42797. * Observable raised when the engine ends the current frame
  42798. */
  42799. onEndFrameObservable: Observable<Engine>;
  42800. /**
  42801. * Observable raised when the engine is about to compile a shader
  42802. */
  42803. onBeforeShaderCompilationObservable: Observable<Engine>;
  42804. /**
  42805. * Observable raised when the engine has just compiled a shader
  42806. */
  42807. onAfterShaderCompilationObservable: Observable<Engine>;
  42808. /**
  42809. * Gets the audio engine
  42810. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42811. * @ignorenaming
  42812. */
  42813. static audioEngine: IAudioEngine;
  42814. /**
  42815. * Default AudioEngine factory responsible of creating the Audio Engine.
  42816. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  42817. */
  42818. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  42819. /**
  42820. * Default offline support factory responsible of creating a tool used to store data locally.
  42821. * By default, this will create a Database object if the workload has been embedded.
  42822. */
  42823. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  42824. private _loadingScreen;
  42825. private _pointerLockRequested;
  42826. private _rescalePostProcess;
  42827. protected _deterministicLockstep: boolean;
  42828. protected _lockstepMaxSteps: number;
  42829. protected _timeStep: number;
  42830. protected get _supportsHardwareTextureRescaling(): boolean;
  42831. private _fps;
  42832. private _deltaTime;
  42833. /** @hidden */
  42834. _drawCalls: PerfCounter;
  42835. /** 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 */
  42836. canvasTabIndex: number;
  42837. /**
  42838. * Turn this value on if you want to pause FPS computation when in background
  42839. */
  42840. disablePerformanceMonitorInBackground: boolean;
  42841. private _performanceMonitor;
  42842. /**
  42843. * Gets the performance monitor attached to this engine
  42844. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  42845. */
  42846. get performanceMonitor(): PerformanceMonitor;
  42847. private _onFocus;
  42848. private _onBlur;
  42849. private _onCanvasPointerOut;
  42850. private _onCanvasBlur;
  42851. private _onCanvasFocus;
  42852. private _onFullscreenChange;
  42853. private _onPointerLockChange;
  42854. /**
  42855. * Gets the HTML element used to attach event listeners
  42856. * @returns a HTML element
  42857. */
  42858. getInputElement(): Nullable<HTMLElement>;
  42859. /**
  42860. * Creates a new engine
  42861. * @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
  42862. * @param antialias defines enable antialiasing (default: false)
  42863. * @param options defines further options to be sent to the getContext() function
  42864. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  42865. */
  42866. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  42867. /**
  42868. * Shared initialization across engines types.
  42869. * @param canvas The canvas associated with this instance of the engine.
  42870. * @param doNotHandleTouchAction Defines that engine should ignore modifying touch action attribute and style
  42871. * @param audioEngine Defines if an audio engine should be created by default
  42872. */
  42873. protected _sharedInit(canvas: HTMLCanvasElement, doNotHandleTouchAction: boolean, audioEngine: boolean): void;
  42874. /**
  42875. * Gets current aspect ratio
  42876. * @param viewportOwner defines the camera to use to get the aspect ratio
  42877. * @param useScreen defines if screen size must be used (or the current render target if any)
  42878. * @returns a number defining the aspect ratio
  42879. */
  42880. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  42881. /**
  42882. * Gets current screen aspect ratio
  42883. * @returns a number defining the aspect ratio
  42884. */
  42885. getScreenAspectRatio(): number;
  42886. /**
  42887. * Gets the client rect of the HTML canvas attached with the current webGL context
  42888. * @returns a client rectangle
  42889. */
  42890. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  42891. /**
  42892. * Gets the client rect of the HTML element used for events
  42893. * @returns a client rectangle
  42894. */
  42895. getInputElementClientRect(): Nullable<ClientRect>;
  42896. /**
  42897. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  42898. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42899. * @returns true if engine is in deterministic lock step mode
  42900. */
  42901. isDeterministicLockStep(): boolean;
  42902. /**
  42903. * Gets the max steps when engine is running in deterministic lock step
  42904. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42905. * @returns the max steps
  42906. */
  42907. getLockstepMaxSteps(): number;
  42908. /**
  42909. * Returns the time in ms between steps when using deterministic lock step.
  42910. * @returns time step in (ms)
  42911. */
  42912. getTimeStep(): number;
  42913. /**
  42914. * Force the mipmap generation for the given render target texture
  42915. * @param texture defines the render target texture to use
  42916. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  42917. */
  42918. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  42919. /** States */
  42920. /**
  42921. * Set various states to the webGL context
  42922. * @param culling defines backface culling state
  42923. * @param zOffset defines the value to apply to zOffset (0 by default)
  42924. * @param force defines if states must be applied even if cache is up to date
  42925. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  42926. */
  42927. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42928. /**
  42929. * Set the z offset to apply to current rendering
  42930. * @param value defines the offset to apply
  42931. */
  42932. setZOffset(value: number): void;
  42933. /**
  42934. * Gets the current value of the zOffset
  42935. * @returns the current zOffset state
  42936. */
  42937. getZOffset(): number;
  42938. /**
  42939. * Gets a boolean indicating if depth testing is enabled
  42940. * @returns the current state
  42941. */
  42942. getDepthBuffer(): boolean;
  42943. /**
  42944. * Enable or disable depth buffering
  42945. * @param enable defines the state to set
  42946. */
  42947. setDepthBuffer(enable: boolean): void;
  42948. /**
  42949. * Gets a boolean indicating if depth writing is enabled
  42950. * @returns the current depth writing state
  42951. */
  42952. getDepthWrite(): boolean;
  42953. /**
  42954. * Enable or disable depth writing
  42955. * @param enable defines the state to set
  42956. */
  42957. setDepthWrite(enable: boolean): void;
  42958. /**
  42959. * Gets a boolean indicating if stencil buffer is enabled
  42960. * @returns the current stencil buffer state
  42961. */
  42962. getStencilBuffer(): boolean;
  42963. /**
  42964. * Enable or disable the stencil buffer
  42965. * @param enable defines if the stencil buffer must be enabled or disabled
  42966. */
  42967. setStencilBuffer(enable: boolean): void;
  42968. /**
  42969. * Gets the current stencil mask
  42970. * @returns a number defining the new stencil mask to use
  42971. */
  42972. getStencilMask(): number;
  42973. /**
  42974. * Sets the current stencil mask
  42975. * @param mask defines the new stencil mask to use
  42976. */
  42977. setStencilMask(mask: number): void;
  42978. /**
  42979. * Gets the current stencil function
  42980. * @returns a number defining the stencil function to use
  42981. */
  42982. getStencilFunction(): number;
  42983. /**
  42984. * Gets the current stencil reference value
  42985. * @returns a number defining the stencil reference value to use
  42986. */
  42987. getStencilFunctionReference(): number;
  42988. /**
  42989. * Gets the current stencil mask
  42990. * @returns a number defining the stencil mask to use
  42991. */
  42992. getStencilFunctionMask(): number;
  42993. /**
  42994. * Sets the current stencil function
  42995. * @param stencilFunc defines the new stencil function to use
  42996. */
  42997. setStencilFunction(stencilFunc: number): void;
  42998. /**
  42999. * Sets the current stencil reference
  43000. * @param reference defines the new stencil reference to use
  43001. */
  43002. setStencilFunctionReference(reference: number): void;
  43003. /**
  43004. * Sets the current stencil mask
  43005. * @param mask defines the new stencil mask to use
  43006. */
  43007. setStencilFunctionMask(mask: number): void;
  43008. /**
  43009. * Gets the current stencil operation when stencil fails
  43010. * @returns a number defining stencil operation to use when stencil fails
  43011. */
  43012. getStencilOperationFail(): number;
  43013. /**
  43014. * Gets the current stencil operation when depth fails
  43015. * @returns a number defining stencil operation to use when depth fails
  43016. */
  43017. getStencilOperationDepthFail(): number;
  43018. /**
  43019. * Gets the current stencil operation when stencil passes
  43020. * @returns a number defining stencil operation to use when stencil passes
  43021. */
  43022. getStencilOperationPass(): number;
  43023. /**
  43024. * Sets the stencil operation to use when stencil fails
  43025. * @param operation defines the stencil operation to use when stencil fails
  43026. */
  43027. setStencilOperationFail(operation: number): void;
  43028. /**
  43029. * Sets the stencil operation to use when depth fails
  43030. * @param operation defines the stencil operation to use when depth fails
  43031. */
  43032. setStencilOperationDepthFail(operation: number): void;
  43033. /**
  43034. * Sets the stencil operation to use when stencil passes
  43035. * @param operation defines the stencil operation to use when stencil passes
  43036. */
  43037. setStencilOperationPass(operation: number): void;
  43038. /**
  43039. * Sets a boolean indicating if the dithering state is enabled or disabled
  43040. * @param value defines the dithering state
  43041. */
  43042. setDitheringState(value: boolean): void;
  43043. /**
  43044. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  43045. * @param value defines the rasterizer state
  43046. */
  43047. setRasterizerState(value: boolean): void;
  43048. /**
  43049. * Gets the current depth function
  43050. * @returns a number defining the depth function
  43051. */
  43052. getDepthFunction(): Nullable<number>;
  43053. /**
  43054. * Sets the current depth function
  43055. * @param depthFunc defines the function to use
  43056. */
  43057. setDepthFunction(depthFunc: number): void;
  43058. /**
  43059. * Sets the current depth function to GREATER
  43060. */
  43061. setDepthFunctionToGreater(): void;
  43062. /**
  43063. * Sets the current depth function to GEQUAL
  43064. */
  43065. setDepthFunctionToGreaterOrEqual(): void;
  43066. /**
  43067. * Sets the current depth function to LESS
  43068. */
  43069. setDepthFunctionToLess(): void;
  43070. /**
  43071. * Sets the current depth function to LEQUAL
  43072. */
  43073. setDepthFunctionToLessOrEqual(): void;
  43074. private _cachedStencilBuffer;
  43075. private _cachedStencilFunction;
  43076. private _cachedStencilMask;
  43077. private _cachedStencilOperationPass;
  43078. private _cachedStencilOperationFail;
  43079. private _cachedStencilOperationDepthFail;
  43080. private _cachedStencilReference;
  43081. /**
  43082. * Caches the the state of the stencil buffer
  43083. */
  43084. cacheStencilState(): void;
  43085. /**
  43086. * Restores the state of the stencil buffer
  43087. */
  43088. restoreStencilState(): void;
  43089. /**
  43090. * Directly set the WebGL Viewport
  43091. * @param x defines the x coordinate of the viewport (in screen space)
  43092. * @param y defines the y coordinate of the viewport (in screen space)
  43093. * @param width defines the width of the viewport (in screen space)
  43094. * @param height defines the height of the viewport (in screen space)
  43095. * @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
  43096. */
  43097. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  43098. /**
  43099. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  43100. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  43101. * @param y defines the y-coordinate of the corner of the clear rectangle
  43102. * @param width defines the width of the clear rectangle
  43103. * @param height defines the height of the clear rectangle
  43104. * @param clearColor defines the clear color
  43105. */
  43106. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  43107. /**
  43108. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  43109. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  43110. * @param y defines the y-coordinate of the corner of the clear rectangle
  43111. * @param width defines the width of the clear rectangle
  43112. * @param height defines the height of the clear rectangle
  43113. */
  43114. enableScissor(x: number, y: number, width: number, height: number): void;
  43115. /**
  43116. * Disable previously set scissor test rectangle
  43117. */
  43118. disableScissor(): void;
  43119. protected _reportDrawCall(): void;
  43120. /**
  43121. * Initializes a webVR display and starts listening to display change events
  43122. * The onVRDisplayChangedObservable will be notified upon these changes
  43123. * @returns The onVRDisplayChangedObservable
  43124. */
  43125. initWebVR(): Observable<IDisplayChangedEventArgs>;
  43126. /** @hidden */
  43127. _prepareVRComponent(): void;
  43128. /** @hidden */
  43129. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  43130. /** @hidden */
  43131. _submitVRFrame(): void;
  43132. /**
  43133. * Call this function to leave webVR mode
  43134. * Will do nothing if webVR is not supported or if there is no webVR device
  43135. * @see https://doc.babylonjs.com/how_to/webvr_camera
  43136. */
  43137. disableVR(): void;
  43138. /**
  43139. * Gets a boolean indicating that the system is in VR mode and is presenting
  43140. * @returns true if VR mode is engaged
  43141. */
  43142. isVRPresenting(): boolean;
  43143. /** @hidden */
  43144. _requestVRFrame(): void;
  43145. /** @hidden */
  43146. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  43147. /**
  43148. * Gets the source code of the vertex shader associated with a specific webGL program
  43149. * @param program defines the program to use
  43150. * @returns a string containing the source code of the vertex shader associated with the program
  43151. */
  43152. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  43153. /**
  43154. * Gets the source code of the fragment shader associated with a specific webGL program
  43155. * @param program defines the program to use
  43156. * @returns a string containing the source code of the fragment shader associated with the program
  43157. */
  43158. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  43159. /**
  43160. * Sets a depth stencil texture from a render target to the according uniform.
  43161. * @param channel The texture channel
  43162. * @param uniform The uniform to set
  43163. * @param texture The render target texture containing the depth stencil texture to apply
  43164. * @param name The texture name
  43165. */
  43166. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>, name?: string): void;
  43167. /**
  43168. * Sets a texture to the webGL context from a postprocess
  43169. * @param channel defines the channel to use
  43170. * @param postProcess defines the source postprocess
  43171. * @param name name of the channel
  43172. */
  43173. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>, name: string): void;
  43174. /**
  43175. * Binds the output of the passed in post process to the texture channel specified
  43176. * @param channel The channel the texture should be bound to
  43177. * @param postProcess The post process which's output should be bound
  43178. * @param name name of the channel
  43179. */
  43180. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>, name: string): void;
  43181. protected _rebuildBuffers(): void;
  43182. /** @hidden */
  43183. _renderFrame(): void;
  43184. _renderLoop(): void;
  43185. /** @hidden */
  43186. _renderViews(): boolean;
  43187. /**
  43188. * Toggle full screen mode
  43189. * @param requestPointerLock defines if a pointer lock should be requested from the user
  43190. */
  43191. switchFullscreen(requestPointerLock: boolean): void;
  43192. /**
  43193. * Enters full screen mode
  43194. * @param requestPointerLock defines if a pointer lock should be requested from the user
  43195. */
  43196. enterFullscreen(requestPointerLock: boolean): void;
  43197. /**
  43198. * Exits full screen mode
  43199. */
  43200. exitFullscreen(): void;
  43201. /**
  43202. * Enters Pointerlock mode
  43203. */
  43204. enterPointerlock(): void;
  43205. /**
  43206. * Exits Pointerlock mode
  43207. */
  43208. exitPointerlock(): void;
  43209. /**
  43210. * Begin a new frame
  43211. */
  43212. beginFrame(): void;
  43213. /**
  43214. * End the current frame
  43215. */
  43216. endFrame(): void;
  43217. /**
  43218. * Resize the view according to the canvas' size
  43219. * @param forceSetSize true to force setting the sizes of the underlying canvas
  43220. */
  43221. resize(forceSetSize?: boolean): void;
  43222. /**
  43223. * Force a specific size of the canvas
  43224. * @param width defines the new canvas' width
  43225. * @param height defines the new canvas' height
  43226. * @param forceSetSize true to force setting the sizes of the underlying canvas
  43227. * @returns true if the size was changed
  43228. */
  43229. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  43230. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  43231. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  43232. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  43233. _releaseTexture(texture: InternalTexture): void;
  43234. /**
  43235. * @hidden
  43236. * Rescales a texture
  43237. * @param source input texture
  43238. * @param destination destination texture
  43239. * @param scene scene to use to render the resize
  43240. * @param internalFormat format to use when resizing
  43241. * @param onComplete callback to be called when resize has completed
  43242. */
  43243. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  43244. /**
  43245. * Gets the current framerate
  43246. * @returns a number representing the framerate
  43247. */
  43248. getFps(): number;
  43249. /**
  43250. * Gets the time spent between current and previous frame
  43251. * @returns a number representing the delta time in ms
  43252. */
  43253. getDeltaTime(): number;
  43254. private _measureFps;
  43255. /** @hidden */
  43256. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  43257. /**
  43258. * Updates the sample count of a render target texture
  43259. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  43260. * @param texture defines the texture to update
  43261. * @param samples defines the sample count to set
  43262. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  43263. */
  43264. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  43265. /**
  43266. * Updates a depth texture Comparison Mode and Function.
  43267. * If the comparison Function is equal to 0, the mode will be set to none.
  43268. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  43269. * @param texture The texture to set the comparison function for
  43270. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  43271. */
  43272. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  43273. /**
  43274. * Creates a webGL buffer to use with instantiation
  43275. * @param capacity defines the size of the buffer
  43276. * @returns the webGL buffer
  43277. */
  43278. createInstancesBuffer(capacity: number): DataBuffer;
  43279. /**
  43280. * Delete a webGL buffer used with instantiation
  43281. * @param buffer defines the webGL buffer to delete
  43282. */
  43283. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  43284. private _clientWaitAsync;
  43285. /** @hidden */
  43286. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Nullable<Promise<ArrayBufferView>>;
  43287. dispose(): void;
  43288. private _disableTouchAction;
  43289. /**
  43290. * Display the loading screen
  43291. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  43292. */
  43293. displayLoadingUI(): void;
  43294. /**
  43295. * Hide the loading screen
  43296. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  43297. */
  43298. hideLoadingUI(): void;
  43299. /**
  43300. * Gets the current loading screen object
  43301. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  43302. */
  43303. get loadingScreen(): ILoadingScreen;
  43304. /**
  43305. * Sets the current loading screen object
  43306. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  43307. */
  43308. set loadingScreen(loadingScreen: ILoadingScreen);
  43309. /**
  43310. * Sets the current loading screen text
  43311. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  43312. */
  43313. set loadingUIText(text: string);
  43314. /**
  43315. * Sets the current loading screen background color
  43316. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  43317. */
  43318. set loadingUIBackgroundColor(color: string);
  43319. /** Pointerlock and fullscreen */
  43320. /**
  43321. * Ask the browser to promote the current element to pointerlock mode
  43322. * @param element defines the DOM element to promote
  43323. */
  43324. static _RequestPointerlock(element: HTMLElement): void;
  43325. /**
  43326. * Asks the browser to exit pointerlock mode
  43327. */
  43328. static _ExitPointerlock(): void;
  43329. /**
  43330. * Ask the browser to promote the current element to fullscreen rendering mode
  43331. * @param element defines the DOM element to promote
  43332. */
  43333. static _RequestFullscreen(element: HTMLElement): void;
  43334. /**
  43335. * Asks the browser to exit fullscreen mode
  43336. */
  43337. static _ExitFullscreen(): void;
  43338. }
  43339. }
  43340. declare module BABYLON {
  43341. /**
  43342. * The engine store class is responsible to hold all the instances of Engine and Scene created
  43343. * during the life time of the application.
  43344. */
  43345. export class EngineStore {
  43346. /** Gets the list of created engines */
  43347. static Instances: Engine[];
  43348. /** @hidden */
  43349. static _LastCreatedScene: Nullable<Scene>;
  43350. /**
  43351. * Gets the latest created engine
  43352. */
  43353. static get LastCreatedEngine(): Nullable<Engine>;
  43354. /**
  43355. * Gets the latest created scene
  43356. */
  43357. static get LastCreatedScene(): Nullable<Scene>;
  43358. /**
  43359. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  43360. * @ignorenaming
  43361. */
  43362. static UseFallbackTexture: boolean;
  43363. /**
  43364. * Texture content used if a texture cannot loaded
  43365. * @ignorenaming
  43366. */
  43367. static FallbackTexture: string;
  43368. }
  43369. }
  43370. declare module BABYLON {
  43371. /**
  43372. * Helper class that provides a small promise polyfill
  43373. */
  43374. export class PromisePolyfill {
  43375. /**
  43376. * Static function used to check if the polyfill is required
  43377. * If this is the case then the function will inject the polyfill to window.Promise
  43378. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  43379. */
  43380. static Apply(force?: boolean): void;
  43381. }
  43382. }
  43383. declare module BABYLON {
  43384. /**
  43385. * Interface for screenshot methods with describe argument called `size` as object with options
  43386. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  43387. */
  43388. export interface IScreenshotSize {
  43389. /**
  43390. * number in pixels for canvas height
  43391. */
  43392. height?: number;
  43393. /**
  43394. * multiplier allowing render at a higher or lower resolution
  43395. * If value is defined then height and width will be ignored and taken from camera
  43396. */
  43397. precision?: number;
  43398. /**
  43399. * number in pixels for canvas width
  43400. */
  43401. width?: number;
  43402. }
  43403. }
  43404. declare module BABYLON {
  43405. interface IColor4Like {
  43406. r: float;
  43407. g: float;
  43408. b: float;
  43409. a: float;
  43410. }
  43411. /**
  43412. * Class containing a set of static utilities functions
  43413. */
  43414. export class Tools {
  43415. /**
  43416. * Gets or sets the base URL to use to load assets
  43417. */
  43418. static get BaseUrl(): string;
  43419. static set BaseUrl(value: string);
  43420. /**
  43421. * Enable/Disable Custom HTTP Request Headers globally.
  43422. * default = false
  43423. * @see CustomRequestHeaders
  43424. */
  43425. static UseCustomRequestHeaders: boolean;
  43426. /**
  43427. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  43428. * i.e. when loading files, where the server/service expects an Authorization header
  43429. */
  43430. static CustomRequestHeaders: {
  43431. [key: string]: string;
  43432. };
  43433. /**
  43434. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  43435. */
  43436. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  43437. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  43438. /**
  43439. * Default behaviour for cors in the application.
  43440. * It can be a string if the expected behavior is identical in the entire app.
  43441. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  43442. */
  43443. static get CorsBehavior(): string | ((url: string | string[]) => string);
  43444. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  43445. /**
  43446. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  43447. * @ignorenaming
  43448. */
  43449. static get UseFallbackTexture(): boolean;
  43450. static set UseFallbackTexture(value: boolean);
  43451. /**
  43452. * Use this object to register external classes like custom textures or material
  43453. * to allow the loaders to instantiate them
  43454. */
  43455. static get RegisteredExternalClasses(): {
  43456. [key: string]: Object;
  43457. };
  43458. static set RegisteredExternalClasses(classes: {
  43459. [key: string]: Object;
  43460. });
  43461. /**
  43462. * Texture content used if a texture cannot loaded
  43463. * @ignorenaming
  43464. */
  43465. static get fallbackTexture(): string;
  43466. static set fallbackTexture(value: string);
  43467. /**
  43468. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  43469. * @param u defines the coordinate on X axis
  43470. * @param v defines the coordinate on Y axis
  43471. * @param width defines the width of the source data
  43472. * @param height defines the height of the source data
  43473. * @param pixels defines the source byte array
  43474. * @param color defines the output color
  43475. */
  43476. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  43477. /**
  43478. * Interpolates between a and b via alpha
  43479. * @param a The lower value (returned when alpha = 0)
  43480. * @param b The upper value (returned when alpha = 1)
  43481. * @param alpha The interpolation-factor
  43482. * @return The mixed value
  43483. */
  43484. static Mix(a: number, b: number, alpha: number): number;
  43485. /**
  43486. * Tries to instantiate a new object from a given class name
  43487. * @param className defines the class name to instantiate
  43488. * @returns the new object or null if the system was not able to do the instantiation
  43489. */
  43490. static Instantiate(className: string): any;
  43491. /**
  43492. * Provides a slice function that will work even on IE
  43493. * @param data defines the array to slice
  43494. * @param start defines the start of the data (optional)
  43495. * @param end defines the end of the data (optional)
  43496. * @returns the new sliced array
  43497. */
  43498. static Slice<T>(data: T, start?: number, end?: number): T;
  43499. /**
  43500. * Provides a slice function that will work even on IE
  43501. * The difference between this and Slice is that this will force-convert to array
  43502. * @param data defines the array to slice
  43503. * @param start defines the start of the data (optional)
  43504. * @param end defines the end of the data (optional)
  43505. * @returns the new sliced array
  43506. */
  43507. static SliceToArray<T, P>(data: T, start?: number, end?: number): Array<P>;
  43508. /**
  43509. * Polyfill for setImmediate
  43510. * @param action defines the action to execute after the current execution block
  43511. */
  43512. static SetImmediate(action: () => void): void;
  43513. /**
  43514. * Function indicating if a number is an exponent of 2
  43515. * @param value defines the value to test
  43516. * @returns true if the value is an exponent of 2
  43517. */
  43518. static IsExponentOfTwo(value: number): boolean;
  43519. private static _tmpFloatArray;
  43520. /**
  43521. * Returns the nearest 32-bit single precision float representation of a Number
  43522. * @param value A Number. If the parameter is of a different type, it will get converted
  43523. * to a number or to NaN if it cannot be converted
  43524. * @returns number
  43525. */
  43526. static FloatRound(value: number): number;
  43527. /**
  43528. * Extracts the filename from a path
  43529. * @param path defines the path to use
  43530. * @returns the filename
  43531. */
  43532. static GetFilename(path: string): string;
  43533. /**
  43534. * Extracts the "folder" part of a path (everything before the filename).
  43535. * @param uri The URI to extract the info from
  43536. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  43537. * @returns The "folder" part of the path
  43538. */
  43539. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  43540. /**
  43541. * Extracts text content from a DOM element hierarchy
  43542. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  43543. */
  43544. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  43545. /**
  43546. * Convert an angle in radians to degrees
  43547. * @param angle defines the angle to convert
  43548. * @returns the angle in degrees
  43549. */
  43550. static ToDegrees(angle: number): number;
  43551. /**
  43552. * Convert an angle in degrees to radians
  43553. * @param angle defines the angle to convert
  43554. * @returns the angle in radians
  43555. */
  43556. static ToRadians(angle: number): number;
  43557. /**
  43558. * Returns an array if obj is not an array
  43559. * @param obj defines the object to evaluate as an array
  43560. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  43561. * @returns either obj directly if obj is an array or a new array containing obj
  43562. */
  43563. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  43564. /**
  43565. * Gets the pointer prefix to use
  43566. * @param engine defines the engine we are finding the prefix for
  43567. * @returns "pointer" if touch is enabled. Else returns "mouse"
  43568. */
  43569. static GetPointerPrefix(engine: Engine): string;
  43570. /**
  43571. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  43572. * @param url define the url we are trying
  43573. * @param element define the dom element where to configure the cors policy
  43574. */
  43575. static SetCorsBehavior(url: string | string[], element: {
  43576. crossOrigin: string | null;
  43577. }): void;
  43578. /**
  43579. * Removes unwanted characters from an url
  43580. * @param url defines the url to clean
  43581. * @returns the cleaned url
  43582. */
  43583. static CleanUrl(url: string): string;
  43584. /**
  43585. * Gets or sets a function used to pre-process url before using them to load assets
  43586. */
  43587. static get PreprocessUrl(): (url: string) => string;
  43588. static set PreprocessUrl(processor: (url: string) => string);
  43589. /**
  43590. * Loads an image as an HTMLImageElement.
  43591. * @param input url string, ArrayBuffer, or Blob to load
  43592. * @param onLoad callback called when the image successfully loads
  43593. * @param onError callback called when the image fails to load
  43594. * @param offlineProvider offline provider for caching
  43595. * @param mimeType optional mime type
  43596. * @returns the HTMLImageElement of the loaded image
  43597. */
  43598. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  43599. /**
  43600. * Loads a file from a url
  43601. * @param url url string, ArrayBuffer, or Blob to load
  43602. * @param onSuccess callback called when the file successfully loads
  43603. * @param onProgress callback called while file is loading (if the server supports this mode)
  43604. * @param offlineProvider defines the offline provider for caching
  43605. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43606. * @param onError callback called when the file fails to load
  43607. * @returns a file request object
  43608. */
  43609. 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;
  43610. /**
  43611. * Loads a file from a url
  43612. * @param url the file url to load
  43613. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43614. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  43615. */
  43616. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  43617. /**
  43618. * Load a script (identified by an url). When the url returns, the
  43619. * content of this file is added into a new script element, attached to the DOM (body element)
  43620. * @param scriptUrl defines the url of the script to laod
  43621. * @param onSuccess defines the callback called when the script is loaded
  43622. * @param onError defines the callback to call if an error occurs
  43623. * @param scriptId defines the id of the script element
  43624. */
  43625. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  43626. /**
  43627. * Load an asynchronous script (identified by an url). When the url returns, the
  43628. * content of this file is added into a new script element, attached to the DOM (body element)
  43629. * @param scriptUrl defines the url of the script to laod
  43630. * @param scriptId defines the id of the script element
  43631. * @returns a promise request object
  43632. */
  43633. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  43634. /**
  43635. * Loads a file from a blob
  43636. * @param fileToLoad defines the blob to use
  43637. * @param callback defines the callback to call when data is loaded
  43638. * @param progressCallback defines the callback to call during loading process
  43639. * @returns a file request object
  43640. */
  43641. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  43642. /**
  43643. * Reads a file from a File object
  43644. * @param file defines the file to load
  43645. * @param onSuccess defines the callback to call when data is loaded
  43646. * @param onProgress defines the callback to call during loading process
  43647. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43648. * @param onError defines the callback to call when an error occurs
  43649. * @returns a file request object
  43650. */
  43651. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  43652. /**
  43653. * Creates a data url from a given string content
  43654. * @param content defines the content to convert
  43655. * @returns the new data url link
  43656. */
  43657. static FileAsURL(content: string): string;
  43658. /**
  43659. * Format the given number to a specific decimal format
  43660. * @param value defines the number to format
  43661. * @param decimals defines the number of decimals to use
  43662. * @returns the formatted string
  43663. */
  43664. static Format(value: number, decimals?: number): string;
  43665. /**
  43666. * Tries to copy an object by duplicating every property
  43667. * @param source defines the source object
  43668. * @param destination defines the target object
  43669. * @param doNotCopyList defines a list of properties to avoid
  43670. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  43671. */
  43672. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  43673. /**
  43674. * Gets a boolean indicating if the given object has no own property
  43675. * @param obj defines the object to test
  43676. * @returns true if object has no own property
  43677. */
  43678. static IsEmpty(obj: any): boolean;
  43679. /**
  43680. * Function used to register events at window level
  43681. * @param windowElement defines the Window object to use
  43682. * @param events defines the events to register
  43683. */
  43684. static RegisterTopRootEvents(windowElement: Window, events: {
  43685. name: string;
  43686. handler: Nullable<(e: FocusEvent) => any>;
  43687. }[]): void;
  43688. /**
  43689. * Function used to unregister events from window level
  43690. * @param windowElement defines the Window object to use
  43691. * @param events defines the events to unregister
  43692. */
  43693. static UnregisterTopRootEvents(windowElement: Window, events: {
  43694. name: string;
  43695. handler: Nullable<(e: FocusEvent) => any>;
  43696. }[]): void;
  43697. /**
  43698. * @ignore
  43699. */
  43700. static _ScreenshotCanvas: HTMLCanvasElement;
  43701. /**
  43702. * Dumps the current bound framebuffer
  43703. * @param width defines the rendering width
  43704. * @param height defines the rendering height
  43705. * @param engine defines the hosting engine
  43706. * @param successCallback defines the callback triggered once the data are available
  43707. * @param mimeType defines the mime type of the result
  43708. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  43709. * @return a void promise
  43710. */
  43711. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): Promise<void>;
  43712. /**
  43713. * Dumps an array buffer
  43714. * @param width defines the rendering width
  43715. * @param height defines the rendering height
  43716. * @param data the data array
  43717. * @param successCallback defines the callback triggered once the data are available
  43718. * @param mimeType defines the mime type of the result
  43719. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  43720. * @param invertY true to invert the picture in the Y dimension
  43721. * @param toArrayBuffer true to convert the data to an ArrayBuffer (encoded as `mimeType`) instead of a base64 string
  43722. */
  43723. static DumpData(width: number, height: number, data: ArrayBufferView, successCallback?: (data: string | ArrayBuffer) => void, mimeType?: string, fileName?: string, invertY?: boolean, toArrayBuffer?: boolean): void;
  43724. /**
  43725. * Dumps an array buffer
  43726. * @param width defines the rendering width
  43727. * @param height defines the rendering height
  43728. * @param data the data array
  43729. * @param successCallback defines the callback triggered once the data are available
  43730. * @param mimeType defines the mime type of the result
  43731. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  43732. * @param invertY true to invert the picture in the Y dimension
  43733. * @param toArrayBuffer true to convert the data to an ArrayBuffer (encoded as `mimeType`) instead of a base64 string
  43734. * @return a promise that resolve to the final data
  43735. */
  43736. static DumpDataAsync(width: number, height: number, data: ArrayBufferView, mimeType?: string, fileName?: string, invertY?: boolean, toArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  43737. /**
  43738. * Converts the canvas data to blob.
  43739. * This acts as a polyfill for browsers not supporting the to blob function.
  43740. * @param canvas Defines the canvas to extract the data from
  43741. * @param successCallback Defines the callback triggered once the data are available
  43742. * @param mimeType Defines the mime type of the result
  43743. */
  43744. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  43745. /**
  43746. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  43747. * @param successCallback defines the callback triggered once the data are available
  43748. * @param mimeType defines the mime type of the result
  43749. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  43750. * @param canvas canvas to get the data from. If not provided, use the default screenshot canvas
  43751. */
  43752. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string, canvas?: HTMLCanvasElement): void;
  43753. /**
  43754. * Downloads a blob in the browser
  43755. * @param blob defines the blob to download
  43756. * @param fileName defines the name of the downloaded file
  43757. */
  43758. static Download(blob: Blob, fileName: string): void;
  43759. /**
  43760. * Will return the right value of the noPreventDefault variable
  43761. * Needed to keep backwards compatibility to the old API.
  43762. *
  43763. * @param args arguments passed to the attachControl function
  43764. * @returns the correct value for noPreventDefault
  43765. */
  43766. static BackCompatCameraNoPreventDefault(args: IArguments): boolean;
  43767. /**
  43768. * Captures a screenshot of the current rendering
  43769. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43770. * @param engine defines the rendering engine
  43771. * @param camera defines the source camera
  43772. * @param size This parameter can be set to a single number or to an object with the
  43773. * following (optional) properties: precision, width, height. If a single number is passed,
  43774. * it will be used for both width and height. If an object is passed, the screenshot size
  43775. * will be derived from the parameters. The precision property is a multiplier allowing
  43776. * rendering at a higher or lower resolution
  43777. * @param successCallback defines the callback receives a single parameter which contains the
  43778. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  43779. * src parameter of an <img> to display it
  43780. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  43781. * Check your browser for supported MIME types
  43782. */
  43783. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  43784. /**
  43785. * Captures a screenshot of the current rendering
  43786. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43787. * @param engine defines the rendering engine
  43788. * @param camera defines the source camera
  43789. * @param size This parameter can be set to a single number or to an object with the
  43790. * following (optional) properties: precision, width, height. If a single number is passed,
  43791. * it will be used for both width and height. If an object is passed, the screenshot size
  43792. * will be derived from the parameters. The precision property is a multiplier allowing
  43793. * rendering at a higher or lower resolution
  43794. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  43795. * Check your browser for supported MIME types
  43796. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  43797. * to the src parameter of an <img> to display it
  43798. */
  43799. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  43800. /**
  43801. * Generates an image screenshot from the specified camera.
  43802. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43803. * @param engine The engine to use for rendering
  43804. * @param camera The camera to use for rendering
  43805. * @param size This parameter can be set to a single number or to an object with the
  43806. * following (optional) properties: precision, width, height. If a single number is passed,
  43807. * it will be used for both width and height. If an object is passed, the screenshot size
  43808. * will be derived from the parameters. The precision property is a multiplier allowing
  43809. * rendering at a higher or lower resolution
  43810. * @param successCallback The callback receives a single parameter which contains the
  43811. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  43812. * src parameter of an <img> to display it
  43813. * @param mimeType The MIME type of the screenshot image (default: image/png).
  43814. * Check your browser for supported MIME types
  43815. * @param samples Texture samples (default: 1)
  43816. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  43817. * @param fileName A name for for the downloaded file.
  43818. */
  43819. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  43820. /**
  43821. * Generates an image screenshot from the specified camera.
  43822. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43823. * @param engine The engine to use for rendering
  43824. * @param camera The camera to use for rendering
  43825. * @param size This parameter can be set to a single number or to an object with the
  43826. * following (optional) properties: precision, width, height. If a single number is passed,
  43827. * it will be used for both width and height. If an object is passed, the screenshot size
  43828. * will be derived from the parameters. The precision property is a multiplier allowing
  43829. * rendering at a higher or lower resolution
  43830. * @param mimeType The MIME type of the screenshot image (default: image/png).
  43831. * Check your browser for supported MIME types
  43832. * @param samples Texture samples (default: 1)
  43833. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  43834. * @param fileName A name for for the downloaded file.
  43835. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  43836. * to the src parameter of an <img> to display it
  43837. */
  43838. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  43839. /**
  43840. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  43841. * Be aware Math.random() could cause collisions, but:
  43842. * "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"
  43843. * @returns a pseudo random id
  43844. */
  43845. static RandomId(): string;
  43846. /**
  43847. * Test if the given uri is a base64 string
  43848. * @param uri The uri to test
  43849. * @return True if the uri is a base64 string or false otherwise
  43850. */
  43851. static IsBase64(uri: string): boolean;
  43852. /**
  43853. * Decode the given base64 uri.
  43854. * @param uri The uri to decode
  43855. * @return The decoded base64 data.
  43856. */
  43857. static DecodeBase64(uri: string): ArrayBuffer;
  43858. /**
  43859. * Gets the absolute url.
  43860. * @param url the input url
  43861. * @return the absolute url
  43862. */
  43863. static GetAbsoluteUrl(url: string): string;
  43864. /**
  43865. * No log
  43866. */
  43867. static readonly NoneLogLevel: number;
  43868. /**
  43869. * Only message logs
  43870. */
  43871. static readonly MessageLogLevel: number;
  43872. /**
  43873. * Only warning logs
  43874. */
  43875. static readonly WarningLogLevel: number;
  43876. /**
  43877. * Only error logs
  43878. */
  43879. static readonly ErrorLogLevel: number;
  43880. /**
  43881. * All logs
  43882. */
  43883. static readonly AllLogLevel: number;
  43884. /**
  43885. * Gets a value indicating the number of loading errors
  43886. * @ignorenaming
  43887. */
  43888. static get errorsCount(): number;
  43889. /**
  43890. * Callback called when a new log is added
  43891. */
  43892. static OnNewCacheEntry: (entry: string) => void;
  43893. /**
  43894. * Log a message to the console
  43895. * @param message defines the message to log
  43896. */
  43897. static Log(message: string): void;
  43898. /**
  43899. * Write a warning message to the console
  43900. * @param message defines the message to log
  43901. */
  43902. static Warn(message: string): void;
  43903. /**
  43904. * Write an error message to the console
  43905. * @param message defines the message to log
  43906. */
  43907. static Error(message: string): void;
  43908. /**
  43909. * Gets current log cache (list of logs)
  43910. */
  43911. static get LogCache(): string;
  43912. /**
  43913. * Clears the log cache
  43914. */
  43915. static ClearLogCache(): void;
  43916. /**
  43917. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  43918. */
  43919. static set LogLevels(level: number);
  43920. /**
  43921. * Checks if the window object exists
  43922. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  43923. */
  43924. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  43925. /**
  43926. * No performance log
  43927. */
  43928. static readonly PerformanceNoneLogLevel: number;
  43929. /**
  43930. * Use user marks to log performance
  43931. */
  43932. static readonly PerformanceUserMarkLogLevel: number;
  43933. /**
  43934. * Log performance to the console
  43935. */
  43936. static readonly PerformanceConsoleLogLevel: number;
  43937. private static _performance;
  43938. /**
  43939. * Sets the current performance log level
  43940. */
  43941. static set PerformanceLogLevel(level: number);
  43942. private static _StartPerformanceCounterDisabled;
  43943. private static _EndPerformanceCounterDisabled;
  43944. private static _StartUserMark;
  43945. private static _EndUserMark;
  43946. private static _StartPerformanceConsole;
  43947. private static _EndPerformanceConsole;
  43948. /**
  43949. * Starts a performance counter
  43950. */
  43951. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  43952. /**
  43953. * Ends a specific performance counter
  43954. */
  43955. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  43956. /**
  43957. * Gets either window.performance.now() if supported or Date.now() else
  43958. */
  43959. static get Now(): number;
  43960. /**
  43961. * This method will return the name of the class used to create the instance of the given object.
  43962. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  43963. * @param object the object to get the class name from
  43964. * @param isType defines if the object is actually a type
  43965. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  43966. */
  43967. static GetClassName(object: any, isType?: boolean): string;
  43968. /**
  43969. * Gets the first element of an array satisfying a given predicate
  43970. * @param array defines the array to browse
  43971. * @param predicate defines the predicate to use
  43972. * @returns null if not found or the element
  43973. */
  43974. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  43975. /**
  43976. * This method will return the name of the full name of the class, including its owning module (if any).
  43977. * 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).
  43978. * @param object the object to get the class name from
  43979. * @param isType defines if the object is actually a type
  43980. * @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.
  43981. * @ignorenaming
  43982. */
  43983. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  43984. /**
  43985. * Returns a promise that resolves after the given amount of time.
  43986. * @param delay Number of milliseconds to delay
  43987. * @returns Promise that resolves after the given amount of time
  43988. */
  43989. static DelayAsync(delay: number): Promise<void>;
  43990. /**
  43991. * Utility function to detect if the current user agent is Safari
  43992. * @returns whether or not the current user agent is safari
  43993. */
  43994. static IsSafari(): boolean;
  43995. }
  43996. /**
  43997. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  43998. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  43999. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  44000. * @param name The name of the class, case should be preserved
  44001. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  44002. */
  44003. export function className(name: string, module?: string): (target: Object) => void;
  44004. /**
  44005. * An implementation of a loop for asynchronous functions.
  44006. */
  44007. export class AsyncLoop {
  44008. /**
  44009. * Defines the number of iterations for the loop
  44010. */
  44011. iterations: number;
  44012. /**
  44013. * Defines the current index of the loop.
  44014. */
  44015. index: number;
  44016. private _done;
  44017. private _fn;
  44018. private _successCallback;
  44019. /**
  44020. * Constructor.
  44021. * @param iterations the number of iterations.
  44022. * @param func the function to run each iteration
  44023. * @param successCallback the callback that will be called upon successful execution
  44024. * @param offset starting offset.
  44025. */
  44026. constructor(
  44027. /**
  44028. * Defines the number of iterations for the loop
  44029. */
  44030. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  44031. /**
  44032. * Execute the next iteration. Must be called after the last iteration was finished.
  44033. */
  44034. executeNext(): void;
  44035. /**
  44036. * Break the loop and run the success callback.
  44037. */
  44038. breakLoop(): void;
  44039. /**
  44040. * Create and run an async loop.
  44041. * @param iterations the number of iterations.
  44042. * @param fn the function to run each iteration
  44043. * @param successCallback the callback that will be called upon successful execution
  44044. * @param offset starting offset.
  44045. * @returns the created async loop object
  44046. */
  44047. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  44048. /**
  44049. * A for-loop that will run a given number of iterations synchronous and the rest async.
  44050. * @param iterations total number of iterations
  44051. * @param syncedIterations number of synchronous iterations in each async iteration.
  44052. * @param fn the function to call each iteration.
  44053. * @param callback a success call back that will be called when iterating stops.
  44054. * @param breakFunction a break condition (optional)
  44055. * @param timeout timeout settings for the setTimeout function. default - 0.
  44056. * @returns the created async loop object
  44057. */
  44058. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  44059. }
  44060. }
  44061. declare module BABYLON {
  44062. /**
  44063. * This class implement a typical dictionary using a string as key and the generic type T as value.
  44064. * The underlying implementation relies on an associative array to ensure the best performances.
  44065. * The value can be anything including 'null' but except 'undefined'
  44066. */
  44067. export class StringDictionary<T> {
  44068. /**
  44069. * This will clear this dictionary and copy the content from the 'source' one.
  44070. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  44071. * @param source the dictionary to take the content from and copy to this dictionary
  44072. */
  44073. copyFrom(source: StringDictionary<T>): void;
  44074. /**
  44075. * Get a value based from its key
  44076. * @param key the given key to get the matching value from
  44077. * @return the value if found, otherwise undefined is returned
  44078. */
  44079. get(key: string): T | undefined;
  44080. /**
  44081. * Get a value from its key or add it if it doesn't exist.
  44082. * This method will ensure you that a given key/data will be present in the dictionary.
  44083. * @param key the given key to get the matching value from
  44084. * @param factory the factory that will create the value if the key is not present in the dictionary.
  44085. * The factory will only be invoked if there's no data for the given key.
  44086. * @return the value corresponding to the key.
  44087. */
  44088. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  44089. /**
  44090. * Get a value from its key if present in the dictionary otherwise add it
  44091. * @param key the key to get the value from
  44092. * @param val if there's no such key/value pair in the dictionary add it with this value
  44093. * @return the value corresponding to the key
  44094. */
  44095. getOrAdd(key: string, val: T): T;
  44096. /**
  44097. * Check if there's a given key in the dictionary
  44098. * @param key the key to check for
  44099. * @return true if the key is present, false otherwise
  44100. */
  44101. contains(key: string): boolean;
  44102. /**
  44103. * Add a new key and its corresponding value
  44104. * @param key the key to add
  44105. * @param value the value corresponding to the key
  44106. * @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
  44107. */
  44108. add(key: string, value: T): boolean;
  44109. /**
  44110. * Update a specific value associated to a key
  44111. * @param key defines the key to use
  44112. * @param value defines the value to store
  44113. * @returns true if the value was updated (or false if the key was not found)
  44114. */
  44115. set(key: string, value: T): boolean;
  44116. /**
  44117. * Get the element of the given key and remove it from the dictionary
  44118. * @param key defines the key to search
  44119. * @returns the value associated with the key or null if not found
  44120. */
  44121. getAndRemove(key: string): Nullable<T>;
  44122. /**
  44123. * Remove a key/value from the dictionary.
  44124. * @param key the key to remove
  44125. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  44126. */
  44127. remove(key: string): boolean;
  44128. /**
  44129. * Clear the whole content of the dictionary
  44130. */
  44131. clear(): void;
  44132. /**
  44133. * Gets the current count
  44134. */
  44135. get count(): number;
  44136. /**
  44137. * Execute a callback on each key/val of the dictionary.
  44138. * Note that you can remove any element in this dictionary in the callback implementation
  44139. * @param callback the callback to execute on a given key/value pair
  44140. */
  44141. forEach(callback: (key: string, val: T) => void): void;
  44142. /**
  44143. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  44144. * If the callback returns null or undefined the method will iterate to the next key/value pair
  44145. * Note that you can remove any element in this dictionary in the callback implementation
  44146. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  44147. * @returns the first item
  44148. */
  44149. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  44150. private _count;
  44151. private _data;
  44152. }
  44153. }
  44154. declare module BABYLON {
  44155. /** @hidden */
  44156. export interface ICollisionCoordinator {
  44157. createCollider(): Collider;
  44158. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  44159. init(scene: Scene): void;
  44160. }
  44161. /** @hidden */
  44162. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  44163. private _scene;
  44164. private _scaledPosition;
  44165. private _scaledVelocity;
  44166. private _finalPosition;
  44167. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  44168. createCollider(): Collider;
  44169. init(scene: Scene): void;
  44170. private _collideWithWorld;
  44171. }
  44172. }
  44173. declare module BABYLON {
  44174. /**
  44175. * Enum for Device Types
  44176. */
  44177. export enum DeviceType {
  44178. /** Generic */
  44179. Generic = 0,
  44180. /** Keyboard */
  44181. Keyboard = 1,
  44182. /** Mouse */
  44183. Mouse = 2,
  44184. /** Touch Pointers */
  44185. Touch = 3,
  44186. /** PS4 Dual Shock */
  44187. DualShock = 4,
  44188. /** Xbox */
  44189. Xbox = 5,
  44190. /** Switch Controller */
  44191. Switch = 6
  44192. }
  44193. /**
  44194. * Enum for All Pointers (Touch/Mouse)
  44195. */
  44196. export enum PointerInput {
  44197. /** Horizontal Axis */
  44198. Horizontal = 0,
  44199. /** Vertical Axis */
  44200. Vertical = 1,
  44201. /** Left Click or Touch */
  44202. LeftClick = 2,
  44203. /** Middle Click */
  44204. MiddleClick = 3,
  44205. /** Right Click */
  44206. RightClick = 4,
  44207. /** Browser Back */
  44208. BrowserBack = 5,
  44209. /** Browser Forward */
  44210. BrowserForward = 6,
  44211. /** Mouse Wheel X */
  44212. MouseWheelX = 7,
  44213. /** Mouse Wheel Y */
  44214. MouseWheelY = 8,
  44215. /** Mouse Wheel Z */
  44216. MouseWheelZ = 9,
  44217. /** Delta X */
  44218. DeltaHorizontal = 10,
  44219. /** Delta Y */
  44220. DeltaVertical = 11
  44221. }
  44222. /**
  44223. * Enum for Dual Shock Gamepad
  44224. */
  44225. export enum DualShockInput {
  44226. /** Cross */
  44227. Cross = 0,
  44228. /** Circle */
  44229. Circle = 1,
  44230. /** Square */
  44231. Square = 2,
  44232. /** Triangle */
  44233. Triangle = 3,
  44234. /** L1 */
  44235. L1 = 4,
  44236. /** R1 */
  44237. R1 = 5,
  44238. /** L2 */
  44239. L2 = 6,
  44240. /** R2 */
  44241. R2 = 7,
  44242. /** Share */
  44243. Share = 8,
  44244. /** Options */
  44245. Options = 9,
  44246. /** L3 */
  44247. L3 = 10,
  44248. /** R3 */
  44249. R3 = 11,
  44250. /** DPadUp */
  44251. DPadUp = 12,
  44252. /** DPadDown */
  44253. DPadDown = 13,
  44254. /** DPadLeft */
  44255. DPadLeft = 14,
  44256. /** DRight */
  44257. DPadRight = 15,
  44258. /** Home */
  44259. Home = 16,
  44260. /** TouchPad */
  44261. TouchPad = 17,
  44262. /** LStickXAxis */
  44263. LStickXAxis = 18,
  44264. /** LStickYAxis */
  44265. LStickYAxis = 19,
  44266. /** RStickXAxis */
  44267. RStickXAxis = 20,
  44268. /** RStickYAxis */
  44269. RStickYAxis = 21
  44270. }
  44271. /**
  44272. * Enum for Xbox Gamepad
  44273. */
  44274. export enum XboxInput {
  44275. /** A */
  44276. A = 0,
  44277. /** B */
  44278. B = 1,
  44279. /** X */
  44280. X = 2,
  44281. /** Y */
  44282. Y = 3,
  44283. /** LB */
  44284. LB = 4,
  44285. /** RB */
  44286. RB = 5,
  44287. /** LT */
  44288. LT = 6,
  44289. /** RT */
  44290. RT = 7,
  44291. /** Back */
  44292. Back = 8,
  44293. /** Start */
  44294. Start = 9,
  44295. /** LS */
  44296. LS = 10,
  44297. /** RS */
  44298. RS = 11,
  44299. /** DPadUp */
  44300. DPadUp = 12,
  44301. /** DPadDown */
  44302. DPadDown = 13,
  44303. /** DPadLeft */
  44304. DPadLeft = 14,
  44305. /** DRight */
  44306. DPadRight = 15,
  44307. /** Home */
  44308. Home = 16,
  44309. /** LStickXAxis */
  44310. LStickXAxis = 17,
  44311. /** LStickYAxis */
  44312. LStickYAxis = 18,
  44313. /** RStickXAxis */
  44314. RStickXAxis = 19,
  44315. /** RStickYAxis */
  44316. RStickYAxis = 20
  44317. }
  44318. /**
  44319. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  44320. */
  44321. export enum SwitchInput {
  44322. /** B */
  44323. B = 0,
  44324. /** A */
  44325. A = 1,
  44326. /** Y */
  44327. Y = 2,
  44328. /** X */
  44329. X = 3,
  44330. /** L */
  44331. L = 4,
  44332. /** R */
  44333. R = 5,
  44334. /** ZL */
  44335. ZL = 6,
  44336. /** ZR */
  44337. ZR = 7,
  44338. /** Minus */
  44339. Minus = 8,
  44340. /** Plus */
  44341. Plus = 9,
  44342. /** LS */
  44343. LS = 10,
  44344. /** RS */
  44345. RS = 11,
  44346. /** DPadUp */
  44347. DPadUp = 12,
  44348. /** DPadDown */
  44349. DPadDown = 13,
  44350. /** DPadLeft */
  44351. DPadLeft = 14,
  44352. /** DRight */
  44353. DPadRight = 15,
  44354. /** Home */
  44355. Home = 16,
  44356. /** Capture */
  44357. Capture = 17,
  44358. /** LStickXAxis */
  44359. LStickXAxis = 18,
  44360. /** LStickYAxis */
  44361. LStickYAxis = 19,
  44362. /** RStickXAxis */
  44363. RStickXAxis = 20,
  44364. /** RStickYAxis */
  44365. RStickYAxis = 21
  44366. }
  44367. }
  44368. declare module BABYLON {
  44369. /**
  44370. * This class will take all inputs from Keyboard, Pointer, and
  44371. * any Gamepads and provide a polling system that all devices
  44372. * will use. This class assumes that there will only be one
  44373. * pointer device and one keyboard.
  44374. */
  44375. export class DeviceInputSystem implements IDisposable {
  44376. /**
  44377. * Returns onDeviceConnected callback property
  44378. * @returns Callback with function to execute when a device is connected
  44379. */
  44380. get onDeviceConnected(): (deviceType: DeviceType, deviceSlot: number) => void;
  44381. /**
  44382. * Sets callback function when a device is connected and executes against all connected devices
  44383. * @param callback Function to execute when a device is connected
  44384. */
  44385. set onDeviceConnected(callback: (deviceType: DeviceType, deviceSlot: number) => void);
  44386. /**
  44387. * Callback to be triggered when a device is disconnected
  44388. */
  44389. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  44390. /**
  44391. * Callback to be triggered when event driven input is updated
  44392. */
  44393. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  44394. private _inputs;
  44395. private _gamepads;
  44396. private _keyboardActive;
  44397. private _pointerActive;
  44398. private _elementToAttachTo;
  44399. private _keyboardDownEvent;
  44400. private _keyboardUpEvent;
  44401. private _pointerMoveEvent;
  44402. private _pointerDownEvent;
  44403. private _pointerUpEvent;
  44404. private _pointerWheelEvent;
  44405. private _wheelEventName;
  44406. private _gamepadConnectedEvent;
  44407. private _gamepadDisconnectedEvent;
  44408. private _onDeviceConnected;
  44409. private static _MAX_KEYCODES;
  44410. private static _MAX_POINTER_INPUTS;
  44411. private _eventPrefix;
  44412. private constructor();
  44413. /**
  44414. * Creates a new DeviceInputSystem instance
  44415. * @param engine Engine to pull input element from
  44416. * @returns The new instance
  44417. */
  44418. static Create(engine: Engine): DeviceInputSystem;
  44419. /**
  44420. * Checks for current device input value, given an id and input index
  44421. * @param deviceName Id of connected device
  44422. * @param inputIndex Index of device input
  44423. * @returns Current value of input
  44424. */
  44425. /**
  44426. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  44427. * @param deviceType Enum specifiying device type
  44428. * @param deviceSlot "Slot" or index that device is referenced in
  44429. * @param inputIndex Id of input to be checked
  44430. * @returns Current value of input
  44431. */
  44432. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  44433. /**
  44434. * Check for a specific device in the DeviceInputSystem
  44435. * @param deviceType Type of device to check for
  44436. * @returns bool with status of device's existence
  44437. */
  44438. isDeviceAvailable(deviceType: DeviceType): boolean;
  44439. /**
  44440. * Dispose of all the eventlisteners
  44441. */
  44442. dispose(): void;
  44443. /**
  44444. * Checks for existing connections to devices and register them, if necessary
  44445. * Currently handles gamepads and mouse
  44446. */
  44447. private _checkForConnectedDevices;
  44448. /**
  44449. * Add a gamepad to the DeviceInputSystem
  44450. * @param gamepad A single DOM Gamepad object
  44451. */
  44452. private _addGamePad;
  44453. /**
  44454. * Add pointer device to DeviceInputSystem
  44455. * @param deviceType Type of Pointer to add
  44456. * @param deviceSlot Pointer ID (0 for mouse, pointerId for Touch)
  44457. * @param currentX Current X at point of adding
  44458. * @param currentY Current Y at point of adding
  44459. */
  44460. private _addPointerDevice;
  44461. /**
  44462. * Add device and inputs to device array
  44463. * @param deviceType Enum specifiying device type
  44464. * @param deviceSlot "Slot" or index that device is referenced in
  44465. * @param numberOfInputs Number of input entries to create for given device
  44466. */
  44467. private _registerDevice;
  44468. /**
  44469. * Given a specific device name, remove that device from the device map
  44470. * @param deviceType Enum specifiying device type
  44471. * @param deviceSlot "Slot" or index that device is referenced in
  44472. */
  44473. private _unregisterDevice;
  44474. /**
  44475. * Handle all actions that come from keyboard interaction
  44476. */
  44477. private _handleKeyActions;
  44478. /**
  44479. * Handle all actions that come from pointer interaction
  44480. */
  44481. private _handlePointerActions;
  44482. /**
  44483. * Handle all actions that come from gamepad interaction
  44484. */
  44485. private _handleGamepadActions;
  44486. /**
  44487. * Update all non-event based devices with each frame
  44488. * @param deviceType Enum specifiying device type
  44489. * @param deviceSlot "Slot" or index that device is referenced in
  44490. * @param inputIndex Id of input to be checked
  44491. */
  44492. private _updateDevice;
  44493. /**
  44494. * Gets DeviceType from the device name
  44495. * @param deviceName Name of Device from DeviceInputSystem
  44496. * @returns DeviceType enum value
  44497. */
  44498. private _getGamepadDeviceType;
  44499. }
  44500. }
  44501. declare module BABYLON {
  44502. /**
  44503. * Class used to manage all inputs for the scene.
  44504. */
  44505. export class InputManager {
  44506. /** The distance in pixel that you have to move to prevent some events */
  44507. static DragMovementThreshold: number;
  44508. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  44509. static LongPressDelay: number;
  44510. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  44511. static DoubleClickDelay: number;
  44512. /** If you need to check double click without raising a single click at first click, enable this flag */
  44513. static ExclusiveDoubleClickMode: boolean;
  44514. /** 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. */
  44515. private _alreadyAttached;
  44516. private _alreadyAttachedTo;
  44517. private _onPointerMove;
  44518. private _onPointerDown;
  44519. private _onPointerUp;
  44520. private _initClickEvent;
  44521. private _initActionManager;
  44522. private _delayedSimpleClick;
  44523. private _delayedSimpleClickTimeout;
  44524. private _previousDelayedSimpleClickTimeout;
  44525. private _meshPickProceed;
  44526. private _previousButtonPressed;
  44527. private _currentPickResult;
  44528. private _previousPickResult;
  44529. private _totalPointersPressed;
  44530. private _doubleClickOccured;
  44531. private _pointerOverMesh;
  44532. private _pickedDownMesh;
  44533. private _pickedUpMesh;
  44534. private _pointerX;
  44535. private _pointerY;
  44536. private _unTranslatedPointerX;
  44537. private _unTranslatedPointerY;
  44538. private _startingPointerPosition;
  44539. private _previousStartingPointerPosition;
  44540. private _startingPointerTime;
  44541. private _previousStartingPointerTime;
  44542. private _pointerCaptures;
  44543. private _meshUnderPointerId;
  44544. private _onKeyDown;
  44545. private _onKeyUp;
  44546. private _scene;
  44547. private _deviceInputSystem;
  44548. /**
  44549. * Creates a new InputManager
  44550. * @param scene defines the hosting scene
  44551. */
  44552. constructor(scene: Scene);
  44553. /**
  44554. * Gets the mesh that is currently under the pointer
  44555. */
  44556. get meshUnderPointer(): Nullable<AbstractMesh>;
  44557. /**
  44558. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  44559. * @param pointerId the pointer id to use
  44560. * @returns The mesh under this pointer id or null if not found
  44561. */
  44562. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  44563. /**
  44564. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  44565. */
  44566. get unTranslatedPointer(): Vector2;
  44567. /**
  44568. * Gets or sets the current on-screen X position of the pointer
  44569. */
  44570. get pointerX(): number;
  44571. set pointerX(value: number);
  44572. /**
  44573. * Gets or sets the current on-screen Y position of the pointer
  44574. */
  44575. get pointerY(): number;
  44576. set pointerY(value: number);
  44577. private _updatePointerPosition;
  44578. private _processPointerMove;
  44579. private _setRayOnPointerInfo;
  44580. private _checkPrePointerObservable;
  44581. /**
  44582. * Use this method to simulate a pointer move on a mesh
  44583. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  44584. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  44585. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  44586. */
  44587. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  44588. /**
  44589. * Use this method to simulate a pointer down on a mesh
  44590. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  44591. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  44592. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  44593. */
  44594. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  44595. private _processPointerDown;
  44596. /** @hidden */
  44597. _isPointerSwiping(): boolean;
  44598. /**
  44599. * Use this method to simulate a pointer up on a mesh
  44600. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  44601. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  44602. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  44603. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  44604. */
  44605. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  44606. private _processPointerUp;
  44607. /**
  44608. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  44609. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  44610. * @returns true if the pointer was captured
  44611. */
  44612. isPointerCaptured(pointerId?: number): boolean;
  44613. /**
  44614. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  44615. * @param attachUp defines if you want to attach events to pointerup
  44616. * @param attachDown defines if you want to attach events to pointerdown
  44617. * @param attachMove defines if you want to attach events to pointermove
  44618. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  44619. */
  44620. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  44621. /**
  44622. * Detaches all event handlers
  44623. */
  44624. detachControl(): void;
  44625. /**
  44626. * Force the value of meshUnderPointer
  44627. * @param mesh defines the mesh to use
  44628. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  44629. */
  44630. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  44631. /**
  44632. * Gets the mesh under the pointer
  44633. * @returns a Mesh or null if no mesh is under the pointer
  44634. */
  44635. getPointerOverMesh(): Nullable<AbstractMesh>;
  44636. }
  44637. }
  44638. declare module BABYLON {
  44639. /**
  44640. * This class defines the direct association between an animation and a target
  44641. */
  44642. export class TargetedAnimation {
  44643. /**
  44644. * Animation to perform
  44645. */
  44646. animation: Animation;
  44647. /**
  44648. * Target to animate
  44649. */
  44650. target: any;
  44651. /**
  44652. * Returns the string "TargetedAnimation"
  44653. * @returns "TargetedAnimation"
  44654. */
  44655. getClassName(): string;
  44656. /**
  44657. * Serialize the object
  44658. * @returns the JSON object representing the current entity
  44659. */
  44660. serialize(): any;
  44661. }
  44662. /**
  44663. * Use this class to create coordinated animations on multiple targets
  44664. */
  44665. export class AnimationGroup implements IDisposable {
  44666. /** The name of the animation group */
  44667. name: string;
  44668. private _scene;
  44669. private _targetedAnimations;
  44670. private _animatables;
  44671. private _from;
  44672. private _to;
  44673. private _isStarted;
  44674. private _isPaused;
  44675. private _speedRatio;
  44676. private _loopAnimation;
  44677. private _isAdditive;
  44678. /**
  44679. * Gets or sets the unique id of the node
  44680. */
  44681. uniqueId: number;
  44682. /**
  44683. * This observable will notify when one animation have ended
  44684. */
  44685. onAnimationEndObservable: Observable<TargetedAnimation>;
  44686. /**
  44687. * Observer raised when one animation loops
  44688. */
  44689. onAnimationLoopObservable: Observable<TargetedAnimation>;
  44690. /**
  44691. * Observer raised when all animations have looped
  44692. */
  44693. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  44694. /**
  44695. * This observable will notify when all animations have ended.
  44696. */
  44697. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  44698. /**
  44699. * This observable will notify when all animations have paused.
  44700. */
  44701. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  44702. /**
  44703. * This observable will notify when all animations are playing.
  44704. */
  44705. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  44706. /**
  44707. * Gets the first frame
  44708. */
  44709. get from(): number;
  44710. /**
  44711. * Gets the last frame
  44712. */
  44713. get to(): number;
  44714. /**
  44715. * Define if the animations are started
  44716. */
  44717. get isStarted(): boolean;
  44718. /**
  44719. * Gets a value indicating that the current group is playing
  44720. */
  44721. get isPlaying(): boolean;
  44722. /**
  44723. * Gets or sets the speed ratio to use for all animations
  44724. */
  44725. get speedRatio(): number;
  44726. /**
  44727. * Gets or sets the speed ratio to use for all animations
  44728. */
  44729. set speedRatio(value: number);
  44730. /**
  44731. * Gets or sets if all animations should loop or not
  44732. */
  44733. get loopAnimation(): boolean;
  44734. set loopAnimation(value: boolean);
  44735. /**
  44736. * Gets or sets if all animations should be evaluated additively
  44737. */
  44738. get isAdditive(): boolean;
  44739. set isAdditive(value: boolean);
  44740. /**
  44741. * Gets the targeted animations for this animation group
  44742. */
  44743. get targetedAnimations(): Array<TargetedAnimation>;
  44744. /**
  44745. * returning the list of animatables controlled by this animation group.
  44746. */
  44747. get animatables(): Array<Animatable>;
  44748. /**
  44749. * Gets the list of target animations
  44750. */
  44751. get children(): TargetedAnimation[];
  44752. /**
  44753. * Instantiates a new Animation Group.
  44754. * This helps managing several animations at once.
  44755. * @see https://doc.babylonjs.com/how_to/group
  44756. * @param name Defines the name of the group
  44757. * @param scene Defines the scene the group belongs to
  44758. */
  44759. constructor(
  44760. /** The name of the animation group */
  44761. name: string, scene?: Nullable<Scene>);
  44762. /**
  44763. * Add an animation (with its target) in the group
  44764. * @param animation defines the animation we want to add
  44765. * @param target defines the target of the animation
  44766. * @returns the TargetedAnimation object
  44767. */
  44768. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  44769. /**
  44770. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  44771. * It can add constant keys at begin or end
  44772. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  44773. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  44774. * @returns the animation group
  44775. */
  44776. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  44777. private _animationLoopCount;
  44778. private _animationLoopFlags;
  44779. private _processLoop;
  44780. /**
  44781. * Start all animations on given targets
  44782. * @param loop defines if animations must loop
  44783. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  44784. * @param from defines the from key (optional)
  44785. * @param to defines the to key (optional)
  44786. * @param isAdditive defines the additive state for the resulting animatables (optional)
  44787. * @returns the current animation group
  44788. */
  44789. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  44790. /**
  44791. * Pause all animations
  44792. * @returns the animation group
  44793. */
  44794. pause(): AnimationGroup;
  44795. /**
  44796. * Play all animations to initial state
  44797. * This function will start() the animations if they were not started or will restart() them if they were paused
  44798. * @param loop defines if animations must loop
  44799. * @returns the animation group
  44800. */
  44801. play(loop?: boolean): AnimationGroup;
  44802. /**
  44803. * Reset all animations to initial state
  44804. * @returns the animation group
  44805. */
  44806. reset(): AnimationGroup;
  44807. /**
  44808. * Restart animations from key 0
  44809. * @returns the animation group
  44810. */
  44811. restart(): AnimationGroup;
  44812. /**
  44813. * Stop all animations
  44814. * @returns the animation group
  44815. */
  44816. stop(): AnimationGroup;
  44817. /**
  44818. * Set animation weight for all animatables
  44819. * @param weight defines the weight to use
  44820. * @return the animationGroup
  44821. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  44822. */
  44823. setWeightForAllAnimatables(weight: number): AnimationGroup;
  44824. /**
  44825. * Synchronize and normalize all animatables with a source animatable
  44826. * @param root defines the root animatable to synchronize with
  44827. * @return the animationGroup
  44828. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  44829. */
  44830. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  44831. /**
  44832. * Goes to a specific frame in this animation group
  44833. * @param frame the frame number to go to
  44834. * @return the animationGroup
  44835. */
  44836. goToFrame(frame: number): AnimationGroup;
  44837. /**
  44838. * Dispose all associated resources
  44839. */
  44840. dispose(): void;
  44841. private _checkAnimationGroupEnded;
  44842. /**
  44843. * Clone the current animation group and returns a copy
  44844. * @param newName defines the name of the new group
  44845. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  44846. * @returns the new animation group
  44847. */
  44848. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  44849. /**
  44850. * Serializes the animationGroup to an object
  44851. * @returns Serialized object
  44852. */
  44853. serialize(): any;
  44854. /**
  44855. * Returns a new AnimationGroup object parsed from the source provided.
  44856. * @param parsedAnimationGroup defines the source
  44857. * @param scene defines the scene that will receive the animationGroup
  44858. * @returns a new AnimationGroup
  44859. */
  44860. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  44861. /**
  44862. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  44863. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  44864. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  44865. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  44866. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  44867. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  44868. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  44869. */
  44870. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  44871. /**
  44872. * Returns the string "AnimationGroup"
  44873. * @returns "AnimationGroup"
  44874. */
  44875. getClassName(): string;
  44876. /**
  44877. * Creates a detailed string about the object
  44878. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  44879. * @returns a string representing the object
  44880. */
  44881. toString(fullDetails?: boolean): string;
  44882. }
  44883. }
  44884. declare module BABYLON {
  44885. /**
  44886. * @hidden
  44887. **/
  44888. export class _TimeToken {
  44889. _startTimeQuery: Nullable<WebGLQuery>;
  44890. _endTimeQuery: Nullable<WebGLQuery>;
  44891. _timeElapsedQuery: Nullable<WebGLQuery>;
  44892. _timeElapsedQueryEnded: boolean;
  44893. }
  44894. }
  44895. declare module BABYLON {
  44896. /** @hidden */
  44897. export enum ExtensionName {
  44898. DepthClamping = "depth-clamping",
  44899. Depth24UnormStencil8 = "depth24unorm-stencil8",
  44900. Depth32FloatStencil8 = "depth32float-stencil8",
  44901. PipelineStatisticsQuery = "pipeline-statistics-query",
  44902. TextureCompressionBC = "texture-compression-bc",
  44903. TimestampQuery = "timestamp-query"
  44904. }
  44905. /** @hidden */
  44906. export enum AddressMode {
  44907. ClampToEdge = "clamp-to-edge",
  44908. Repeat = "repeat",
  44909. MirrorRepeat = "mirror-repeat"
  44910. }
  44911. /** @hidden */
  44912. export enum BindingType {
  44913. UniformBuffer = "uniform-buffer",
  44914. StorageBuffer = "storage-buffer",
  44915. ReadonlyStorageBuffer = "readonly-storage-buffer",
  44916. Sampler = "sampler",
  44917. ComparisonSampler = "comparison-sampler",
  44918. SampledTexture = "sampled-texture",
  44919. ReadonlyStorageTexture = "readonly-storage-texture",
  44920. WriteonlyStorageTexture = "writeonly-storage-texture"
  44921. }
  44922. /** @hidden */
  44923. export enum BlendFactor {
  44924. Zero = "zero",
  44925. One = "one",
  44926. SrcColor = "src-color",
  44927. OneMinusSrcColor = "one-minus-src-color",
  44928. SrcAlpha = "src-alpha",
  44929. OneMinusSrcAlpha = "one-minus-src-alpha",
  44930. DstColor = "dst-color",
  44931. OneMinusDstColor = "one-minus-dst-color",
  44932. DstAlpha = "dst-alpha",
  44933. OneMinusDstAlpha = "one-minus-dst-alpha",
  44934. SrcAlphaSaturated = "src-alpha-saturated",
  44935. BlendColor = "blend-color",
  44936. OneMinusBlendColor = "one-minus-blend-color"
  44937. }
  44938. /** @hidden */
  44939. export enum BlendOperation {
  44940. Add = "add",
  44941. Subtract = "subtract",
  44942. ReverseSubtract = "reverse-subtract",
  44943. Min = "min",
  44944. Max = "max"
  44945. }
  44946. /** @hidden */
  44947. export enum CompareFunction {
  44948. Never = "never",
  44949. Less = "less",
  44950. Equal = "equal",
  44951. LessEqual = "less-equal",
  44952. Greater = "greater",
  44953. NotEqual = "not-equal",
  44954. GreaterEqual = "greater-equal",
  44955. Always = "always"
  44956. }
  44957. /** @hidden */
  44958. export enum CullMode {
  44959. None = "none",
  44960. Front = "front",
  44961. Back = "back"
  44962. }
  44963. /** @hidden */
  44964. export enum FilterMode {
  44965. Nearest = "nearest",
  44966. Linear = "linear"
  44967. }
  44968. /** @hidden */
  44969. export enum FrontFace {
  44970. CCW = "ccw",
  44971. CW = "cw"
  44972. }
  44973. /** @hidden */
  44974. export enum IndexFormat {
  44975. Uint16 = "uint16",
  44976. Uint32 = "uint32"
  44977. }
  44978. /** @hidden */
  44979. export enum InputStepMode {
  44980. Vertex = "vertex",
  44981. Instance = "instance"
  44982. }
  44983. /** @hidden */
  44984. export enum LoadOp {
  44985. Load = "load"
  44986. }
  44987. /** @hidden */
  44988. export enum PrimitiveTopology {
  44989. PointList = "point-list",
  44990. LineList = "line-list",
  44991. LineStrip = "line-strip",
  44992. TriangleList = "triangle-list",
  44993. TriangleStrip = "triangle-strip"
  44994. }
  44995. /** @hidden */
  44996. export enum StencilOperation {
  44997. Keep = "keep",
  44998. Zero = "zero",
  44999. Replace = "replace",
  45000. Invert = "invert",
  45001. IncrementClamp = "increment-clamp",
  45002. DecrementClamp = "decrement-clamp",
  45003. IncrementWrap = "increment-wrap",
  45004. DecrementWrap = "decrement-wrap"
  45005. }
  45006. /** @hidden */
  45007. export enum StoreOp {
  45008. Store = "store",
  45009. Clear = "clear"
  45010. }
  45011. /** @hidden */
  45012. export enum TextureDimension {
  45013. E1d = "1d",
  45014. E2d = "2d",
  45015. E3d = "3d"
  45016. }
  45017. /** @hidden */
  45018. export enum TextureFormat {
  45019. R8Unorm = "r8unorm",
  45020. R8Snorm = "r8snorm",
  45021. R8Uint = "r8uint",
  45022. R8Sint = "r8sint",
  45023. R16Uint = "r16uint",
  45024. R16Sint = "r16sint",
  45025. R16Float = "r16float",
  45026. RG8Unorm = "rg8unorm",
  45027. RG8Snorm = "rg8snorm",
  45028. RG8Uint = "rg8uint",
  45029. RG8Sint = "rg8sint",
  45030. R32Uint = "r32uint",
  45031. R32Sint = "r32sint",
  45032. R32Float = "r32float",
  45033. RG16Uint = "rg16uint",
  45034. RG16Sint = "rg16sint",
  45035. RG16Float = "rg16float",
  45036. RGBA8Unorm = "rgba8unorm",
  45037. RGBA8UnormSRGB = "rgba8unorm-srgb",
  45038. RGBA8Snorm = "rgba8snorm",
  45039. RGBA8Uint = "rgba8uint",
  45040. RGBA8Sint = "rgba8sint",
  45041. BGRA8Unorm = "bgra8unorm",
  45042. BGRA8UnormSRGB = "bgra8unorm-srgb",
  45043. RGB9E5UFloat = "rgb9e5ufloat",
  45044. RGB10A2Unorm = "rgb10a2unorm",
  45045. RG11B10UFloat = "rg11b10ufloat",
  45046. RG32Uint = "rg32uint",
  45047. RG32Sint = "rg32sint",
  45048. RG32Float = "rg32float",
  45049. RGBA16Uint = "rgba16uint",
  45050. RGBA16Sint = "rgba16sint",
  45051. RGBA16Float = "rgba16float",
  45052. RGBA32Uint = "rgba32uint",
  45053. RGBA32Sint = "rgba32sint",
  45054. RGBA32Float = "rgba32float",
  45055. Stencil8 = "stencil8",
  45056. Depth16Unorm = "depth16unorm",
  45057. Depth24Plus = "depth24plus",
  45058. Depth24PlusStencil8 = "depth24plus-stencil8",
  45059. Depth32Float = "depth32float",
  45060. BC1RGBAUNorm = "bc1-rgba-unorm",
  45061. BC1RGBAUnormSRGB = "bc1-rgba-unorm-srgb",
  45062. BC2RGBAUnorm = "bc2-rgba-unorm",
  45063. BC2RGBAUnormSRGB = "bc2-rgba-unorm-srgb",
  45064. BC3RGBAUnorm = "bc3-rgba-unorm",
  45065. BC3RGBAUnormSRGB = "bc3-rgba-unorm-srgb",
  45066. BC4RUnorm = "bc4-r-unorm",
  45067. BC4RSnorm = "bc4-r-snorm",
  45068. BC5RGUnorm = "bc5-rg-unorm",
  45069. BC5RGSnorm = "bc5-rg-snorm",
  45070. BC6HRGBUFloat = "bc6h-rgb-ufloat",
  45071. BC6HRGBFloat = "bc6h-rgb-float",
  45072. BC7RGBAUnorm = "bc7-rgba-unorm",
  45073. BC7RGBAUnormSRGB = "bc7-rgba-unorm-srgb",
  45074. Depth24UnormStencil8 = "depth24unorm-stencil8",
  45075. Depth32FloatStencil8 = "depth32float-stencil8"
  45076. }
  45077. /** @hidden */
  45078. export enum TextureComponentType {
  45079. Float = "float",
  45080. Sint = "sint",
  45081. Uint = "uint",
  45082. DepthComparison = "depth-comparison"
  45083. }
  45084. /** @hidden */
  45085. export enum TextureViewDimension {
  45086. E1d = "1d",
  45087. E2d = "2d",
  45088. E2dArray = "2d-array",
  45089. Cube = "cube",
  45090. CubeArray = "cube-array",
  45091. E3d = "3d"
  45092. }
  45093. /** @hidden */
  45094. export enum VertexFormat {
  45095. Uchar2 = "uchar2",
  45096. Uchar4 = "uchar4",
  45097. Char2 = "char2",
  45098. Char4 = "char4",
  45099. Uchar2Norm = "uchar2norm",
  45100. Uchar4Norm = "uchar4norm",
  45101. Char2Norm = "char2norm",
  45102. Char4Norm = "char4norm",
  45103. Ushort2 = "ushort2",
  45104. Ushort4 = "ushort4",
  45105. Short2 = "short2",
  45106. Short4 = "short4",
  45107. Ushort2Norm = "ushort2norm",
  45108. Ushort4Norm = "ushort4norm",
  45109. Short2Norm = "short2norm",
  45110. Short4Norm = "short4norm",
  45111. Half2 = "half2",
  45112. Half4 = "half4",
  45113. Float = "float",
  45114. Float2 = "float2",
  45115. Float3 = "float3",
  45116. Float4 = "float4",
  45117. Uint = "uint",
  45118. Uint2 = "uint2",
  45119. Uint3 = "uint3",
  45120. Uint4 = "uint4",
  45121. Int = "int",
  45122. Int2 = "int2",
  45123. Int3 = "int3",
  45124. Int4 = "int4"
  45125. }
  45126. /** @hidden */
  45127. export enum TextureAspect {
  45128. All = "all",
  45129. StencilOnly = "stencil-only",
  45130. DepthOnly = "depth-only"
  45131. }
  45132. /** @hidden */
  45133. export enum CompilationMessageType {
  45134. Error = "error",
  45135. Warning = "warning",
  45136. Info = "info"
  45137. }
  45138. /** @hidden */
  45139. export enum QueryType {
  45140. Occlusion = "occlusion"
  45141. }
  45142. /** @hidden */
  45143. export enum BufferUsage {
  45144. MapRead = 1,
  45145. MapWrite = 2,
  45146. CopySrc = 4,
  45147. CopyDst = 8,
  45148. Index = 16,
  45149. Vertex = 32,
  45150. Uniform = 64,
  45151. Storage = 128,
  45152. Indirect = 256,
  45153. QueryResolve = 512
  45154. }
  45155. /** @hidden */
  45156. export enum ColorWrite {
  45157. Red = 1,
  45158. Green = 2,
  45159. Blue = 4,
  45160. Alpha = 8,
  45161. All = 15
  45162. }
  45163. /** @hidden */
  45164. export enum ShaderStage {
  45165. Vertex = 1,
  45166. Fragment = 2,
  45167. Compute = 4
  45168. }
  45169. /** @hidden */
  45170. export enum TextureUsage {
  45171. CopySrc = 1,
  45172. CopyDst = 2,
  45173. Sampled = 4,
  45174. Storage = 8,
  45175. OutputAttachment = 16
  45176. }
  45177. /** @hidden */
  45178. export enum MapMode {
  45179. Read = 1,
  45180. Write = 2
  45181. }
  45182. }
  45183. declare module BABYLON {
  45184. /** @hidden */
  45185. export interface WebGPUBindingInfo {
  45186. setIndex: number;
  45187. bindingIndex: number;
  45188. }
  45189. /** @hidden */
  45190. export interface WebGPUTextureSamplerBindingDescription {
  45191. sampler: WebGPUBindingInfo;
  45192. isTextureArray: boolean;
  45193. textures: Array<WebGPUBindingInfo>;
  45194. }
  45195. /** @hidden
  45196. * If the binding is a UBO, isSampler=isTexture=false
  45197. */
  45198. export interface WebGPUBindingDescription {
  45199. name: string;
  45200. usedInVertex: boolean;
  45201. usedInFragment: boolean;
  45202. isSampler: boolean;
  45203. isComparisonSampler?: boolean;
  45204. isTexture: boolean;
  45205. componentType?: GPUTextureComponentType;
  45206. textureDimension?: GPUTextureViewDimension;
  45207. }
  45208. /**
  45209. * @hidden
  45210. */
  45211. export class WebGPUShaderProcessingContext implements ShaderProcessingContext {
  45212. uboNextBindingIndex: number;
  45213. freeSetIndex: number;
  45214. freeBindingIndex: number;
  45215. availableVaryings: {
  45216. [key: string]: number;
  45217. };
  45218. availableAttributes: {
  45219. [key: string]: number;
  45220. };
  45221. availableUBOs: {
  45222. [key: string]: {
  45223. setIndex: number;
  45224. bindingIndex: number;
  45225. };
  45226. };
  45227. availableSamplers: {
  45228. [key: string]: WebGPUTextureSamplerBindingDescription;
  45229. };
  45230. leftOverUniforms: {
  45231. name: string;
  45232. type: string;
  45233. length: number;
  45234. }[];
  45235. orderedAttributes: string[];
  45236. orderedUBOsAndSamplers: WebGPUBindingDescription[][];
  45237. uniformBufferNames: string[];
  45238. attributeNamesFromEffect: string[];
  45239. attributeLocationsFromEffect: number[];
  45240. private _attributeNextLocation;
  45241. private _varyingNextLocation;
  45242. constructor();
  45243. getAttributeNextLocation(dataType: string, arrayLength?: number): number;
  45244. getVaryingNextLocation(dataType: string, arrayLength?: number): number;
  45245. getNextFreeUBOBinding(): {
  45246. setIndex: number;
  45247. bindingIndex: number;
  45248. };
  45249. private _getNextFreeBinding;
  45250. }
  45251. }
  45252. declare module BABYLON {
  45253. /** @hidden */
  45254. export interface IWebGPUPipelineContextSamplerCache {
  45255. samplerBinding: number;
  45256. firstTextureName: string;
  45257. }
  45258. /** @hidden */
  45259. export interface IWebGPUPipelineContextTextureCache {
  45260. textureBinding: number;
  45261. texture: InternalTexture;
  45262. }
  45263. /** @hidden */
  45264. export interface IWebGPUPipelineContextVertexInputsCache {
  45265. indexBuffer: Nullable<GPUBuffer>;
  45266. indexOffset: number;
  45267. vertexStartSlot: number;
  45268. vertexBuffers: GPUBuffer[];
  45269. vertexOffsets: number[];
  45270. }
  45271. /** @hidden */
  45272. export interface IWebGPURenderPipelineStageDescriptor {
  45273. vertexStage: GPUProgrammableStageDescriptor;
  45274. fragmentStage?: GPUProgrammableStageDescriptor;
  45275. }
  45276. /** @hidden */
  45277. export class WebGPUBindGroupCacheNode {
  45278. values: {
  45279. [id: number]: WebGPUBindGroupCacheNode;
  45280. };
  45281. bindGroups: GPUBindGroup[];
  45282. constructor();
  45283. }
  45284. /** @hidden */
  45285. export class WebGPUPipelineContext implements IPipelineContext {
  45286. engine: WebGPUEngine;
  45287. shaderProcessingContext: WebGPUShaderProcessingContext;
  45288. leftOverUniformsByName: {
  45289. [name: string]: string;
  45290. };
  45291. sources: {
  45292. vertex: string;
  45293. fragment: string;
  45294. rawVertex: string;
  45295. rawFragment: string;
  45296. };
  45297. stages: Nullable<IWebGPURenderPipelineStageDescriptor>;
  45298. samplers: {
  45299. [name: string]: Nullable<IWebGPUPipelineContextSamplerCache>;
  45300. };
  45301. textures: {
  45302. [name: string]: Nullable<IWebGPUPipelineContextTextureCache>;
  45303. };
  45304. bindGroupLayouts: GPUBindGroupLayout[];
  45305. bindGroupsCache: WebGPUBindGroupCacheNode;
  45306. /**
  45307. * Stores the uniform buffer
  45308. */
  45309. uniformBuffer: Nullable<UniformBuffer>;
  45310. onCompiled?: () => void;
  45311. get isAsync(): boolean;
  45312. get isReady(): boolean;
  45313. /** @hidden */
  45314. _name: string;
  45315. constructor(shaderProcessingContext: WebGPUShaderProcessingContext, engine: WebGPUEngine);
  45316. _handlesSpectorRebuildCallback(onCompiled: (program: any) => void): void;
  45317. _fillEffectInformation(effect: Effect, uniformBuffersNames: {
  45318. [key: string]: number;
  45319. }, uniformsNames: string[], uniforms: {
  45320. [key: string]: Nullable<WebGLUniformLocation>;
  45321. }, samplerList: string[], samplers: {
  45322. [key: string]: number;
  45323. }, attributesNames: string[], attributes: number[]): void;
  45324. /** @hidden */
  45325. /**
  45326. * Build the uniform buffer used in the material.
  45327. */
  45328. buildUniformLayout(): void;
  45329. /**
  45330. * Release all associated resources.
  45331. **/
  45332. dispose(): void;
  45333. /**
  45334. * Sets an integer value on a uniform variable.
  45335. * @param uniformName Name of the variable.
  45336. * @param value Value to be set.
  45337. */
  45338. setInt(uniformName: string, value: number): void;
  45339. /**
  45340. * Sets an int2 value on a uniform variable.
  45341. * @param uniformName Name of the variable.
  45342. * @param x First int in int2.
  45343. * @param y Second int in int2.
  45344. */
  45345. setInt2(uniformName: string, x: number, y: number): void;
  45346. /**
  45347. * Sets an int3 value on a uniform variable.
  45348. * @param uniformName Name of the variable.
  45349. * @param x First int in int3.
  45350. * @param y Second int in int3.
  45351. * @param z Third int in int3.
  45352. */
  45353. setInt3(uniformName: string, x: number, y: number, z: number): void;
  45354. /**
  45355. * Sets an int4 value on a uniform variable.
  45356. * @param uniformName Name of the variable.
  45357. * @param x First int in int4.
  45358. * @param y Second int in int4.
  45359. * @param z Third int in int4.
  45360. * @param w Fourth int in int4.
  45361. */
  45362. setInt4(uniformName: string, x: number, y: number, z: number, w: number): void;
  45363. /**
  45364. * Sets an int array on a uniform variable.
  45365. * @param uniformName Name of the variable.
  45366. * @param array array to be set.
  45367. */
  45368. setIntArray(uniformName: string, array: Int32Array): void;
  45369. /**
  45370. * 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)
  45371. * @param uniformName Name of the variable.
  45372. * @param array array to be set.
  45373. */
  45374. setIntArray2(uniformName: string, array: Int32Array): void;
  45375. /**
  45376. * 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)
  45377. * @param uniformName Name of the variable.
  45378. * @param array array to be set.
  45379. */
  45380. setIntArray3(uniformName: string, array: Int32Array): void;
  45381. /**
  45382. * 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)
  45383. * @param uniformName Name of the variable.
  45384. * @param array array to be set.
  45385. */
  45386. setIntArray4(uniformName: string, array: Int32Array): void;
  45387. /**
  45388. * Sets an array on a uniform variable.
  45389. * @param uniformName Name of the variable.
  45390. * @param array array to be set.
  45391. */
  45392. setArray(uniformName: string, array: number[]): void;
  45393. /**
  45394. * 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)
  45395. * @param uniformName Name of the variable.
  45396. * @param array array to be set.
  45397. */
  45398. setArray2(uniformName: string, array: number[]): void;
  45399. /**
  45400. * 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)
  45401. * @param uniformName Name of the variable.
  45402. * @param array array to be set.
  45403. * @returns this effect.
  45404. */
  45405. setArray3(uniformName: string, array: number[]): void;
  45406. /**
  45407. * 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)
  45408. * @param uniformName Name of the variable.
  45409. * @param array array to be set.
  45410. */
  45411. setArray4(uniformName: string, array: number[]): void;
  45412. /**
  45413. * Sets matrices on a uniform variable.
  45414. * @param uniformName Name of the variable.
  45415. * @param matrices matrices to be set.
  45416. */
  45417. setMatrices(uniformName: string, matrices: Float32Array): void;
  45418. /**
  45419. * Sets matrix on a uniform variable.
  45420. * @param uniformName Name of the variable.
  45421. * @param matrix matrix to be set.
  45422. */
  45423. setMatrix(uniformName: string, matrix: IMatrixLike): void;
  45424. /**
  45425. * 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)
  45426. * @param uniformName Name of the variable.
  45427. * @param matrix matrix to be set.
  45428. */
  45429. setMatrix3x3(uniformName: string, matrix: Float32Array): void;
  45430. /**
  45431. * Sets a 2x2 matrix on a uniform variable. (Specified as [1,2,3,4] will result in [1,2][3,4] matrix)
  45432. * @param uniformName Name of the variable.
  45433. * @param matrix matrix to be set.
  45434. */
  45435. setMatrix2x2(uniformName: string, matrix: Float32Array): void;
  45436. /**
  45437. * Sets a float on a uniform variable.
  45438. * @param uniformName Name of the variable.
  45439. * @param value value to be set.
  45440. * @returns this effect.
  45441. */
  45442. setFloat(uniformName: string, value: number): void;
  45443. /**
  45444. * Sets a Vector2 on a uniform variable.
  45445. * @param uniformName Name of the variable.
  45446. * @param vector2 vector2 to be set.
  45447. */
  45448. setVector2(uniformName: string, vector2: IVector2Like): void;
  45449. /**
  45450. * Sets a float2 on a uniform variable.
  45451. * @param uniformName Name of the variable.
  45452. * @param x First float in float2.
  45453. * @param y Second float in float2.
  45454. */
  45455. setFloat2(uniformName: string, x: number, y: number): void;
  45456. /**
  45457. * Sets a Vector3 on a uniform variable.
  45458. * @param uniformName Name of the variable.
  45459. * @param vector3 Value to be set.
  45460. */
  45461. setVector3(uniformName: string, vector3: IVector3Like): void;
  45462. /**
  45463. * Sets a float3 on a uniform variable.
  45464. * @param uniformName Name of the variable.
  45465. * @param x First float in float3.
  45466. * @param y Second float in float3.
  45467. * @param z Third float in float3.
  45468. */
  45469. setFloat3(uniformName: string, x: number, y: number, z: number): void;
  45470. /**
  45471. * Sets a Vector4 on a uniform variable.
  45472. * @param uniformName Name of the variable.
  45473. * @param vector4 Value to be set.
  45474. */
  45475. setVector4(uniformName: string, vector4: IVector4Like): void;
  45476. /**
  45477. * Sets a float4 on a uniform variable.
  45478. * @param uniformName Name of the variable.
  45479. * @param x First float in float4.
  45480. * @param y Second float in float4.
  45481. * @param z Third float in float4.
  45482. * @param w Fourth float in float4.
  45483. * @returns this effect.
  45484. */
  45485. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): void;
  45486. /**
  45487. * Sets a Color3 on a uniform variable.
  45488. * @param uniformName Name of the variable.
  45489. * @param color3 Value to be set.
  45490. */
  45491. setColor3(uniformName: string, color3: IColor3Like): void;
  45492. /**
  45493. * Sets a Color4 on a uniform variable.
  45494. * @param uniformName Name of the variable.
  45495. * @param color3 Value to be set.
  45496. * @param alpha Alpha value to be set.
  45497. */
  45498. setColor4(uniformName: string, color3: IColor3Like, alpha: number): void;
  45499. /**
  45500. * Sets a Color4 on a uniform variable
  45501. * @param uniformName defines the name of the variable
  45502. * @param color4 defines the value to be set
  45503. */
  45504. setDirectColor4(uniformName: string, color4: IColor4Like): void;
  45505. _getVertexShaderCode(): string | null;
  45506. _getFragmentShaderCode(): string | null;
  45507. }
  45508. }
  45509. declare module BABYLON {
  45510. /** @hidden */
  45511. export class WebGPUDataBuffer extends DataBuffer {
  45512. private _buffer;
  45513. constructor(resource: GPUBuffer);
  45514. get underlyingResource(): any;
  45515. }
  45516. }
  45517. declare module BABYLON {
  45518. /**
  45519. * Class used to inline functions in shader code
  45520. */
  45521. export class ShaderCodeInliner {
  45522. private static readonly _RegexpFindFunctionNameAndType;
  45523. private _sourceCode;
  45524. private _functionDescr;
  45525. private _numMaxIterations;
  45526. /** Gets or sets the token used to mark the functions to inline */
  45527. inlineToken: string;
  45528. /** Gets or sets the debug mode */
  45529. debug: boolean;
  45530. /** Gets the code after the inlining process */
  45531. get code(): string;
  45532. /**
  45533. * Initializes the inliner
  45534. * @param sourceCode shader code source to inline
  45535. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  45536. */
  45537. constructor(sourceCode: string, numMaxIterations?: number);
  45538. /**
  45539. * Start the processing of the shader code
  45540. */
  45541. processCode(): void;
  45542. private _collectFunctions;
  45543. private _processInlining;
  45544. private _extractBetweenMarkers;
  45545. private _skipWhitespaces;
  45546. private _isIdentifierChar;
  45547. private _removeComments;
  45548. private _replaceFunctionCallsByCode;
  45549. private _findBackward;
  45550. private _escapeRegExp;
  45551. private _replaceNames;
  45552. }
  45553. }
  45554. declare module BABYLON {
  45555. /** @hidden */
  45556. export class WebGPUShaderProcessor implements IShaderProcessor {
  45557. protected _missingVaryings: Array<string>;
  45558. protected _textureArrayProcessing: Array<string>;
  45559. protected _preProcessors: {
  45560. [key: string]: string;
  45561. };
  45562. private _getArraySize;
  45563. initializeShaders(processingContext: Nullable<ShaderProcessingContext>): void;
  45564. varyingProcessor(varying: string, isFragment: boolean, preProcessors: {
  45565. [key: string]: string;
  45566. }, processingContext: Nullable<ShaderProcessingContext>): string;
  45567. attributeProcessor(attribute: string, preProcessors: {
  45568. [key: string]: string;
  45569. }, processingContext: Nullable<ShaderProcessingContext>): string;
  45570. uniformProcessor(uniform: string, isFragment: boolean, preProcessors: {
  45571. [key: string]: string;
  45572. }, processingContext: Nullable<ShaderProcessingContext>): string;
  45573. uniformBufferProcessor(uniformBuffer: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>): string;
  45574. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>): string;
  45575. private _applyTextureArrayProcessing;
  45576. finalizeShaders(vertexCode: string, fragmentCode: string, processingContext: Nullable<ShaderProcessingContext>): {
  45577. vertexCode: string;
  45578. fragmentCode: string;
  45579. };
  45580. }
  45581. }
  45582. declare module BABYLON {
  45583. /** @hidden */
  45584. export class WebGPUBufferManager {
  45585. private _device;
  45586. private _deferredReleaseBuffers;
  45587. private static _IsGPUBuffer;
  45588. constructor(device: GPUDevice);
  45589. createRawBuffer(viewOrSize: ArrayBufferView | number, flags: GPUBufferUsageFlags, mappedAtCreation?: boolean): GPUBuffer;
  45590. createBuffer(viewOrSize: ArrayBufferView | number, flags: GPUBufferUsageFlags): DataBuffer;
  45591. setSubData(dataBuffer: WebGPUDataBuffer, dstByteOffset: number, src: ArrayBufferView, srcByteOffset?: number, byteLength?: number): void;
  45592. private _FromHalfFloat;
  45593. private _GetHalfFloatAsFloatRGBAArrayBuffer;
  45594. readDataFromBuffer(gpuBuffer: GPUBuffer, size: number, width: number, height: number, bytesPerRow: number, bytesPerRowAligned: number, floatFormat?: number, offset?: number, buffer?: Nullable<ArrayBufferView>, destroyBuffer?: boolean): Promise<ArrayBufferView>;
  45595. releaseBuffer(buffer: DataBuffer | GPUBuffer): boolean;
  45596. destroyDeferredBuffers(): void;
  45597. }
  45598. }
  45599. declare module BABYLON {
  45600. /** @hidden */
  45601. export class WebGPUHardwareTexture implements HardwareTextureWrapper {
  45602. private _webgpuTexture;
  45603. private _webgpuMSAATexture;
  45604. get underlyingResource(): Nullable<GPUTexture>;
  45605. get msaaTexture(): Nullable<GPUTexture>;
  45606. set msaaTexture(texture: Nullable<GPUTexture>);
  45607. view: Nullable<GPUTextureView>;
  45608. format: GPUTextureFormat;
  45609. textureUsages: number;
  45610. constructor(existingTexture?: Nullable<GPUTexture>);
  45611. set(hardwareTexture: GPUTexture): void;
  45612. setMSAATexture(hardwareTexture: GPUTexture): void;
  45613. setUsage(textureSource: number, generateMipMaps: boolean, isCube: boolean, width: number, height: number): void;
  45614. createView(descriptor?: GPUTextureViewDescriptor): void;
  45615. reset(): void;
  45616. release(): void;
  45617. }
  45618. }
  45619. declare module BABYLON {
  45620. /** @hidden */
  45621. export class WebGPUTextureHelper {
  45622. private _device;
  45623. private _glslang;
  45624. private _bufferManager;
  45625. private _mipmapSampler;
  45626. private _invertYPreMultiplyAlphaSampler;
  45627. private _pipelines;
  45628. private _compiledShaders;
  45629. private _deferredReleaseTextures;
  45630. private _commandEncoderForCreation;
  45631. static ComputeNumMipmapLevels(width: number, height: number): number;
  45632. constructor(device: GPUDevice, glslang: any, bufferManager: WebGPUBufferManager);
  45633. private _getPipeline;
  45634. private static _GetTextureTypeFromFormat;
  45635. private static _GetBlockInformationFromFormat;
  45636. private static _IsHardwareTexture;
  45637. private static _IsInternalTexture;
  45638. static GetCompareFunction(compareFunction: Nullable<number>): GPUCompareFunction;
  45639. static IsImageBitmap(imageBitmap: ImageBitmap | {
  45640. width: number;
  45641. height: number;
  45642. }): imageBitmap is ImageBitmap;
  45643. static IsImageBitmapArray(imageBitmap: ImageBitmap[] | {
  45644. width: number;
  45645. height: number;
  45646. }): imageBitmap is ImageBitmap[];
  45647. setCommandEncoder(encoder: GPUCommandEncoder): void;
  45648. static IsCompressedFormat(format: GPUTextureFormat): boolean;
  45649. static GetWebGPUTextureFormat(type: number, format: number): GPUTextureFormat;
  45650. invertYPreMultiplyAlpha(gpuTexture: GPUTexture, width: number, height: number, format: GPUTextureFormat, invertY?: boolean, premultiplyAlpha?: boolean, faceIndex?: number, commandEncoder?: GPUCommandEncoder): void;
  45651. clear(format: GPUTextureFormat, color: IColor4Like, passEncoder: GPURenderPassEncoder): void;
  45652. createTexture(imageBitmap: ImageBitmap | {
  45653. width: number;
  45654. height: number;
  45655. layers: number;
  45656. }, hasMipmaps?: boolean, generateMipmaps?: boolean, invertY?: boolean, premultiplyAlpha?: boolean, is3D?: boolean, format?: GPUTextureFormat, sampleCount?: number, commandEncoder?: GPUCommandEncoder, usage?: number): GPUTexture;
  45657. createCubeTexture(imageBitmaps: ImageBitmap[] | {
  45658. width: number;
  45659. height: number;
  45660. }, hasMipmaps?: boolean, generateMipmaps?: boolean, invertY?: boolean, premultiplyAlpha?: boolean, format?: GPUTextureFormat, sampleCount?: number, commandEncoder?: GPUCommandEncoder, usage?: number): GPUTexture;
  45661. generateCubeMipmaps(gpuTexture: GPUTexture, format: GPUTextureFormat, mipLevelCount: number, commandEncoder?: GPUCommandEncoder): void;
  45662. generateMipmaps(gpuTexture: GPUTexture, format: GPUTextureFormat, mipLevelCount: number, faceIndex?: number, commandEncoder?: GPUCommandEncoder): void;
  45663. createGPUTextureForInternalTexture(texture: InternalTexture, width?: number, height?: number, depth?: number): WebGPUHardwareTexture;
  45664. createMSAATexture(texture: InternalTexture, samples: number): void;
  45665. updateCubeTextures(imageBitmaps: ImageBitmap[] | Uint8Array[], gpuTexture: GPUTexture, width: number, height: number, format: GPUTextureFormat, invertY?: boolean, premultiplyAlpha?: boolean, offsetX?: number, offsetY?: number, commandEncoder?: GPUCommandEncoder): void;
  45666. 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;
  45667. readPixels(texture: GPUTexture, x: number, y: number, width: number, height: number, format: GPUTextureFormat, faceIndex?: number, mipLevel?: number, buffer?: Nullable<ArrayBufferView>): Promise<ArrayBufferView>;
  45668. releaseTexture(texture: InternalTexture | GPUTexture): void;
  45669. destroyDeferredTextures(): void;
  45670. }
  45671. }
  45672. declare module BABYLON {
  45673. /** @hidden */
  45674. export class WebGPURenderPassWrapper {
  45675. renderPassDescriptor: Nullable<GPURenderPassDescriptor>;
  45676. renderPass: Nullable<GPURenderPassEncoder>;
  45677. colorAttachmentViewDescriptor: Nullable<GPUTextureViewDescriptor>;
  45678. depthAttachmentViewDescriptor: Nullable<GPUTextureViewDescriptor>;
  45679. colorAttachmentGPUTextures: WebGPUHardwareTexture[];
  45680. depthTextureFormat: GPUTextureFormat | undefined;
  45681. constructor();
  45682. reset(fullReset?: boolean): void;
  45683. }
  45684. }
  45685. declare module BABYLON {
  45686. /** @hidden */
  45687. export class WebGPUCacheSampler {
  45688. private _samplers;
  45689. private _device;
  45690. disabled: boolean;
  45691. constructor(device: GPUDevice);
  45692. private static _GetSamplerHashCode;
  45693. private static _GetSamplerFilterDescriptor;
  45694. private static _GetWrappingMode;
  45695. private static _GetSamplerWrappingDescriptor;
  45696. private static _GetSamplerDescriptor;
  45697. getSampler(internalTexture: InternalTexture, bypassCache?: boolean): GPUSampler;
  45698. }
  45699. }
  45700. declare module BABYLON {
  45701. /** @hidden */
  45702. export class WebGPUShaderManager {
  45703. private _shaders;
  45704. private _device;
  45705. constructor(device: GPUDevice);
  45706. getCompiledShaders(name: string): IWebGPURenderPipelineStageDescriptor;
  45707. }
  45708. }
  45709. declare module BABYLON {
  45710. /** @hidden */
  45711. export abstract class WebGPUCacheRenderPipeline {
  45712. static NumCacheHitWithoutHash: number;
  45713. static NumCacheHitWithHash: number;
  45714. static NumCacheMiss: number;
  45715. static NumPipelineCreationLastFrame: number;
  45716. disabled: boolean;
  45717. private static _NumPipelineCreationCurrentFrame;
  45718. protected _states: number[];
  45719. protected _stateDirtyLowestIndex: number;
  45720. lastStateDirtyLowestIndex: number;
  45721. private _device;
  45722. private _isDirty;
  45723. private _emptyVertexBuffer;
  45724. private _parameter;
  45725. private _shaderId;
  45726. private _alphaToCoverageEnabled;
  45727. private _frontFace;
  45728. private _cullEnabled;
  45729. private _cullFace;
  45730. private _clampDepth;
  45731. private _rasterizationState;
  45732. private _depthBias;
  45733. private _depthBiasClamp;
  45734. private _depthBiasSlopeScale;
  45735. private _colorFormat;
  45736. private _webgpuColorFormat;
  45737. private _mrtAttachments1;
  45738. private _mrtAttachments2;
  45739. private _mrtFormats;
  45740. private _alphaBlendEnabled;
  45741. private _alphaBlendFuncParams;
  45742. private _alphaBlendEqParams;
  45743. private _writeMask;
  45744. private _colorStates;
  45745. private _depthStencilFormat;
  45746. private _webgpuDepthStencilFormat;
  45747. private _depthTestEnabled;
  45748. private _depthWriteEnabled;
  45749. private _depthCompare;
  45750. private _stencilEnabled;
  45751. private _stencilFrontCompare;
  45752. private _stencilFrontDepthFailOp;
  45753. private _stencilFrontPassOp;
  45754. private _stencilFrontFailOp;
  45755. private _stencilReadMask;
  45756. private _stencilWriteMask;
  45757. private _depthStencilState;
  45758. private _vertexBuffers;
  45759. private _overrideVertexBuffers;
  45760. private _indexBuffer;
  45761. constructor(device: GPUDevice, emptyVertexBuffer: VertexBuffer);
  45762. reset(): void;
  45763. protected abstract _getRenderPipeline(param: {
  45764. token: any;
  45765. pipeline: Nullable<GPURenderPipeline>;
  45766. }): void;
  45767. protected abstract _setRenderPipeline(param: {
  45768. token: any;
  45769. pipeline: Nullable<GPURenderPipeline>;
  45770. }): void;
  45771. getRenderPipeline(fillMode: number, effect: Effect, sampleCount: number): GPURenderPipeline;
  45772. endFrame(): void;
  45773. setAlphaToCoverage(enabled: boolean): void;
  45774. setFrontFace(frontFace: number): void;
  45775. setCullEnabled(enabled: boolean): void;
  45776. setCullFace(cullFace: number): void;
  45777. setClampDepth(clampDepth: boolean): void;
  45778. resetDepthCullingState(): void;
  45779. setDepthCullingState(cullEnabled: boolean, frontFace: number, cullFace: number, zOffset: number, depthTestEnabled: boolean, depthWriteEnabled: boolean, depthCompare: Nullable<number>): void;
  45780. setDepthBiasSlopeScale(depthBiasSlopeScale: number): void;
  45781. setColorFormat(format: GPUTextureFormat): void;
  45782. setMRTAttachments(attachments: number[], textureArray: InternalTexture[]): void;
  45783. setAlphaBlendEnabled(enabled: boolean): void;
  45784. setAlphaBlendFactors(factors: Array<Nullable<number>>, operations: Array<Nullable<number>>): void;
  45785. setWriteMask(mask: number): void;
  45786. setDepthStencilFormat(format: GPUTextureFormat | undefined): void;
  45787. setDepthTestEnabled(enabled: boolean): void;
  45788. setDepthWriteEnabled(enabled: boolean): void;
  45789. setDepthCompare(func: Nullable<number>): void;
  45790. setStencilEnabled(enabled: boolean): void;
  45791. setStencilCompare(func: Nullable<number>): void;
  45792. setStencilDepthFailOp(op: Nullable<number>): void;
  45793. setStencilPassOp(op: Nullable<number>): void;
  45794. setStencilFailOp(op: Nullable<number>): void;
  45795. setStencilReadMask(mask: number): void;
  45796. setStencilWriteMask(mask: number): void;
  45797. resetStencilState(): void;
  45798. setStencilState(stencilEnabled: boolean, compare: Nullable<number>, depthFailOp: Nullable<number>, passOp: Nullable<number>, failOp: Nullable<number>, readMask: number, writeMask: number): void;
  45799. setBuffers(vertexBuffers: Nullable<{
  45800. [key: string]: Nullable<VertexBuffer>;
  45801. }>, indexBuffer: Nullable<DataBuffer>, overrideVertexBuffers: Nullable<{
  45802. [key: string]: Nullable<VertexBuffer>;
  45803. }>): void;
  45804. private static _GetTopology;
  45805. private static _GetAphaBlendOperation;
  45806. private static _GetAphaBlendFactor;
  45807. private static _GetCompareFunction;
  45808. private static _GetStencilOpFunction;
  45809. private static _GetVertexInputDescriptorFormat;
  45810. private _getAphaBlendState;
  45811. private _getColorBlendState;
  45812. private _setShaderStage;
  45813. private _setRasterizationState;
  45814. private _setColorStates;
  45815. private _setDepthStencilState;
  45816. private _setVertexState;
  45817. private _createPipelineLayout;
  45818. private _getVertexInputDescriptor;
  45819. private _createRenderPipeline;
  45820. }
  45821. }
  45822. declare module BABYLON {
  45823. /** @hidden */
  45824. class NodeState {
  45825. values: {
  45826. [name: number]: NodeState;
  45827. };
  45828. pipeline: GPURenderPipeline;
  45829. constructor();
  45830. count(): [number, number];
  45831. }
  45832. /** @hidden */
  45833. export class WebGPUCacheRenderPipelineTree extends WebGPUCacheRenderPipeline {
  45834. private static _Cache;
  45835. private _nodeStack;
  45836. static GetNodeCounts(): {
  45837. nodeCount: number;
  45838. pipelineCount: number;
  45839. };
  45840. constructor(device: GPUDevice, emptyVertexBuffer: VertexBuffer);
  45841. protected _getRenderPipeline(param: {
  45842. token: any;
  45843. pipeline: Nullable<GPURenderPipeline>;
  45844. }): void;
  45845. protected _setRenderPipeline(param: {
  45846. token: NodeState;
  45847. pipeline: Nullable<GPURenderPipeline>;
  45848. }): void;
  45849. }
  45850. }
  45851. declare module BABYLON {
  45852. /**
  45853. * @hidden
  45854. **/
  45855. export class WebGPUStencilState extends StencilState {
  45856. private _cache;
  45857. constructor(cache: WebGPUCacheRenderPipeline);
  45858. get stencilFunc(): number;
  45859. set stencilFunc(value: number);
  45860. get stencilFuncRef(): number;
  45861. set stencilFuncRef(value: number);
  45862. get stencilFuncMask(): number;
  45863. set stencilFuncMask(value: number);
  45864. get stencilOpStencilFail(): number;
  45865. set stencilOpStencilFail(value: number);
  45866. get stencilOpDepthFail(): number;
  45867. set stencilOpDepthFail(value: number);
  45868. get stencilOpStencilDepthPass(): number;
  45869. set stencilOpStencilDepthPass(value: number);
  45870. get stencilMask(): number;
  45871. set stencilMask(value: number);
  45872. get stencilTest(): boolean;
  45873. set stencilTest(value: boolean);
  45874. reset(): void;
  45875. apply(gl: WebGLRenderingContext): void;
  45876. }
  45877. }
  45878. declare module BABYLON {
  45879. /**
  45880. * @hidden
  45881. **/
  45882. export class WebGPUDepthCullingState extends DepthCullingState {
  45883. private _cache;
  45884. /**
  45885. * Initializes the state.
  45886. */
  45887. constructor(cache: WebGPUCacheRenderPipeline);
  45888. get zOffset(): number;
  45889. set zOffset(value: number);
  45890. get cullFace(): Nullable<number>;
  45891. set cullFace(value: Nullable<number>);
  45892. get cull(): Nullable<boolean>;
  45893. set cull(value: Nullable<boolean>);
  45894. get depthFunc(): Nullable<number>;
  45895. set depthFunc(value: Nullable<number>);
  45896. get depthMask(): boolean;
  45897. set depthMask(value: boolean);
  45898. get depthTest(): boolean;
  45899. set depthTest(value: boolean);
  45900. get frontFace(): Nullable<number>;
  45901. set frontFace(value: Nullable<number>);
  45902. reset(): void;
  45903. apply(gl: WebGLRenderingContext): void;
  45904. }
  45905. }
  45906. declare module BABYLON {
  45907. /** @hidden */
  45908. export var clearQuadVertexShader: {
  45909. name: string;
  45910. shader: string;
  45911. };
  45912. }
  45913. declare module BABYLON {
  45914. /** @hidden */
  45915. export var clearQuadPixelShader: {
  45916. name: string;
  45917. shader: string;
  45918. };
  45919. }
  45920. declare module BABYLON {
  45921. /**
  45922. * Options to load the associated Glslang library
  45923. */
  45924. export interface GlslangOptions {
  45925. /**
  45926. * Defines an existing instance of Glslang (useful in modules who do not access the global instance).
  45927. */
  45928. glslang?: any;
  45929. /**
  45930. * Defines the URL of the glslang JS File.
  45931. */
  45932. jsPath?: string;
  45933. /**
  45934. * Defines the URL of the glslang WASM File.
  45935. */
  45936. wasmPath?: string;
  45937. }
  45938. /**
  45939. * Options to create the WebGPU engine
  45940. */
  45941. export interface WebGPUEngineOptions extends GPURequestAdapterOptions {
  45942. /**
  45943. * If delta time between frames should be constant
  45944. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45945. */
  45946. deterministicLockstep?: boolean;
  45947. /**
  45948. * Maximum about of steps between frames (Default: 4)
  45949. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45950. */
  45951. lockstepMaxSteps?: number;
  45952. /**
  45953. * Defines the seconds between each deterministic lock step
  45954. */
  45955. timeStep?: number;
  45956. /**
  45957. * Defines that engine should ignore modifying touch action attribute and style
  45958. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  45959. */
  45960. doNotHandleTouchAction?: boolean;
  45961. /**
  45962. * Defines if webaudio should be initialized as well
  45963. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  45964. */
  45965. audioEngine?: boolean;
  45966. /**
  45967. * Defines the category of adapter to use.
  45968. * Is it the discrete or integrated device.
  45969. */
  45970. powerPreference?: GPUPowerPreference;
  45971. /**
  45972. * Defines the device descriptor used to create a device.
  45973. */
  45974. deviceDescriptor?: GPUDeviceDescriptor;
  45975. /**
  45976. * Defines the requested Swap Chain Format.
  45977. */
  45978. swapChainFormat?: GPUTextureFormat;
  45979. /**
  45980. * Defines whether MSAA is enabled on the canvas.
  45981. */
  45982. antialiasing?: boolean;
  45983. /**
  45984. * Defines whether the stencil buffer should be enabled.
  45985. */
  45986. stencil?: boolean;
  45987. /**
  45988. * Defines whether we should generate debug markers in the gpu command lists (can be seen with PIX for eg)
  45989. */
  45990. enableGPUDebugMarkers?: boolean;
  45991. /**
  45992. * Options to load the associated Glslang library
  45993. */
  45994. glslangOptions?: GlslangOptions;
  45995. }
  45996. /**
  45997. * The web GPU engine class provides support for WebGPU version of babylon.js.
  45998. */
  45999. export class WebGPUEngine extends Engine {
  46000. private static readonly _glslangDefaultOptions;
  46001. private readonly _uploadEncoderDescriptor;
  46002. private readonly _renderEncoderDescriptor;
  46003. private readonly _renderTargetEncoderDescriptor;
  46004. private readonly _clearDepthValue;
  46005. private readonly _clearReverseDepthValue;
  46006. private readonly _clearStencilValue;
  46007. private readonly _defaultSampleCount;
  46008. private _canvas;
  46009. private _options;
  46010. private _glslang;
  46011. private _adapter;
  46012. private _adapterSupportedExtensions;
  46013. private _device;
  46014. private _deviceEnabledExtensions;
  46015. private _context;
  46016. private _swapChain;
  46017. private _swapChainTexture;
  46018. private _mainPassSampleCount;
  46019. private _textureHelper;
  46020. private _bufferManager;
  46021. private _shaderManager;
  46022. private _cacheSampler;
  46023. private _cacheRenderPipeline;
  46024. private _emptyVertexBuffer;
  46025. private _lastCachedWrapU;
  46026. private _lastCachedWrapV;
  46027. private _lastCachedWrapR;
  46028. private _mrtAttachments;
  46029. private _counters;
  46030. private _mainTexture;
  46031. private _depthTexture;
  46032. private _mainTextureExtends;
  46033. private _depthTextureFormat;
  46034. private _colorFormat;
  46035. private _uploadEncoder;
  46036. private _renderEncoder;
  46037. private _renderTargetEncoder;
  46038. private _commandBuffers;
  46039. private _currentRenderPass;
  46040. private _mainRenderPassWrapper;
  46041. private _rttRenderPassWrapper;
  46042. private _pendingDebugCommands;
  46043. private _currentVertexBuffers;
  46044. private _currentOverrideVertexBuffers;
  46045. private _currentIndexBuffer;
  46046. private __colorWrite;
  46047. private _uniformsBuffers;
  46048. private _forceEnableEffect;
  46049. /** @hidden */
  46050. dbgShowShaderCode: boolean;
  46051. /** @hidden */
  46052. dbgSanityChecks: boolean;
  46053. /** @hidden */
  46054. dbgGenerateLogs: boolean;
  46055. /** @hidden */
  46056. dbgVerboseLogsForFirstFrames: boolean;
  46057. /** @hidden */
  46058. dbgVerboseLogsNumFrames: number;
  46059. /**
  46060. * Sets this to true to disable the cache for the samplers. You should do it only for testing purpose!
  46061. */
  46062. get disableCacheSamplers(): boolean;
  46063. set disableCacheSamplers(disable: boolean);
  46064. /**
  46065. * Sets this to true to disable the cache for the render pipelines. You should do it only for testing purpose!
  46066. */
  46067. get disableCacheRenderPipelines(): boolean;
  46068. set disableCacheRenderPipelines(disable: boolean);
  46069. /**
  46070. * Gets a boolean indicating if the engine can be instantiated (ie. if a WebGPU context can be found)
  46071. * @returns true if the engine can be created
  46072. */
  46073. static get IsSupported(): boolean;
  46074. /**
  46075. * Gets a boolean indicating that the engine supports uniform buffers
  46076. */
  46077. get supportsUniformBuffers(): boolean;
  46078. /** Gets the supported extensions by the WebGPU adapter */
  46079. get supportedExtensions(): Immutable<GPUExtensionName[]>;
  46080. /** Gets the currently enabled extensions on the WebGPU device */
  46081. get enabledExtensions(): Immutable<GPUExtensionName[]>;
  46082. /**
  46083. * Returns the name of the engine
  46084. */
  46085. get name(): string;
  46086. /**
  46087. * Returns a string describing the current engine
  46088. */
  46089. get description(): string;
  46090. /**
  46091. * Returns the version of the engine
  46092. */
  46093. get version(): number;
  46094. /**
  46095. * Create a new instance of the gpu engine asynchronously
  46096. * @param canvas Defines the canvas to use to display the result
  46097. * @param options Defines the options passed to the engine to create the GPU context dependencies
  46098. * @returns a promise that resolves with the created engine
  46099. */
  46100. static CreateAsync(canvas: HTMLCanvasElement, options?: WebGPUEngineOptions): Promise<WebGPUEngine>;
  46101. /**
  46102. * Create a new instance of the gpu engine.
  46103. * @param canvas Defines the canvas to use to display the result
  46104. * @param options Defines the options passed to the engine to create the GPU context dependencies
  46105. */
  46106. constructor(canvas: HTMLCanvasElement, options?: WebGPUEngineOptions);
  46107. /**
  46108. * Initializes the WebGPU context and dependencies.
  46109. * @param glslangOptions Defines the GLSLang compiler options if necessary
  46110. * @returns a promise notifying the readiness of the engine.
  46111. */
  46112. initAsync(glslangOptions?: GlslangOptions): Promise<void>;
  46113. private _initGlslang;
  46114. private _initializeLimits;
  46115. private _initializeContextAndSwapChain;
  46116. private _initializeMainAttachments;
  46117. /**
  46118. * Force a specific size of the canvas
  46119. * @param width defines the new canvas' width
  46120. * @param height defines the new canvas' height
  46121. * @param forceSetSize true to force setting the sizes of the underlying canvas
  46122. * @returns true if the size was changed
  46123. */
  46124. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  46125. /**
  46126. * Gets a shader processor implementation fitting with the current engine type.
  46127. * @returns The shader processor implementation.
  46128. */
  46129. protected _getShaderProcessor(): Nullable<IShaderProcessor>;
  46130. /** @hidden */
  46131. _getShaderProcessingContext(): Nullable<ShaderProcessingContext>;
  46132. /**
  46133. * Force the entire cache to be cleared
  46134. * You should not have to use this function unless your engine needs to share the WebGPU context with another engine
  46135. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  46136. */
  46137. wipeCaches(bruteForce?: boolean): void;
  46138. /**
  46139. * Enable or disable color writing
  46140. * @param enable defines the state to set
  46141. */
  46142. setColorWrite(enable: boolean): void;
  46143. /**
  46144. * Gets a boolean indicating if color writing is enabled
  46145. * @returns the current color writing state
  46146. */
  46147. getColorWrite(): boolean;
  46148. private _viewportsCurrent;
  46149. private _resetCurrentViewport;
  46150. private _applyViewport;
  46151. /** @hidden */
  46152. _viewport(x: number, y: number, width: number, height: number): void;
  46153. private _scissorsCurrent;
  46154. protected _scissorCached: {
  46155. x: number;
  46156. y: number;
  46157. z: number;
  46158. w: number;
  46159. };
  46160. private _resetCurrentScissor;
  46161. private _applyScissor;
  46162. private _scissorIsActive;
  46163. enableScissor(x: number, y: number, width: number, height: number): void;
  46164. disableScissor(): void;
  46165. /**
  46166. * Clear the current render buffer or the current render target (if any is set up)
  46167. * @param color defines the color to use
  46168. * @param backBuffer defines if the back buffer must be cleared
  46169. * @param depth defines if the depth buffer must be cleared
  46170. * @param stencil defines if the stencil buffer must be cleared
  46171. */
  46172. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46173. /**
  46174. * Clears a list of attachments
  46175. * @param attachments list of the attachments
  46176. * @param colorMain clear color for the main attachment (the first one)
  46177. * @param colorOthers clear color for the other attachments
  46178. * @param clearDepth true to clear the depth buffer. Used only for the first attachment
  46179. * @param clearStencil true to clear the stencil buffer. Used only for the first attachment
  46180. */
  46181. clearAttachments(attachments: number[], colorMain: Nullable<IColor4Like>, colorOthers: Nullable<IColor4Like>, clearDepth: boolean, clearStencil: boolean): void;
  46182. /**
  46183. * Creates a vertex buffer
  46184. * @param data the data for the vertex buffer
  46185. * @returns the new buffer
  46186. */
  46187. createVertexBuffer(data: DataArray): DataBuffer;
  46188. /**
  46189. * Creates a vertex buffer
  46190. * @param data the data for the dynamic vertex buffer
  46191. * @returns the new buffer
  46192. */
  46193. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  46194. /**
  46195. * Updates a vertex buffer.
  46196. * @param vertexBuffer the vertex buffer to update
  46197. * @param data the data used to update the vertex buffer
  46198. * @param byteOffset the byte offset of the data
  46199. * @param byteLength the byte length of the data
  46200. */
  46201. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  46202. /**
  46203. * Creates a new index buffer
  46204. * @param indices defines the content of the index buffer
  46205. * @param updatable defines if the index buffer must be updatable - not used in WebGPU
  46206. * @returns a new buffer
  46207. */
  46208. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  46209. /**
  46210. * Update an index buffer
  46211. * @param indexBuffer defines the target index buffer
  46212. * @param indices defines the data to update
  46213. * @param offset defines the offset in the target index buffer where update should start
  46214. */
  46215. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  46216. /** @hidden */
  46217. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  46218. /** @hidden */
  46219. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  46220. /**
  46221. * Bind a list of vertex buffers with the engine
  46222. * @param vertexBuffers defines the list of vertex buffers to bind
  46223. * @param indexBuffer defines the index buffer to bind
  46224. * @param effect defines the effect associated with the vertex buffers
  46225. * @param overrideVertexBuffers defines optional list of avertex buffers that overrides the entries in vertexBuffers
  46226. */
  46227. bindBuffers(vertexBuffers: {
  46228. [key: string]: Nullable<VertexBuffer>;
  46229. }, indexBuffer: Nullable<DataBuffer>, effect: Effect, overrideVertexBuffers?: {
  46230. [kind: string]: Nullable<VertexBuffer>;
  46231. }): void;
  46232. /** @hidden */
  46233. _releaseBuffer(buffer: DataBuffer): boolean;
  46234. createUniformBuffer(elements: FloatArray): DataBuffer;
  46235. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  46236. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  46237. bindUniformBufferBase(buffer: DataBuffer, location: number, name: string): void;
  46238. /**
  46239. * Create a new effect (used to store vertex/fragment shaders)
  46240. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  46241. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  46242. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  46243. * @param samplers defines an array of string used to represent textures
  46244. * @param defines defines the string containing the defines to use to compile the shaders
  46245. * @param fallbacks defines the list of potential fallbacks to use if shader compilation fails
  46246. * @param onCompiled defines a function to call when the effect creation is successful
  46247. * @param onError defines a function to call when the effect creation has failed
  46248. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  46249. * @returns the new Effect
  46250. */
  46251. 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;
  46252. private _compileRawShaderToSpirV;
  46253. private _compileShaderToSpirV;
  46254. private _createPipelineStageDescriptor;
  46255. private _compileRawPipelineStageDescriptor;
  46256. private _compilePipelineStageDescriptor;
  46257. /** @hidden */
  46258. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  46259. /** @hidden */
  46260. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  46261. /**
  46262. * Creates a new pipeline context
  46263. * @param shaderProcessingContext defines the shader processing context used during the processing if available
  46264. * @returns the new pipeline
  46265. */
  46266. createPipelineContext(shaderProcessingContext: Nullable<ShaderProcessingContext>): IPipelineContext;
  46267. /** @hidden */
  46268. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>, key: string): void;
  46269. /**
  46270. * Gets the list of active attributes for a given WebGPU program
  46271. * @param pipelineContext defines the pipeline context to use
  46272. * @param attributesNames defines the list of attribute names to get
  46273. * @returns an array of indices indicating the offset of each attribute
  46274. */
  46275. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46276. /**
  46277. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  46278. * @param effect defines the effect to activate
  46279. */
  46280. enableEffect(effect: Nullable<Effect>): void;
  46281. /** @hidden */
  46282. _releaseEffect(effect: Effect): void;
  46283. /**
  46284. * 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
  46285. */
  46286. releaseEffects(): void;
  46287. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  46288. /**
  46289. * Gets a boolean indicating that only power of 2 textures are supported
  46290. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  46291. */
  46292. get needPOTTextures(): boolean;
  46293. /** @hidden */
  46294. _createHardwareTexture(): HardwareTextureWrapper;
  46295. /** @hidden */
  46296. _releaseTexture(texture: InternalTexture): void;
  46297. /** @hidden */
  46298. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  46299. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  46300. /**
  46301. * Usually called from Texture.ts.
  46302. * Passed information to create a hardware texture
  46303. * @param url defines a value which contains one of the following:
  46304. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46305. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46306. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46307. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46308. * @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)
  46309. * @param scene needed for loading to the correct scene
  46310. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  46311. * @param onLoad optional callback to be called upon successful completion
  46312. * @param onError optional callback to be called upon failure
  46313. * @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
  46314. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46315. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46316. * @param forcedExtension defines the extension to use to pick the right loader
  46317. * @param mimeType defines an optional mime type
  46318. * @param loaderOptions options to be passed to the loader
  46319. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46320. */
  46321. 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;
  46322. /** @hidden */
  46323. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  46324. /**
  46325. * Creates a cube texture
  46326. * @param rootUrl defines the url where the files to load is located
  46327. * @param scene defines the current scene
  46328. * @param files defines the list of files to load (1 per face)
  46329. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  46330. * @param onLoad defines an optional callback raised when the texture is loaded
  46331. * @param onError defines an optional callback raised if there is an issue to load the texture
  46332. * @param format defines the format of the data
  46333. * @param forcedExtension defines the extension to use to pick the right loader
  46334. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  46335. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  46336. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  46337. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  46338. * @param loaderOptions options to be passed to the loader
  46339. * @returns the cube texture as an InternalTexture
  46340. */
  46341. 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;
  46342. /**
  46343. * Creates a raw texture
  46344. * @param data defines the data to store in the texture
  46345. * @param width defines the width of the texture
  46346. * @param height defines the height of the texture
  46347. * @param format defines the format of the data
  46348. * @param generateMipMaps defines if the engine should generate the mip levels
  46349. * @param invertY defines if data must be stored with Y axis inverted
  46350. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  46351. * @param compression defines the compression used (null by default)
  46352. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  46353. * @returns the raw texture inside an InternalTexture
  46354. */
  46355. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  46356. /**
  46357. * Creates a new raw cube texture
  46358. * @param data defines the array of data to use to create each face
  46359. * @param size defines the size of the textures
  46360. * @param format defines the format of the data
  46361. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  46362. * @param generateMipMaps defines if the engine should generate the mip levels
  46363. * @param invertY defines if data must be stored with Y axis inverted
  46364. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  46365. * @param compression defines the compression used (null by default)
  46366. * @returns the cube texture as an InternalTexture
  46367. */
  46368. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  46369. /**
  46370. * Creates a new raw cube texture from a specified url
  46371. * @param url defines the url where the data is located
  46372. * @param scene defines the current scene
  46373. * @param size defines the size of the textures
  46374. * @param format defines the format of the data
  46375. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  46376. * @param noMipmap defines if the engine should avoid generating the mip levels
  46377. * @param callback defines a callback used to extract texture data from loaded data
  46378. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  46379. * @param onLoad defines a callback called when texture is loaded
  46380. * @param onError defines a callback called if there is an error
  46381. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  46382. * @param invertY defines if data must be stored with Y axis inverted
  46383. * @returns the cube texture as an InternalTexture
  46384. */
  46385. 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;
  46386. /**
  46387. * Creates a new raw 2D array texture
  46388. * @param data defines the data used to create the texture
  46389. * @param width defines the width of the texture
  46390. * @param height defines the height of the texture
  46391. * @param depth defines the number of layers of the texture
  46392. * @param format defines the format of the texture
  46393. * @param generateMipMaps defines if the engine must generate mip levels
  46394. * @param invertY defines if data must be stored with Y axis inverted
  46395. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  46396. * @param compression defines the compressed used (can be null)
  46397. * @param textureType defines the compressed used (can be null)
  46398. * @returns a new raw 2D array texture (stored in an InternalTexture)
  46399. */
  46400. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  46401. /**
  46402. * Creates a new raw 3D texture
  46403. * @param data defines the data used to create the texture
  46404. * @param width defines the width of the texture
  46405. * @param height defines the height of the texture
  46406. * @param depth defines the depth of the texture
  46407. * @param format defines the format of the texture
  46408. * @param generateMipMaps defines if the engine must generate mip levels
  46409. * @param invertY defines if data must be stored with Y axis inverted
  46410. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  46411. * @param compression defines the compressed used (can be null)
  46412. * @param textureType defines the compressed used (can be null)
  46413. * @returns a new raw 3D texture (stored in an InternalTexture)
  46414. */
  46415. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  46416. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  46417. /**
  46418. * Update the sampling mode of a given texture
  46419. * @param samplingMode defines the required sampling mode
  46420. * @param texture defines the texture to update
  46421. * @param generateMipMaps defines whether to generate mipmaps for the texture
  46422. */
  46423. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  46424. /**
  46425. * Update the sampling mode of a given texture
  46426. * @param texture defines the texture to update
  46427. * @param wrapU defines the texture wrap mode of the u coordinates
  46428. * @param wrapV defines the texture wrap mode of the v coordinates
  46429. * @param wrapR defines the texture wrap mode of the r coordinates
  46430. */
  46431. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  46432. /**
  46433. * Update the dimensions of a texture
  46434. * @param texture texture to update
  46435. * @param width new width of the texture
  46436. * @param height new height of the texture
  46437. * @param depth new depth of the texture
  46438. */
  46439. updateTextureDimensions(texture: InternalTexture, width: number, height: number, depth?: number): void;
  46440. private _setInternalTexture;
  46441. /**
  46442. * Sets a texture to the according uniform.
  46443. * @param channel The texture channel
  46444. * @param unused unused parameter
  46445. * @param texture The texture to apply
  46446. * @param name The name of the uniform in the effect
  46447. */
  46448. setTexture(channel: number, unused: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>, name: string): void;
  46449. /**
  46450. * Sets an array of texture to the WebGPU context
  46451. * @param channel defines the channel where the texture array must be set
  46452. * @param unused unused parameter
  46453. * @param textures defines the array of textures to bind
  46454. * @param name name of the channel
  46455. */
  46456. setTextureArray(channel: number, unused: Nullable<WebGLUniformLocation>, textures: BaseTexture[], name: string): void;
  46457. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean, name?: string, baseName?: string, textureIndex?: number): boolean;
  46458. /** @hidden */
  46459. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  46460. /** @hidden */
  46461. _bindTexture(channel: number, texture: InternalTexture, name: string): void;
  46462. private _generateMipmaps;
  46463. /**
  46464. * Update the content of a texture
  46465. * @param texture defines the texture to update
  46466. * @param canvas defines the source containing the data
  46467. * @param invertY defines if data must be stored with Y axis inverted
  46468. * @param premulAlpha defines if alpha is stored as premultiplied
  46469. * @param format defines the format of the data
  46470. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  46471. */
  46472. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  46473. /**
  46474. * Update a portion of an internal texture
  46475. * @param texture defines the texture to update
  46476. * @param imageData defines the data to store into the texture
  46477. * @param xOffset defines the x coordinates of the update rectangle
  46478. * @param yOffset defines the y coordinates of the update rectangle
  46479. * @param width defines the width of the update rectangle
  46480. * @param height defines the height of the update rectangle
  46481. * @param faceIndex defines the face index if texture is a cube (0 by default)
  46482. * @param lod defines the lod level to update (0 by default)
  46483. */
  46484. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  46485. /**
  46486. * Update a video texture
  46487. * @param texture defines the texture to update
  46488. * @param video defines the video element to use
  46489. * @param invertY defines if data must be stored with Y axis inverted
  46490. */
  46491. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  46492. /** @hidden */
  46493. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46494. /** @hidden */
  46495. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  46496. /** @hidden */
  46497. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46498. /** @hidden */
  46499. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  46500. /**
  46501. * Update a raw texture
  46502. * @param texture defines the texture to update
  46503. * @param bufferView defines the data to store in the texture
  46504. * @param format defines the format of the data
  46505. * @param invertY defines if data must be stored with Y axis inverted
  46506. * @param compression defines the compression used (null by default)
  46507. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  46508. */
  46509. updateRawTexture(texture: Nullable<InternalTexture>, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  46510. /**
  46511. * Update a raw cube texture
  46512. * @param texture defines the texture to update
  46513. * @param bufferView defines the data to store
  46514. * @param format defines the data format
  46515. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  46516. * @param invertY defines if data must be stored with Y axis inverted
  46517. * @param compression defines the compression used (null by default)
  46518. * @param level defines which level of the texture to update
  46519. */
  46520. updateRawCubeTexture(texture: InternalTexture, bufferView: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  46521. /**
  46522. * Update a raw 2D array texture
  46523. * @param texture defines the texture to update
  46524. * @param bufferView defines the data to store
  46525. * @param format defines the data format
  46526. * @param invertY defines if data must be stored with Y axis inverted
  46527. * @param compression defines the used compression (can be null)
  46528. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  46529. */
  46530. updateRawTexture2DArray(texture: InternalTexture, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  46531. /**
  46532. * Update a raw 3D texture
  46533. * @param texture defines the texture to update
  46534. * @param bufferView defines the data to store
  46535. * @param format defines the data format
  46536. * @param invertY defines if data must be stored with Y axis inverted
  46537. * @param compression defines the used compression (can be null)
  46538. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  46539. */
  46540. updateRawTexture3D(texture: InternalTexture, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  46541. /**
  46542. * Reads pixels from the current frame buffer. Please note that this function can be slow
  46543. * @param x defines the x coordinate of the rectangle where pixels must be read
  46544. * @param y defines the y coordinate of the rectangle where pixels must be read
  46545. * @param width defines the width of the rectangle where pixels must be read
  46546. * @param height defines the height of the rectangle where pixels must be read
  46547. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  46548. * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels
  46549. * @returns a ArrayBufferView promise (Uint8Array) containing RGBA colors
  46550. */
  46551. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean, flushRenderer?: boolean): Promise<ArrayBufferView>;
  46552. /** @hidden */
  46553. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Promise<ArrayBufferView>;
  46554. /** @hidden */
  46555. _readTexturePixelsSync(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): ArrayBufferView;
  46556. /**
  46557. * Creates a new render target texture
  46558. * @param size defines the size of the texture
  46559. * @param options defines the options used to create the texture
  46560. * @returns a new render target texture stored in an InternalTexture
  46561. */
  46562. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  46563. /**
  46564. * Create a multi render target texture
  46565. * @param size defines the size of the texture
  46566. * @param options defines the creation options
  46567. * @returns the cube texture as an InternalTexture
  46568. */
  46569. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  46570. /**
  46571. * Creates a new render target cube texture
  46572. * @param size defines the size of the texture
  46573. * @param options defines the options used to create the texture
  46574. * @returns a new render target cube texture stored in an InternalTexture
  46575. */
  46576. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  46577. /** @hidden */
  46578. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  46579. width: number;
  46580. height: number;
  46581. layers?: number;
  46582. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number, samples?: number): void;
  46583. /** @hidden */
  46584. _createDepthStencilTexture(size: number | {
  46585. width: number;
  46586. height: number;
  46587. layers?: number;
  46588. }, options: DepthTextureCreationOptions): InternalTexture;
  46589. /** @hidden */
  46590. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  46591. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  46592. /**
  46593. * Update the sample count for a given multiple render target texture
  46594. * @param textures defines the textures to update
  46595. * @param samples defines the sample count to set
  46596. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  46597. */
  46598. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  46599. /**
  46600. * Begin a new frame
  46601. */
  46602. beginFrame(): void;
  46603. /**
  46604. * End the current frame
  46605. */
  46606. endFrame(): void;
  46607. /**
  46608. * Force a WebGPU flush (ie. a flush of all waiting commands)
  46609. */
  46610. flushFramebuffer(): void;
  46611. private _startRenderTargetRenderPass;
  46612. private _endRenderTargetRenderPass;
  46613. private _getCurrentRenderPass;
  46614. private _startMainRenderPass;
  46615. private _endMainRenderPass;
  46616. /**
  46617. * Restores the WebGPU state to only draw on the main color attachment
  46618. */
  46619. restoreSingleAttachment(): void;
  46620. /**
  46621. * Creates a layout object to draw/clear on specific textures in a MRT
  46622. * @param textureStatus textureStatus[i] indicates if the i-th is active
  46623. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  46624. */
  46625. buildTextureLayout(textureStatus: boolean[]): number[];
  46626. /**
  46627. * Select a subsets of attachments to draw to.
  46628. * @param attachments index of attachments
  46629. */
  46630. bindAttachments(attachments: number[]): void;
  46631. /**
  46632. * Binds the frame buffer to the specified texture.
  46633. * @param texture The texture to render to or null for the default canvas
  46634. * @param faceIndex The face of the texture to render to in case of cube texture
  46635. * @param requiredWidth The width of the target to render to
  46636. * @param requiredHeight The height of the target to render to
  46637. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  46638. * @param lodLevel defines the lod level to bind to the frame buffer
  46639. * @param layer defines the 2d array index to bind to frame buffer to
  46640. */
  46641. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  46642. /**
  46643. * Unbind the current render target texture from the WebGPU context
  46644. * @param texture defines the render target texture to unbind
  46645. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46646. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46647. */
  46648. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46649. /**
  46650. * Unbind a list of render target textures from the WebGPU context
  46651. * @param textures defines the render target textures to unbind
  46652. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46653. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46654. */
  46655. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46656. /**
  46657. * Unbind the current render target and bind the default framebuffer
  46658. */
  46659. restoreDefaultFramebuffer(): void;
  46660. private _setColorFormat;
  46661. private _setDepthTextureFormat;
  46662. setDitheringState(value: boolean): void;
  46663. setRasterizerState(value: boolean): void;
  46664. /**
  46665. * Set various states to the context
  46666. * @param culling defines backface culling state
  46667. * @param zOffset defines the value to apply to zOffset (0 by default)
  46668. * @param force defines if states must be applied even if cache is up to date
  46669. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  46670. */
  46671. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46672. /**
  46673. * Sets the current alpha mode
  46674. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  46675. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  46676. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46677. */
  46678. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  46679. /**
  46680. * Sets the current alpha equation
  46681. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  46682. */
  46683. setAlphaEquation(equation: number): void;
  46684. private _getBindGroupsToRender;
  46685. private _bindVertexInputs;
  46686. private _setRenderBindGroups;
  46687. private _setRenderPipeline;
  46688. /**
  46689. * Draw a list of indexed primitives
  46690. * @param fillMode defines the primitive to use
  46691. * @param indexStart defines the starting index
  46692. * @param indexCount defines the number of index to draw
  46693. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  46694. */
  46695. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46696. /**
  46697. * Draw a list of unindexed primitives
  46698. * @param fillMode defines the primitive to use
  46699. * @param verticesStart defines the index of first vertex to draw
  46700. * @param verticesCount defines the count of vertices to draw
  46701. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  46702. */
  46703. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46704. private _bundleEncoder;
  46705. /**
  46706. * Start recording all the gpu calls into a bundle.
  46707. */
  46708. startRecordBundle(): void;
  46709. /**
  46710. * Stops recording the bundle.
  46711. * @returns the recorded bundle
  46712. */
  46713. stopRecordBundle(): GPURenderBundle;
  46714. /**
  46715. * Execute the previously recorded bundle.
  46716. * @param bundles defines the bundle to replay
  46717. */
  46718. executeBundles(bundles: GPURenderBundle[]): void;
  46719. /**
  46720. * Dispose and release all associated resources
  46721. */
  46722. dispose(): void;
  46723. /**
  46724. * Gets the current render width
  46725. * @param useScreen defines if screen size must be used (or the current render target if any)
  46726. * @returns a number defining the current render width
  46727. */
  46728. getRenderWidth(useScreen?: boolean): number;
  46729. /**
  46730. * Gets the current render height
  46731. * @param useScreen defines if screen size must be used (or the current render target if any)
  46732. * @returns a number defining the current render height
  46733. */
  46734. getRenderHeight(useScreen?: boolean): number;
  46735. /**
  46736. * Gets the HTML canvas attached with the current WebGPU context
  46737. * @returns a HTML canvas
  46738. */
  46739. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  46740. /** @hidden */
  46741. _debugPushGroup(groupName: string, targetObject?: number): void;
  46742. /** @hidden */
  46743. _debugPopGroup(targetObject?: number): void;
  46744. /** @hidden */
  46745. _debugInsertMarker(text: string, targetObject?: number): void;
  46746. private _debugFlushPendingCommands;
  46747. /**
  46748. * Get the current error code of the WebGPU context
  46749. * @returns the error code
  46750. */
  46751. getError(): number;
  46752. /** @hidden */
  46753. bindSamplers(effect: Effect): void;
  46754. /** @hidden */
  46755. _bindTextureDirectly(target: number, texture: InternalTexture, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  46756. /** @hidden */
  46757. _releaseFramebufferObjects(texture: InternalTexture): void;
  46758. /** @hidden */
  46759. applyStates(): void;
  46760. /**
  46761. * Gets a boolean indicating if all created effects are ready
  46762. * @returns always true - No parallel shader compilation
  46763. */
  46764. areAllEffectsReady(): boolean;
  46765. /** @hidden */
  46766. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  46767. /** @hidden */
  46768. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  46769. /** @hidden */
  46770. _getUnpackAlignement(): number;
  46771. /** @hidden */
  46772. _unpackFlipY(value: boolean): void;
  46773. /** @hidden */
  46774. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  46775. min: number;
  46776. mag: number;
  46777. };
  46778. /** @hidden */
  46779. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  46780. /** @hidden */
  46781. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  46782. /** @hidden */
  46783. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  46784. /** @hidden */
  46785. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  46786. /** @hidden */
  46787. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  46788. /** @hidden */
  46789. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  46790. /** @hidden */
  46791. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  46792. /** @hidden */
  46793. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  46794. /** @hidden */
  46795. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  46796. /** @hidden */
  46797. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  46798. /** @hidden */
  46799. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  46800. /** @hidden */
  46801. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  46802. /** @hidden */
  46803. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  46804. /** @hidden */
  46805. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  46806. /** @hidden */
  46807. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  46808. /** @hidden */
  46809. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  46810. /** @hidden */
  46811. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  46812. }
  46813. }
  46814. declare module BABYLON {
  46815. /**
  46816. * Define an interface for all classes that will hold resources
  46817. */
  46818. export interface IDisposable {
  46819. /**
  46820. * Releases all held resources
  46821. */
  46822. dispose(): void;
  46823. }
  46824. /** Interface defining initialization parameters for Scene class */
  46825. export interface SceneOptions {
  46826. /**
  46827. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  46828. * It will improve performance when the number of geometries becomes important.
  46829. */
  46830. useGeometryUniqueIdsMap?: boolean;
  46831. /**
  46832. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  46833. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  46834. */
  46835. useMaterialMeshMap?: boolean;
  46836. /**
  46837. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  46838. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  46839. */
  46840. useClonedMeshMap?: boolean;
  46841. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  46842. virtual?: boolean;
  46843. }
  46844. /**
  46845. * Represents a scene to be rendered by the engine.
  46846. * @see https://doc.babylonjs.com/features/scene
  46847. */
  46848. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  46849. /** The fog is deactivated */
  46850. static readonly FOGMODE_NONE: number;
  46851. /** The fog density is following an exponential function */
  46852. static readonly FOGMODE_EXP: number;
  46853. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  46854. static readonly FOGMODE_EXP2: number;
  46855. /** The fog density is following a linear function. */
  46856. static readonly FOGMODE_LINEAR: number;
  46857. /**
  46858. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  46859. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46860. */
  46861. static MinDeltaTime: number;
  46862. /**
  46863. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  46864. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46865. */
  46866. static MaxDeltaTime: number;
  46867. /**
  46868. * Factory used to create the default material.
  46869. * @param name The name of the material to create
  46870. * @param scene The scene to create the material for
  46871. * @returns The default material
  46872. */
  46873. static DefaultMaterialFactory(scene: Scene): Material;
  46874. /**
  46875. * Factory used to create the a collision coordinator.
  46876. * @returns The collision coordinator
  46877. */
  46878. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  46879. /** @hidden */
  46880. _inputManager: InputManager;
  46881. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  46882. cameraToUseForPointers: Nullable<Camera>;
  46883. /** @hidden */
  46884. readonly _isScene: boolean;
  46885. /** @hidden */
  46886. _blockEntityCollection: boolean;
  46887. /**
  46888. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  46889. */
  46890. autoClear: boolean;
  46891. /**
  46892. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  46893. */
  46894. autoClearDepthAndStencil: boolean;
  46895. /**
  46896. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  46897. */
  46898. clearColor: Color4;
  46899. /**
  46900. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  46901. */
  46902. ambientColor: Color3;
  46903. /**
  46904. * This is use to store the default BRDF lookup for PBR materials in your scene.
  46905. * It should only be one of the following (if not the default embedded one):
  46906. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  46907. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  46908. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  46909. * The material properties need to be setup according to the type of texture in use.
  46910. */
  46911. environmentBRDFTexture: BaseTexture;
  46912. /**
  46913. * Texture used in all pbr material as the reflection texture.
  46914. * As in the majority of the scene they are the same (exception for multi room and so on),
  46915. * this is easier to reference from here than from all the materials.
  46916. */
  46917. get environmentTexture(): Nullable<BaseTexture>;
  46918. /**
  46919. * Texture used in all pbr material as the reflection texture.
  46920. * As in the majority of the scene they are the same (exception for multi room and so on),
  46921. * this is easier to set here than in all the materials.
  46922. */
  46923. set environmentTexture(value: Nullable<BaseTexture>);
  46924. /** @hidden */
  46925. protected _environmentIntensity: number;
  46926. /**
  46927. * Intensity of the environment in all pbr material.
  46928. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  46929. * As in the majority of the scene they are the same (exception for multi room and so on),
  46930. * this is easier to reference from here than from all the materials.
  46931. */
  46932. get environmentIntensity(): number;
  46933. /**
  46934. * Intensity of the environment in all pbr material.
  46935. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  46936. * As in the majority of the scene they are the same (exception for multi room and so on),
  46937. * this is easier to set here than in all the materials.
  46938. */
  46939. set environmentIntensity(value: number);
  46940. /** @hidden */
  46941. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  46942. /**
  46943. * Default image processing configuration used either in the rendering
  46944. * Forward main pass or through the imageProcessingPostProcess if present.
  46945. * As in the majority of the scene they are the same (exception for multi camera),
  46946. * this is easier to reference from here than from all the materials and post process.
  46947. *
  46948. * No setter as we it is a shared configuration, you can set the values instead.
  46949. */
  46950. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  46951. private _forceWireframe;
  46952. /**
  46953. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  46954. */
  46955. set forceWireframe(value: boolean);
  46956. get forceWireframe(): boolean;
  46957. private _skipFrustumClipping;
  46958. /**
  46959. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  46960. */
  46961. set skipFrustumClipping(value: boolean);
  46962. get skipFrustumClipping(): boolean;
  46963. private _forcePointsCloud;
  46964. /**
  46965. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  46966. */
  46967. set forcePointsCloud(value: boolean);
  46968. get forcePointsCloud(): boolean;
  46969. /**
  46970. * Gets or sets the active clipplane 1
  46971. */
  46972. clipPlane: Nullable<Plane>;
  46973. /**
  46974. * Gets or sets the active clipplane 2
  46975. */
  46976. clipPlane2: Nullable<Plane>;
  46977. /**
  46978. * Gets or sets the active clipplane 3
  46979. */
  46980. clipPlane3: Nullable<Plane>;
  46981. /**
  46982. * Gets or sets the active clipplane 4
  46983. */
  46984. clipPlane4: Nullable<Plane>;
  46985. /**
  46986. * Gets or sets the active clipplane 5
  46987. */
  46988. clipPlane5: Nullable<Plane>;
  46989. /**
  46990. * Gets or sets the active clipplane 6
  46991. */
  46992. clipPlane6: Nullable<Plane>;
  46993. /**
  46994. * Gets or sets a boolean indicating if animations are enabled
  46995. */
  46996. animationsEnabled: boolean;
  46997. private _animationPropertiesOverride;
  46998. /**
  46999. * Gets or sets the animation properties override
  47000. */
  47001. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  47002. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  47003. /**
  47004. * Gets or sets a boolean indicating if a constant deltatime has to be used
  47005. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  47006. */
  47007. useConstantAnimationDeltaTime: boolean;
  47008. /**
  47009. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  47010. * Please note that it requires to run a ray cast through the scene on every frame
  47011. */
  47012. constantlyUpdateMeshUnderPointer: boolean;
  47013. /**
  47014. * Defines the HTML cursor to use when hovering over interactive elements
  47015. */
  47016. hoverCursor: string;
  47017. /**
  47018. * Defines the HTML default cursor to use (empty by default)
  47019. */
  47020. defaultCursor: string;
  47021. /**
  47022. * Defines whether cursors are handled by the scene.
  47023. */
  47024. doNotHandleCursors: boolean;
  47025. /**
  47026. * This is used to call preventDefault() on pointer down
  47027. * in order to block unwanted artifacts like system double clicks
  47028. */
  47029. preventDefaultOnPointerDown: boolean;
  47030. /**
  47031. * This is used to call preventDefault() on pointer up
  47032. * in order to block unwanted artifacts like system double clicks
  47033. */
  47034. preventDefaultOnPointerUp: boolean;
  47035. /**
  47036. * Gets or sets user defined metadata
  47037. */
  47038. metadata: any;
  47039. /**
  47040. * For internal use only. Please do not use.
  47041. */
  47042. reservedDataStore: any;
  47043. /**
  47044. * Gets the name of the plugin used to load this scene (null by default)
  47045. */
  47046. loadingPluginName: string;
  47047. /**
  47048. * Use this array to add regular expressions used to disable offline support for specific urls
  47049. */
  47050. disableOfflineSupportExceptionRules: RegExp[];
  47051. /**
  47052. * An event triggered when the scene is disposed.
  47053. */
  47054. onDisposeObservable: Observable<Scene>;
  47055. private _onDisposeObserver;
  47056. /** Sets a function to be executed when this scene is disposed. */
  47057. set onDispose(callback: () => void);
  47058. /**
  47059. * An event triggered before rendering the scene (right after animations and physics)
  47060. */
  47061. onBeforeRenderObservable: Observable<Scene>;
  47062. private _onBeforeRenderObserver;
  47063. /** Sets a function to be executed before rendering this scene */
  47064. set beforeRender(callback: Nullable<() => void>);
  47065. /**
  47066. * An event triggered after rendering the scene
  47067. */
  47068. onAfterRenderObservable: Observable<Scene>;
  47069. /**
  47070. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  47071. */
  47072. onAfterRenderCameraObservable: Observable<Camera>;
  47073. private _onAfterRenderObserver;
  47074. /** Sets a function to be executed after rendering this scene */
  47075. set afterRender(callback: Nullable<() => void>);
  47076. /**
  47077. * An event triggered before animating the scene
  47078. */
  47079. onBeforeAnimationsObservable: Observable<Scene>;
  47080. /**
  47081. * An event triggered after animations processing
  47082. */
  47083. onAfterAnimationsObservable: Observable<Scene>;
  47084. /**
  47085. * An event triggered before draw calls are ready to be sent
  47086. */
  47087. onBeforeDrawPhaseObservable: Observable<Scene>;
  47088. /**
  47089. * An event triggered after draw calls have been sent
  47090. */
  47091. onAfterDrawPhaseObservable: Observable<Scene>;
  47092. /**
  47093. * An event triggered when the scene is ready
  47094. */
  47095. onReadyObservable: Observable<Scene>;
  47096. /**
  47097. * An event triggered before rendering a camera
  47098. */
  47099. onBeforeCameraRenderObservable: Observable<Camera>;
  47100. private _onBeforeCameraRenderObserver;
  47101. /** Sets a function to be executed before rendering a camera*/
  47102. set beforeCameraRender(callback: () => void);
  47103. /**
  47104. * An event triggered after rendering a camera
  47105. */
  47106. onAfterCameraRenderObservable: Observable<Camera>;
  47107. private _onAfterCameraRenderObserver;
  47108. /** Sets a function to be executed after rendering a camera*/
  47109. set afterCameraRender(callback: () => void);
  47110. /**
  47111. * An event triggered when active meshes evaluation is about to start
  47112. */
  47113. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  47114. /**
  47115. * An event triggered when active meshes evaluation is done
  47116. */
  47117. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  47118. /**
  47119. * An event triggered when particles rendering is about to start
  47120. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  47121. */
  47122. onBeforeParticlesRenderingObservable: Observable<Scene>;
  47123. /**
  47124. * An event triggered when particles rendering is done
  47125. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  47126. */
  47127. onAfterParticlesRenderingObservable: Observable<Scene>;
  47128. /**
  47129. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  47130. */
  47131. onDataLoadedObservable: Observable<Scene>;
  47132. /**
  47133. * An event triggered when a camera is created
  47134. */
  47135. onNewCameraAddedObservable: Observable<Camera>;
  47136. /**
  47137. * An event triggered when a camera is removed
  47138. */
  47139. onCameraRemovedObservable: Observable<Camera>;
  47140. /**
  47141. * An event triggered when a light is created
  47142. */
  47143. onNewLightAddedObservable: Observable<Light>;
  47144. /**
  47145. * An event triggered when a light is removed
  47146. */
  47147. onLightRemovedObservable: Observable<Light>;
  47148. /**
  47149. * An event triggered when a geometry is created
  47150. */
  47151. onNewGeometryAddedObservable: Observable<Geometry>;
  47152. /**
  47153. * An event triggered when a geometry is removed
  47154. */
  47155. onGeometryRemovedObservable: Observable<Geometry>;
  47156. /**
  47157. * An event triggered when a transform node is created
  47158. */
  47159. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  47160. /**
  47161. * An event triggered when a transform node is removed
  47162. */
  47163. onTransformNodeRemovedObservable: Observable<TransformNode>;
  47164. /**
  47165. * An event triggered when a mesh is created
  47166. */
  47167. onNewMeshAddedObservable: Observable<AbstractMesh>;
  47168. /**
  47169. * An event triggered when a mesh is removed
  47170. */
  47171. onMeshRemovedObservable: Observable<AbstractMesh>;
  47172. /**
  47173. * An event triggered when a skeleton is created
  47174. */
  47175. onNewSkeletonAddedObservable: Observable<Skeleton>;
  47176. /**
  47177. * An event triggered when a skeleton is removed
  47178. */
  47179. onSkeletonRemovedObservable: Observable<Skeleton>;
  47180. /**
  47181. * An event triggered when a material is created
  47182. */
  47183. onNewMaterialAddedObservable: Observable<Material>;
  47184. /**
  47185. * An event triggered when a multi material is created
  47186. */
  47187. onNewMultiMaterialAddedObservable: Observable<MultiMaterial>;
  47188. /**
  47189. * An event triggered when a material is removed
  47190. */
  47191. onMaterialRemovedObservable: Observable<Material>;
  47192. /**
  47193. * An event triggered when a multi material is removed
  47194. */
  47195. onMultiMaterialRemovedObservable: Observable<MultiMaterial>;
  47196. /**
  47197. * An event triggered when a texture is created
  47198. */
  47199. onNewTextureAddedObservable: Observable<BaseTexture>;
  47200. /**
  47201. * An event triggered when a texture is removed
  47202. */
  47203. onTextureRemovedObservable: Observable<BaseTexture>;
  47204. /**
  47205. * An event triggered when render targets are about to be rendered
  47206. * Can happen multiple times per frame.
  47207. */
  47208. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  47209. /**
  47210. * An event triggered when render targets were rendered.
  47211. * Can happen multiple times per frame.
  47212. */
  47213. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  47214. /**
  47215. * An event triggered before calculating deterministic simulation step
  47216. */
  47217. onBeforeStepObservable: Observable<Scene>;
  47218. /**
  47219. * An event triggered after calculating deterministic simulation step
  47220. */
  47221. onAfterStepObservable: Observable<Scene>;
  47222. /**
  47223. * An event triggered when the activeCamera property is updated
  47224. */
  47225. onActiveCameraChanged: Observable<Scene>;
  47226. /**
  47227. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  47228. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  47229. * 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)
  47230. */
  47231. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  47232. /**
  47233. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  47234. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  47235. * 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)
  47236. */
  47237. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  47238. /**
  47239. * This Observable will when a mesh has been imported into the scene.
  47240. */
  47241. onMeshImportedObservable: Observable<AbstractMesh>;
  47242. /**
  47243. * This Observable will when an animation file has been imported into the scene.
  47244. */
  47245. onAnimationFileImportedObservable: Observable<Scene>;
  47246. /**
  47247. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  47248. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  47249. */
  47250. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  47251. /** @hidden */
  47252. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  47253. /**
  47254. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  47255. */
  47256. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  47257. /**
  47258. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  47259. */
  47260. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  47261. /**
  47262. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  47263. */
  47264. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  47265. /** Callback called when a pointer move is detected */
  47266. onPointerMove: (evt: IPointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  47267. /** Callback called when a pointer down is detected */
  47268. onPointerDown: (evt: IPointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  47269. /** Callback called when a pointer up is detected */
  47270. onPointerUp: (evt: IPointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  47271. /** Callback called when a pointer pick is detected */
  47272. onPointerPick: (evt: IPointerEvent, pickInfo: PickingInfo) => void;
  47273. /**
  47274. * 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).
  47275. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  47276. */
  47277. onPrePointerObservable: Observable<PointerInfoPre>;
  47278. /**
  47279. * Observable event triggered each time an input event is received from the rendering canvas
  47280. */
  47281. onPointerObservable: Observable<PointerInfo>;
  47282. /**
  47283. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  47284. */
  47285. get unTranslatedPointer(): Vector2;
  47286. /**
  47287. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  47288. */
  47289. static get DragMovementThreshold(): number;
  47290. static set DragMovementThreshold(value: number);
  47291. /**
  47292. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  47293. */
  47294. static get LongPressDelay(): number;
  47295. static set LongPressDelay(value: number);
  47296. /**
  47297. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  47298. */
  47299. static get DoubleClickDelay(): number;
  47300. static set DoubleClickDelay(value: number);
  47301. /** If you need to check double click without raising a single click at first click, enable this flag */
  47302. static get ExclusiveDoubleClickMode(): boolean;
  47303. static set ExclusiveDoubleClickMode(value: boolean);
  47304. /** @hidden */
  47305. _mirroredCameraPosition: Nullable<Vector3>;
  47306. /**
  47307. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  47308. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  47309. */
  47310. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  47311. /**
  47312. * Observable event triggered each time an keyboard event is received from the hosting window
  47313. */
  47314. onKeyboardObservable: Observable<KeyboardInfo>;
  47315. private _useRightHandedSystem;
  47316. /**
  47317. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  47318. */
  47319. set useRightHandedSystem(value: boolean);
  47320. get useRightHandedSystem(): boolean;
  47321. private _timeAccumulator;
  47322. private _currentStepId;
  47323. private _currentInternalStep;
  47324. /**
  47325. * Sets the step Id used by deterministic lock step
  47326. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47327. * @param newStepId defines the step Id
  47328. */
  47329. setStepId(newStepId: number): void;
  47330. /**
  47331. * Gets the step Id used by deterministic lock step
  47332. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47333. * @returns the step Id
  47334. */
  47335. getStepId(): number;
  47336. /**
  47337. * Gets the internal step used by deterministic lock step
  47338. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47339. * @returns the internal step
  47340. */
  47341. getInternalStep(): number;
  47342. private _fogEnabled;
  47343. /**
  47344. * Gets or sets a boolean indicating if fog is enabled on this scene
  47345. * @see https://doc.babylonjs.com/babylon101/environment#fog
  47346. * (Default is true)
  47347. */
  47348. set fogEnabled(value: boolean);
  47349. get fogEnabled(): boolean;
  47350. private _fogMode;
  47351. /**
  47352. * Gets or sets the fog mode to use
  47353. * @see https://doc.babylonjs.com/babylon101/environment#fog
  47354. * | mode | value |
  47355. * | --- | --- |
  47356. * | FOGMODE_NONE | 0 |
  47357. * | FOGMODE_EXP | 1 |
  47358. * | FOGMODE_EXP2 | 2 |
  47359. * | FOGMODE_LINEAR | 3 |
  47360. */
  47361. set fogMode(value: number);
  47362. get fogMode(): number;
  47363. /**
  47364. * Gets or sets the fog color to use
  47365. * @see https://doc.babylonjs.com/babylon101/environment#fog
  47366. * (Default is Color3(0.2, 0.2, 0.3))
  47367. */
  47368. fogColor: Color3;
  47369. /**
  47370. * Gets or sets the fog density to use
  47371. * @see https://doc.babylonjs.com/babylon101/environment#fog
  47372. * (Default is 0.1)
  47373. */
  47374. fogDensity: number;
  47375. /**
  47376. * Gets or sets the fog start distance to use
  47377. * @see https://doc.babylonjs.com/babylon101/environment#fog
  47378. * (Default is 0)
  47379. */
  47380. fogStart: number;
  47381. /**
  47382. * Gets or sets the fog end distance to use
  47383. * @see https://doc.babylonjs.com/babylon101/environment#fog
  47384. * (Default is 1000)
  47385. */
  47386. fogEnd: number;
  47387. /**
  47388. * Flag indicating that the frame buffer binding is handled by another component
  47389. */
  47390. get prePass(): boolean;
  47391. private _shadowsEnabled;
  47392. /**
  47393. * Gets or sets a boolean indicating if shadows are enabled on this scene
  47394. */
  47395. set shadowsEnabled(value: boolean);
  47396. get shadowsEnabled(): boolean;
  47397. private _lightsEnabled;
  47398. /**
  47399. * Gets or sets a boolean indicating if lights are enabled on this scene
  47400. */
  47401. set lightsEnabled(value: boolean);
  47402. get lightsEnabled(): boolean;
  47403. /** All of the active cameras added to this scene. */
  47404. activeCameras: Nullable<Camera[]>;
  47405. /** @hidden */
  47406. _activeCamera: Nullable<Camera>;
  47407. /** Gets or sets the current active camera */
  47408. get activeCamera(): Nullable<Camera>;
  47409. set activeCamera(value: Nullable<Camera>);
  47410. private _defaultMaterial;
  47411. /** The default material used on meshes when no material is affected */
  47412. get defaultMaterial(): Material;
  47413. /** The default material used on meshes when no material is affected */
  47414. set defaultMaterial(value: Material);
  47415. private _texturesEnabled;
  47416. /**
  47417. * Gets or sets a boolean indicating if textures are enabled on this scene
  47418. */
  47419. set texturesEnabled(value: boolean);
  47420. get texturesEnabled(): boolean;
  47421. /**
  47422. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  47423. */
  47424. physicsEnabled: boolean;
  47425. /**
  47426. * Gets or sets a boolean indicating if particles are enabled on this scene
  47427. */
  47428. particlesEnabled: boolean;
  47429. /**
  47430. * Gets or sets a boolean indicating if sprites are enabled on this scene
  47431. */
  47432. spritesEnabled: boolean;
  47433. private _skeletonsEnabled;
  47434. /**
  47435. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  47436. */
  47437. set skeletonsEnabled(value: boolean);
  47438. get skeletonsEnabled(): boolean;
  47439. /**
  47440. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  47441. */
  47442. lensFlaresEnabled: boolean;
  47443. /**
  47444. * Gets or sets a boolean indicating if collisions are enabled on this scene
  47445. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  47446. */
  47447. collisionsEnabled: boolean;
  47448. private _collisionCoordinator;
  47449. /** @hidden */
  47450. get collisionCoordinator(): ICollisionCoordinator;
  47451. /**
  47452. * Defines the gravity applied to this scene (used only for collisions)
  47453. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  47454. */
  47455. gravity: Vector3;
  47456. /**
  47457. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  47458. */
  47459. postProcessesEnabled: boolean;
  47460. /**
  47461. * Gets the current postprocess manager
  47462. */
  47463. postProcessManager: PostProcessManager;
  47464. /**
  47465. * Gets or sets a boolean indicating if render targets are enabled on this scene
  47466. */
  47467. renderTargetsEnabled: boolean;
  47468. /**
  47469. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  47470. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  47471. */
  47472. dumpNextRenderTargets: boolean;
  47473. /**
  47474. * The list of user defined render targets added to the scene
  47475. */
  47476. customRenderTargets: RenderTargetTexture[];
  47477. /**
  47478. * Defines if texture loading must be delayed
  47479. * If true, textures will only be loaded when they need to be rendered
  47480. */
  47481. useDelayedTextureLoading: boolean;
  47482. /**
  47483. * Gets the list of meshes imported to the scene through SceneLoader
  47484. */
  47485. importedMeshesFiles: String[];
  47486. /**
  47487. * Gets or sets a boolean indicating if probes are enabled on this scene
  47488. */
  47489. probesEnabled: boolean;
  47490. /**
  47491. * Gets or sets the current offline provider to use to store scene data
  47492. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  47493. */
  47494. offlineProvider: IOfflineProvider;
  47495. /**
  47496. * Gets or sets the action manager associated with the scene
  47497. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  47498. */
  47499. actionManager: AbstractActionManager;
  47500. private _meshesForIntersections;
  47501. /**
  47502. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  47503. */
  47504. proceduralTexturesEnabled: boolean;
  47505. private _engine;
  47506. private _totalVertices;
  47507. /** @hidden */
  47508. _activeIndices: PerfCounter;
  47509. /** @hidden */
  47510. _activeParticles: PerfCounter;
  47511. /** @hidden */
  47512. _activeBones: PerfCounter;
  47513. private _animationRatio;
  47514. /** @hidden */
  47515. _animationTimeLast: number;
  47516. /** @hidden */
  47517. _animationTime: number;
  47518. /**
  47519. * Gets or sets a general scale for animation speed
  47520. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  47521. */
  47522. animationTimeScale: number;
  47523. /** @hidden */
  47524. _cachedMaterial: Nullable<Material>;
  47525. /** @hidden */
  47526. _cachedEffect: Nullable<Effect>;
  47527. /** @hidden */
  47528. _cachedVisibility: Nullable<number>;
  47529. private _renderId;
  47530. private _frameId;
  47531. private _executeWhenReadyTimeoutId;
  47532. private _intermediateRendering;
  47533. private _viewUpdateFlag;
  47534. private _projectionUpdateFlag;
  47535. /** @hidden */
  47536. _toBeDisposed: Nullable<IDisposable>[];
  47537. private _activeRequests;
  47538. /** @hidden */
  47539. _pendingData: any[];
  47540. private _isDisposed;
  47541. /**
  47542. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  47543. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  47544. */
  47545. dispatchAllSubMeshesOfActiveMeshes: boolean;
  47546. private _activeMeshes;
  47547. private _processedMaterials;
  47548. private _renderTargets;
  47549. /** @hidden */
  47550. _activeParticleSystems: SmartArray<IParticleSystem>;
  47551. private _activeSkeletons;
  47552. private _softwareSkinnedMeshes;
  47553. private _renderingManager;
  47554. /** @hidden */
  47555. _activeAnimatables: Animatable[];
  47556. private _transformMatrix;
  47557. private _sceneUbo;
  47558. /** @hidden */
  47559. _viewMatrix: Matrix;
  47560. /** @hidden */
  47561. _projectionMatrix: Matrix;
  47562. /** @hidden */
  47563. _forcedViewPosition: Nullable<Vector3>;
  47564. /** @hidden */
  47565. _frustumPlanes: Plane[];
  47566. /**
  47567. * Gets the list of frustum planes (built from the active camera)
  47568. */
  47569. get frustumPlanes(): Plane[];
  47570. /**
  47571. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  47572. * This is useful if there are more lights that the maximum simulteanous authorized
  47573. */
  47574. requireLightSorting: boolean;
  47575. /** @hidden */
  47576. readonly useMaterialMeshMap: boolean;
  47577. /** @hidden */
  47578. readonly useClonedMeshMap: boolean;
  47579. private _externalData;
  47580. private _uid;
  47581. /**
  47582. * @hidden
  47583. * Backing store of defined scene components.
  47584. */
  47585. _components: ISceneComponent[];
  47586. /**
  47587. * @hidden
  47588. * Backing store of defined scene components.
  47589. */
  47590. _serializableComponents: ISceneSerializableComponent[];
  47591. /**
  47592. * List of components to register on the next registration step.
  47593. */
  47594. private _transientComponents;
  47595. /**
  47596. * Registers the transient components if needed.
  47597. */
  47598. private _registerTransientComponents;
  47599. /**
  47600. * @hidden
  47601. * Add a component to the scene.
  47602. * Note that the ccomponent could be registered on th next frame if this is called after
  47603. * the register component stage.
  47604. * @param component Defines the component to add to the scene
  47605. */
  47606. _addComponent(component: ISceneComponent): void;
  47607. /**
  47608. * @hidden
  47609. * Gets a component from the scene.
  47610. * @param name defines the name of the component to retrieve
  47611. * @returns the component or null if not present
  47612. */
  47613. _getComponent(name: string): Nullable<ISceneComponent>;
  47614. /**
  47615. * @hidden
  47616. * Defines the actions happening before camera updates.
  47617. */
  47618. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  47619. /**
  47620. * @hidden
  47621. * Defines the actions happening before clear the canvas.
  47622. */
  47623. _beforeClearStage: Stage<SimpleStageAction>;
  47624. /**
  47625. * @hidden
  47626. * Defines the actions happening before clear the canvas.
  47627. */
  47628. _beforeRenderTargetClearStage: Stage<RenderTargetStageAction>;
  47629. /**
  47630. * @hidden
  47631. * Defines the actions when collecting render targets for the frame.
  47632. */
  47633. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  47634. /**
  47635. * @hidden
  47636. * Defines the actions happening for one camera in the frame.
  47637. */
  47638. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  47639. /**
  47640. * @hidden
  47641. * Defines the actions happening during the per mesh ready checks.
  47642. */
  47643. _isReadyForMeshStage: Stage<MeshStageAction>;
  47644. /**
  47645. * @hidden
  47646. * Defines the actions happening before evaluate active mesh checks.
  47647. */
  47648. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  47649. /**
  47650. * @hidden
  47651. * Defines the actions happening during the evaluate sub mesh checks.
  47652. */
  47653. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  47654. /**
  47655. * @hidden
  47656. * Defines the actions happening during the active mesh stage.
  47657. */
  47658. _preActiveMeshStage: Stage<PreActiveMeshStageAction>;
  47659. /**
  47660. * @hidden
  47661. * Defines the actions happening during the per camera render target step.
  47662. */
  47663. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  47664. /**
  47665. * @hidden
  47666. * Defines the actions happening just before the active camera is drawing.
  47667. */
  47668. _beforeCameraDrawStage: Stage<CameraStageAction>;
  47669. /**
  47670. * @hidden
  47671. * Defines the actions happening just before a render target is drawing.
  47672. */
  47673. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  47674. /**
  47675. * @hidden
  47676. * Defines the actions happening just before a rendering group is drawing.
  47677. */
  47678. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  47679. /**
  47680. * @hidden
  47681. * Defines the actions happening just before a mesh is drawing.
  47682. */
  47683. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  47684. /**
  47685. * @hidden
  47686. * Defines the actions happening just after a mesh has been drawn.
  47687. */
  47688. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  47689. /**
  47690. * @hidden
  47691. * Defines the actions happening just after a rendering group has been drawn.
  47692. */
  47693. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  47694. /**
  47695. * @hidden
  47696. * Defines the actions happening just after the active camera has been drawn.
  47697. */
  47698. _afterCameraDrawStage: Stage<CameraStageAction>;
  47699. /**
  47700. * @hidden
  47701. * Defines the actions happening just after a render target has been drawn.
  47702. */
  47703. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  47704. /**
  47705. * @hidden
  47706. * Defines the actions happening just after rendering all cameras and computing intersections.
  47707. */
  47708. _afterRenderStage: Stage<SimpleStageAction>;
  47709. /**
  47710. * @hidden
  47711. * Defines the actions happening when a pointer move event happens.
  47712. */
  47713. _pointerMoveStage: Stage<PointerMoveStageAction>;
  47714. /**
  47715. * @hidden
  47716. * Defines the actions happening when a pointer down event happens.
  47717. */
  47718. _pointerDownStage: Stage<PointerUpDownStageAction>;
  47719. /**
  47720. * @hidden
  47721. * Defines the actions happening when a pointer up event happens.
  47722. */
  47723. _pointerUpStage: Stage<PointerUpDownStageAction>;
  47724. /**
  47725. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  47726. */
  47727. private geometriesByUniqueId;
  47728. private _renderBundles;
  47729. /**
  47730. * Creates a new Scene
  47731. * @param engine defines the engine to use to render this scene
  47732. * @param options defines the scene options
  47733. */
  47734. constructor(engine: Engine, options?: SceneOptions);
  47735. /**
  47736. * Gets a string identifying the name of the class
  47737. * @returns "Scene" string
  47738. */
  47739. getClassName(): string;
  47740. private _defaultMeshCandidates;
  47741. /**
  47742. * @hidden
  47743. */
  47744. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  47745. private _defaultSubMeshCandidates;
  47746. /**
  47747. * @hidden
  47748. */
  47749. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  47750. /**
  47751. * Sets the default candidate providers for the scene.
  47752. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  47753. * and getCollidingSubMeshCandidates to their default function
  47754. */
  47755. setDefaultCandidateProviders(): void;
  47756. /**
  47757. * Gets the mesh that is currently under the pointer
  47758. */
  47759. get meshUnderPointer(): Nullable<AbstractMesh>;
  47760. /**
  47761. * Gets or sets the current on-screen X position of the pointer
  47762. */
  47763. get pointerX(): number;
  47764. set pointerX(value: number);
  47765. /**
  47766. * Gets or sets the current on-screen Y position of the pointer
  47767. */
  47768. get pointerY(): number;
  47769. set pointerY(value: number);
  47770. /**
  47771. * Gets the cached material (ie. the latest rendered one)
  47772. * @returns the cached material
  47773. */
  47774. getCachedMaterial(): Nullable<Material>;
  47775. /**
  47776. * Gets the cached effect (ie. the latest rendered one)
  47777. * @returns the cached effect
  47778. */
  47779. getCachedEffect(): Nullable<Effect>;
  47780. /**
  47781. * Gets the cached visibility state (ie. the latest rendered one)
  47782. * @returns the cached visibility state
  47783. */
  47784. getCachedVisibility(): Nullable<number>;
  47785. /**
  47786. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  47787. * @param material defines the current material
  47788. * @param effect defines the current effect
  47789. * @param visibility defines the current visibility state
  47790. * @returns true if one parameter is not cached
  47791. */
  47792. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  47793. /**
  47794. * Gets the engine associated with the scene
  47795. * @returns an Engine
  47796. */
  47797. getEngine(): Engine;
  47798. /**
  47799. * Gets the total number of vertices rendered per frame
  47800. * @returns the total number of vertices rendered per frame
  47801. */
  47802. getTotalVertices(): number;
  47803. /**
  47804. * Gets the performance counter for total vertices
  47805. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  47806. */
  47807. get totalVerticesPerfCounter(): PerfCounter;
  47808. /**
  47809. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  47810. * @returns the total number of active indices rendered per frame
  47811. */
  47812. getActiveIndices(): number;
  47813. /**
  47814. * Gets the performance counter for active indices
  47815. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  47816. */
  47817. get totalActiveIndicesPerfCounter(): PerfCounter;
  47818. /**
  47819. * Gets the total number of active particles rendered per frame
  47820. * @returns the total number of active particles rendered per frame
  47821. */
  47822. getActiveParticles(): number;
  47823. /**
  47824. * Gets the performance counter for active particles
  47825. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  47826. */
  47827. get activeParticlesPerfCounter(): PerfCounter;
  47828. /**
  47829. * Gets the total number of active bones rendered per frame
  47830. * @returns the total number of active bones rendered per frame
  47831. */
  47832. getActiveBones(): number;
  47833. /**
  47834. * Gets the performance counter for active bones
  47835. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  47836. */
  47837. get activeBonesPerfCounter(): PerfCounter;
  47838. /**
  47839. * Gets the array of active meshes
  47840. * @returns an array of AbstractMesh
  47841. */
  47842. getActiveMeshes(): SmartArray<AbstractMesh>;
  47843. /**
  47844. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  47845. * @returns a number
  47846. */
  47847. getAnimationRatio(): number;
  47848. /**
  47849. * Gets an unique Id for the current render phase
  47850. * @returns a number
  47851. */
  47852. getRenderId(): number;
  47853. /**
  47854. * Gets an unique Id for the current frame
  47855. * @returns a number
  47856. */
  47857. getFrameId(): number;
  47858. /** Call this function if you want to manually increment the render Id*/
  47859. incrementRenderId(): void;
  47860. private _createUbo;
  47861. /**
  47862. * Use this method to simulate a pointer move on a mesh
  47863. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  47864. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  47865. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  47866. * @returns the current scene
  47867. */
  47868. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  47869. /**
  47870. * Use this method to simulate a pointer down on a mesh
  47871. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  47872. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  47873. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  47874. * @returns the current scene
  47875. */
  47876. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  47877. /**
  47878. * Use this method to simulate a pointer up on a mesh
  47879. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  47880. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  47881. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  47882. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  47883. * @returns the current scene
  47884. */
  47885. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  47886. /**
  47887. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  47888. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  47889. * @returns true if the pointer was captured
  47890. */
  47891. isPointerCaptured(pointerId?: number): boolean;
  47892. /**
  47893. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  47894. * @param attachUp defines if you want to attach events to pointerup
  47895. * @param attachDown defines if you want to attach events to pointerdown
  47896. * @param attachMove defines if you want to attach events to pointermove
  47897. */
  47898. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  47899. /** Detaches all event handlers*/
  47900. detachControl(): void;
  47901. /**
  47902. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  47903. * Delay loaded resources are not taking in account
  47904. * @return true if all required resources are ready
  47905. */
  47906. isReady(): boolean;
  47907. /** Resets all cached information relative to material (including effect and visibility) */
  47908. resetCachedMaterial(): void;
  47909. /**
  47910. * Registers a function to be called before every frame render
  47911. * @param func defines the function to register
  47912. */
  47913. registerBeforeRender(func: () => void): void;
  47914. /**
  47915. * Unregisters a function called before every frame render
  47916. * @param func defines the function to unregister
  47917. */
  47918. unregisterBeforeRender(func: () => void): void;
  47919. /**
  47920. * Registers a function to be called after every frame render
  47921. * @param func defines the function to register
  47922. */
  47923. registerAfterRender(func: () => void): void;
  47924. /**
  47925. * Unregisters a function called after every frame render
  47926. * @param func defines the function to unregister
  47927. */
  47928. unregisterAfterRender(func: () => void): void;
  47929. private _executeOnceBeforeRender;
  47930. /**
  47931. * The provided function will run before render once and will be disposed afterwards.
  47932. * A timeout delay can be provided so that the function will be executed in N ms.
  47933. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  47934. * @param func The function to be executed.
  47935. * @param timeout optional delay in ms
  47936. */
  47937. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  47938. /** @hidden */
  47939. _addPendingData(data: any): void;
  47940. /** @hidden */
  47941. _removePendingData(data: any): void;
  47942. /**
  47943. * Returns the number of items waiting to be loaded
  47944. * @returns the number of items waiting to be loaded
  47945. */
  47946. getWaitingItemsCount(): number;
  47947. /**
  47948. * Returns a boolean indicating if the scene is still loading data
  47949. */
  47950. get isLoading(): boolean;
  47951. /**
  47952. * Registers a function to be executed when the scene is ready
  47953. * @param {Function} func - the function to be executed
  47954. */
  47955. executeWhenReady(func: () => void): void;
  47956. /**
  47957. * Returns a promise that resolves when the scene is ready
  47958. * @returns A promise that resolves when the scene is ready
  47959. */
  47960. whenReadyAsync(): Promise<void>;
  47961. /** @hidden */
  47962. _checkIsReady(): void;
  47963. /**
  47964. * Gets all animatable attached to the scene
  47965. */
  47966. get animatables(): Animatable[];
  47967. /**
  47968. * Resets the last animation time frame.
  47969. * Useful to override when animations start running when loading a scene for the first time.
  47970. */
  47971. resetLastAnimationTimeFrame(): void;
  47972. /**
  47973. * Gets the current view matrix
  47974. * @returns a Matrix
  47975. */
  47976. getViewMatrix(): Matrix;
  47977. /**
  47978. * Gets the current projection matrix
  47979. * @returns a Matrix
  47980. */
  47981. getProjectionMatrix(): Matrix;
  47982. /**
  47983. * Gets the current transform matrix
  47984. * @returns a Matrix made of View * Projection
  47985. */
  47986. getTransformMatrix(): Matrix;
  47987. /**
  47988. * Sets the current transform matrix
  47989. * @param viewL defines the View matrix to use
  47990. * @param projectionL defines the Projection matrix to use
  47991. * @param viewR defines the right View matrix to use (if provided)
  47992. * @param projectionR defines the right Projection matrix to use (if provided)
  47993. */
  47994. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  47995. /**
  47996. * Gets the uniform buffer used to store scene data
  47997. * @returns a UniformBuffer
  47998. */
  47999. getSceneUniformBuffer(): UniformBuffer;
  48000. /**
  48001. * Gets an unique (relatively to the current scene) Id
  48002. * @returns an unique number for the scene
  48003. */
  48004. getUniqueId(): number;
  48005. /**
  48006. * Add a mesh to the list of scene's meshes
  48007. * @param newMesh defines the mesh to add
  48008. * @param recursive if all child meshes should also be added to the scene
  48009. */
  48010. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  48011. /**
  48012. * Remove a mesh for the list of scene's meshes
  48013. * @param toRemove defines the mesh to remove
  48014. * @param recursive if all child meshes should also be removed from the scene
  48015. * @returns the index where the mesh was in the mesh list
  48016. */
  48017. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  48018. /**
  48019. * Add a transform node to the list of scene's transform nodes
  48020. * @param newTransformNode defines the transform node to add
  48021. */
  48022. addTransformNode(newTransformNode: TransformNode): void;
  48023. /**
  48024. * Remove a transform node for the list of scene's transform nodes
  48025. * @param toRemove defines the transform node to remove
  48026. * @returns the index where the transform node was in the transform node list
  48027. */
  48028. removeTransformNode(toRemove: TransformNode): number;
  48029. /**
  48030. * Remove a skeleton for the list of scene's skeletons
  48031. * @param toRemove defines the skeleton to remove
  48032. * @returns the index where the skeleton was in the skeleton list
  48033. */
  48034. removeSkeleton(toRemove: Skeleton): number;
  48035. /**
  48036. * Remove a morph target for the list of scene's morph targets
  48037. * @param toRemove defines the morph target to remove
  48038. * @returns the index where the morph target was in the morph target list
  48039. */
  48040. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  48041. /**
  48042. * Remove a light for the list of scene's lights
  48043. * @param toRemove defines the light to remove
  48044. * @returns the index where the light was in the light list
  48045. */
  48046. removeLight(toRemove: Light): number;
  48047. /**
  48048. * Remove a camera for the list of scene's cameras
  48049. * @param toRemove defines the camera to remove
  48050. * @returns the index where the camera was in the camera list
  48051. */
  48052. removeCamera(toRemove: Camera): number;
  48053. /**
  48054. * Remove a particle system for the list of scene's particle systems
  48055. * @param toRemove defines the particle system to remove
  48056. * @returns the index where the particle system was in the particle system list
  48057. */
  48058. removeParticleSystem(toRemove: IParticleSystem): number;
  48059. /**
  48060. * Remove a animation for the list of scene's animations
  48061. * @param toRemove defines the animation to remove
  48062. * @returns the index where the animation was in the animation list
  48063. */
  48064. removeAnimation(toRemove: Animation): number;
  48065. /**
  48066. * Will stop the animation of the given target
  48067. * @param target - the target
  48068. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  48069. * @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)
  48070. */
  48071. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  48072. /**
  48073. * Removes the given animation group from this scene.
  48074. * @param toRemove The animation group to remove
  48075. * @returns The index of the removed animation group
  48076. */
  48077. removeAnimationGroup(toRemove: AnimationGroup): number;
  48078. /**
  48079. * Removes the given multi-material from this scene.
  48080. * @param toRemove The multi-material to remove
  48081. * @returns The index of the removed multi-material
  48082. */
  48083. removeMultiMaterial(toRemove: MultiMaterial): number;
  48084. /**
  48085. * Removes the given material from this scene.
  48086. * @param toRemove The material to remove
  48087. * @returns The index of the removed material
  48088. */
  48089. removeMaterial(toRemove: Material): number;
  48090. /**
  48091. * Removes the given action manager from this scene.
  48092. * @param toRemove The action manager to remove
  48093. * @returns The index of the removed action manager
  48094. */
  48095. removeActionManager(toRemove: AbstractActionManager): number;
  48096. /**
  48097. * Removes the given texture from this scene.
  48098. * @param toRemove The texture to remove
  48099. * @returns The index of the removed texture
  48100. */
  48101. removeTexture(toRemove: BaseTexture): number;
  48102. /**
  48103. * Adds the given light to this scene
  48104. * @param newLight The light to add
  48105. */
  48106. addLight(newLight: Light): void;
  48107. /**
  48108. * Sorts the list list based on light priorities
  48109. */
  48110. sortLightsByPriority(): void;
  48111. /**
  48112. * Adds the given camera to this scene
  48113. * @param newCamera The camera to add
  48114. */
  48115. addCamera(newCamera: Camera): void;
  48116. /**
  48117. * Adds the given skeleton to this scene
  48118. * @param newSkeleton The skeleton to add
  48119. */
  48120. addSkeleton(newSkeleton: Skeleton): void;
  48121. /**
  48122. * Adds the given particle system to this scene
  48123. * @param newParticleSystem The particle system to add
  48124. */
  48125. addParticleSystem(newParticleSystem: IParticleSystem): void;
  48126. /**
  48127. * Adds the given animation to this scene
  48128. * @param newAnimation The animation to add
  48129. */
  48130. addAnimation(newAnimation: Animation): void;
  48131. /**
  48132. * Adds the given animation group to this scene.
  48133. * @param newAnimationGroup The animation group to add
  48134. */
  48135. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  48136. /**
  48137. * Adds the given multi-material to this scene
  48138. * @param newMultiMaterial The multi-material to add
  48139. */
  48140. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  48141. /**
  48142. * Adds the given material to this scene
  48143. * @param newMaterial The material to add
  48144. */
  48145. addMaterial(newMaterial: Material): void;
  48146. /**
  48147. * Adds the given morph target to this scene
  48148. * @param newMorphTargetManager The morph target to add
  48149. */
  48150. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  48151. /**
  48152. * Adds the given geometry to this scene
  48153. * @param newGeometry The geometry to add
  48154. */
  48155. addGeometry(newGeometry: Geometry): void;
  48156. /**
  48157. * Adds the given action manager to this scene
  48158. * @param newActionManager The action manager to add
  48159. */
  48160. addActionManager(newActionManager: AbstractActionManager): void;
  48161. /**
  48162. * Adds the given texture to this scene.
  48163. * @param newTexture The texture to add
  48164. */
  48165. addTexture(newTexture: BaseTexture): void;
  48166. /**
  48167. * Switch active camera
  48168. * @param newCamera defines the new active camera
  48169. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  48170. */
  48171. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  48172. /**
  48173. * sets the active camera of the scene using its ID
  48174. * @param id defines the camera's ID
  48175. * @return the new active camera or null if none found.
  48176. */
  48177. setActiveCameraByID(id: string): Nullable<Camera>;
  48178. /**
  48179. * sets the active camera of the scene using its name
  48180. * @param name defines the camera's name
  48181. * @returns the new active camera or null if none found.
  48182. */
  48183. setActiveCameraByName(name: string): Nullable<Camera>;
  48184. /**
  48185. * get an animation group using its name
  48186. * @param name defines the material's name
  48187. * @return the animation group or null if none found.
  48188. */
  48189. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  48190. /**
  48191. * Get a material using its unique id
  48192. * @param uniqueId defines the material's unique id
  48193. * @return the material or null if none found.
  48194. */
  48195. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  48196. /**
  48197. * get a material using its id
  48198. * @param id defines the material's ID
  48199. * @return the material or null if none found.
  48200. */
  48201. getMaterialByID(id: string): Nullable<Material>;
  48202. /**
  48203. * Gets a the last added material using a given id
  48204. * @param id defines the material's ID
  48205. * @return the last material with the given id or null if none found.
  48206. */
  48207. getLastMaterialByID(id: string): Nullable<Material>;
  48208. /**
  48209. * Gets a material using its name
  48210. * @param name defines the material's name
  48211. * @return the material or null if none found.
  48212. */
  48213. getMaterialByName(name: string): Nullable<Material>;
  48214. /**
  48215. * Get a texture using its unique id
  48216. * @param uniqueId defines the texture's unique id
  48217. * @return the texture or null if none found.
  48218. */
  48219. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  48220. /**
  48221. * Gets a camera using its id
  48222. * @param id defines the id to look for
  48223. * @returns the camera or null if not found
  48224. */
  48225. getCameraByID(id: string): Nullable<Camera>;
  48226. /**
  48227. * Gets a camera using its unique id
  48228. * @param uniqueId defines the unique id to look for
  48229. * @returns the camera or null if not found
  48230. */
  48231. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  48232. /**
  48233. * Gets a camera using its name
  48234. * @param name defines the camera's name
  48235. * @return the camera or null if none found.
  48236. */
  48237. getCameraByName(name: string): Nullable<Camera>;
  48238. /**
  48239. * Gets a bone using its id
  48240. * @param id defines the bone's id
  48241. * @return the bone or null if not found
  48242. */
  48243. getBoneByID(id: string): Nullable<Bone>;
  48244. /**
  48245. * Gets a bone using its id
  48246. * @param name defines the bone's name
  48247. * @return the bone or null if not found
  48248. */
  48249. getBoneByName(name: string): Nullable<Bone>;
  48250. /**
  48251. * Gets a light node using its name
  48252. * @param name defines the the light's name
  48253. * @return the light or null if none found.
  48254. */
  48255. getLightByName(name: string): Nullable<Light>;
  48256. /**
  48257. * Gets a light node using its id
  48258. * @param id defines the light's id
  48259. * @return the light or null if none found.
  48260. */
  48261. getLightByID(id: string): Nullable<Light>;
  48262. /**
  48263. * Gets a light node using its scene-generated unique ID
  48264. * @param uniqueId defines the light's unique id
  48265. * @return the light or null if none found.
  48266. */
  48267. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  48268. /**
  48269. * Gets a particle system by id
  48270. * @param id defines the particle system id
  48271. * @return the corresponding system or null if none found
  48272. */
  48273. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  48274. /**
  48275. * Gets a geometry using its ID
  48276. * @param id defines the geometry's id
  48277. * @return the geometry or null if none found.
  48278. */
  48279. getGeometryByID(id: string): Nullable<Geometry>;
  48280. private _getGeometryByUniqueID;
  48281. /**
  48282. * Add a new geometry to this scene
  48283. * @param geometry defines the geometry to be added to the scene.
  48284. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  48285. * @return a boolean defining if the geometry was added or not
  48286. */
  48287. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  48288. /**
  48289. * Removes an existing geometry
  48290. * @param geometry defines the geometry to be removed from the scene
  48291. * @return a boolean defining if the geometry was removed or not
  48292. */
  48293. removeGeometry(geometry: Geometry): boolean;
  48294. /**
  48295. * Gets the list of geometries attached to the scene
  48296. * @returns an array of Geometry
  48297. */
  48298. getGeometries(): Geometry[];
  48299. /**
  48300. * Gets the first added mesh found of a given ID
  48301. * @param id defines the id to search for
  48302. * @return the mesh found or null if not found at all
  48303. */
  48304. getMeshByID(id: string): Nullable<AbstractMesh>;
  48305. /**
  48306. * Gets a list of meshes using their id
  48307. * @param id defines the id to search for
  48308. * @returns a list of meshes
  48309. */
  48310. getMeshesByID(id: string): Array<AbstractMesh>;
  48311. /**
  48312. * Gets the first added transform node found of a given ID
  48313. * @param id defines the id to search for
  48314. * @return the found transform node or null if not found at all.
  48315. */
  48316. getTransformNodeByID(id: string): Nullable<TransformNode>;
  48317. /**
  48318. * Gets a transform node with its auto-generated unique id
  48319. * @param uniqueId efines the unique id to search for
  48320. * @return the found transform node or null if not found at all.
  48321. */
  48322. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  48323. /**
  48324. * Gets a list of transform nodes using their id
  48325. * @param id defines the id to search for
  48326. * @returns a list of transform nodes
  48327. */
  48328. getTransformNodesByID(id: string): Array<TransformNode>;
  48329. /**
  48330. * Gets a mesh with its auto-generated unique id
  48331. * @param uniqueId defines the unique id to search for
  48332. * @return the found mesh or null if not found at all.
  48333. */
  48334. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  48335. /**
  48336. * Gets a the last added mesh using a given id
  48337. * @param id defines the id to search for
  48338. * @return the found mesh or null if not found at all.
  48339. */
  48340. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  48341. /**
  48342. * Gets a the last added node (Mesh, Camera, Light) using a given id
  48343. * @param id defines the id to search for
  48344. * @return the found node or null if not found at all
  48345. */
  48346. getLastEntryByID(id: string): Nullable<Node>;
  48347. /**
  48348. * Gets a node (Mesh, Camera, Light) using a given id
  48349. * @param id defines the id to search for
  48350. * @return the found node or null if not found at all
  48351. */
  48352. getNodeByID(id: string): Nullable<Node>;
  48353. /**
  48354. * Gets a node (Mesh, Camera, Light) using a given name
  48355. * @param name defines the name to search for
  48356. * @return the found node or null if not found at all.
  48357. */
  48358. getNodeByName(name: string): Nullable<Node>;
  48359. /**
  48360. * Gets a mesh using a given name
  48361. * @param name defines the name to search for
  48362. * @return the found mesh or null if not found at all.
  48363. */
  48364. getMeshByName(name: string): Nullable<AbstractMesh>;
  48365. /**
  48366. * Gets a transform node using a given name
  48367. * @param name defines the name to search for
  48368. * @return the found transform node or null if not found at all.
  48369. */
  48370. getTransformNodeByName(name: string): Nullable<TransformNode>;
  48371. /**
  48372. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  48373. * @param id defines the id to search for
  48374. * @return the found skeleton or null if not found at all.
  48375. */
  48376. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  48377. /**
  48378. * Gets a skeleton using a given auto generated unique id
  48379. * @param uniqueId defines the unique id to search for
  48380. * @return the found skeleton or null if not found at all.
  48381. */
  48382. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  48383. /**
  48384. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  48385. * @param id defines the id to search for
  48386. * @return the found skeleton or null if not found at all.
  48387. */
  48388. getSkeletonById(id: string): Nullable<Skeleton>;
  48389. /**
  48390. * Gets a skeleton using a given name
  48391. * @param name defines the name to search for
  48392. * @return the found skeleton or null if not found at all.
  48393. */
  48394. getSkeletonByName(name: string): Nullable<Skeleton>;
  48395. /**
  48396. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  48397. * @param id defines the id to search for
  48398. * @return the found morph target manager or null if not found at all.
  48399. */
  48400. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  48401. /**
  48402. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  48403. * @param id defines the id to search for
  48404. * @return the found morph target or null if not found at all.
  48405. */
  48406. getMorphTargetById(id: string): Nullable<MorphTarget>;
  48407. /**
  48408. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  48409. * @param name defines the name to search for
  48410. * @return the found morph target or null if not found at all.
  48411. */
  48412. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  48413. /**
  48414. * Gets a post process using a given name (if many are found, this function will pick the first one)
  48415. * @param name defines the name to search for
  48416. * @return the found post process or null if not found at all.
  48417. */
  48418. getPostProcessByName(name: string): Nullable<PostProcess>;
  48419. /**
  48420. * Gets a boolean indicating if the given mesh is active
  48421. * @param mesh defines the mesh to look for
  48422. * @returns true if the mesh is in the active list
  48423. */
  48424. isActiveMesh(mesh: AbstractMesh): boolean;
  48425. /**
  48426. * Return a unique id as a string which can serve as an identifier for the scene
  48427. */
  48428. get uid(): string;
  48429. /**
  48430. * Add an externaly attached data from its key.
  48431. * This method call will fail and return false, if such key already exists.
  48432. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  48433. * @param key the unique key that identifies the data
  48434. * @param data the data object to associate to the key for this Engine instance
  48435. * @return true if no such key were already present and the data was added successfully, false otherwise
  48436. */
  48437. addExternalData<T>(key: string, data: T): boolean;
  48438. /**
  48439. * Get an externaly attached data from its key
  48440. * @param key the unique key that identifies the data
  48441. * @return the associated data, if present (can be null), or undefined if not present
  48442. */
  48443. getExternalData<T>(key: string): Nullable<T>;
  48444. /**
  48445. * Get an externaly attached data from its key, create it using a factory if it's not already present
  48446. * @param key the unique key that identifies the data
  48447. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  48448. * @return the associated data, can be null if the factory returned null.
  48449. */
  48450. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  48451. /**
  48452. * Remove an externaly attached data from the Engine instance
  48453. * @param key the unique key that identifies the data
  48454. * @return true if the data was successfully removed, false if it doesn't exist
  48455. */
  48456. removeExternalData(key: string): boolean;
  48457. private _evaluateSubMesh;
  48458. /**
  48459. * Clear the processed materials smart array preventing retention point in material dispose.
  48460. */
  48461. freeProcessedMaterials(): void;
  48462. private _preventFreeActiveMeshesAndRenderingGroups;
  48463. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  48464. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  48465. * when disposing several meshes in a row or a hierarchy of meshes.
  48466. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  48467. */
  48468. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  48469. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  48470. /**
  48471. * Clear the active meshes smart array preventing retention point in mesh dispose.
  48472. */
  48473. freeActiveMeshes(): void;
  48474. /**
  48475. * Clear the info related to rendering groups preventing retention points during dispose.
  48476. */
  48477. freeRenderingGroups(): void;
  48478. /** @hidden */
  48479. _isInIntermediateRendering(): boolean;
  48480. /**
  48481. * Lambda returning the list of potentially active meshes.
  48482. */
  48483. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  48484. /**
  48485. * Lambda returning the list of potentially active sub meshes.
  48486. */
  48487. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  48488. /**
  48489. * Lambda returning the list of potentially intersecting sub meshes.
  48490. */
  48491. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  48492. /**
  48493. * Lambda returning the list of potentially colliding sub meshes.
  48494. */
  48495. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  48496. /** @hidden */
  48497. _activeMeshesFrozen: boolean;
  48498. private _skipEvaluateActiveMeshesCompletely;
  48499. /**
  48500. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  48501. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  48502. * @param onSuccess optional success callback
  48503. * @param onError optional error callback
  48504. * @returns the current scene
  48505. */
  48506. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  48507. /**
  48508. * Use this function to restart evaluating active meshes on every frame
  48509. * @returns the current scene
  48510. */
  48511. unfreezeActiveMeshes(): Scene;
  48512. private _evaluateActiveMeshes;
  48513. private _activeMesh;
  48514. /**
  48515. * Update the transform matrix to update from the current active camera
  48516. * @param force defines a boolean used to force the update even if cache is up to date
  48517. */
  48518. updateTransformMatrix(force?: boolean): void;
  48519. private _bindFrameBuffer;
  48520. /** @hidden */
  48521. _allowPostProcessClearColor: boolean;
  48522. /** @hidden */
  48523. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  48524. private _processSubCameras;
  48525. private _checkIntersections;
  48526. /** @hidden */
  48527. _advancePhysicsEngineStep(step: number): void;
  48528. /**
  48529. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  48530. */
  48531. getDeterministicFrameTime: () => number;
  48532. /** @hidden */
  48533. _animate(): void;
  48534. /** Execute all animations (for a frame) */
  48535. animate(): void;
  48536. /**
  48537. * Render the scene
  48538. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  48539. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  48540. */
  48541. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  48542. /**
  48543. * Freeze all materials
  48544. * A frozen material will not be updatable but should be faster to render
  48545. */
  48546. freezeMaterials(): void;
  48547. /**
  48548. * Unfreeze all materials
  48549. * A frozen material will not be updatable but should be faster to render
  48550. */
  48551. unfreezeMaterials(): void;
  48552. /**
  48553. * Releases all held ressources
  48554. */
  48555. dispose(): void;
  48556. /**
  48557. * Gets if the scene is already disposed
  48558. */
  48559. get isDisposed(): boolean;
  48560. /**
  48561. * Call this function to reduce memory footprint of the scene.
  48562. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  48563. */
  48564. clearCachedVertexData(): void;
  48565. /**
  48566. * This function will remove the local cached buffer data from texture.
  48567. * It will save memory but will prevent the texture from being rebuilt
  48568. */
  48569. cleanCachedTextureBuffer(): void;
  48570. /**
  48571. * Get the world extend vectors with an optional filter
  48572. *
  48573. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  48574. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  48575. */
  48576. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  48577. min: Vector3;
  48578. max: Vector3;
  48579. };
  48580. /**
  48581. * Creates a ray that can be used to pick in the scene
  48582. * @param x defines the x coordinate of the origin (on-screen)
  48583. * @param y defines the y coordinate of the origin (on-screen)
  48584. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  48585. * @param camera defines the camera to use for the picking
  48586. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  48587. * @returns a Ray
  48588. */
  48589. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  48590. /**
  48591. * Creates a ray that can be used to pick in the scene
  48592. * @param x defines the x coordinate of the origin (on-screen)
  48593. * @param y defines the y coordinate of the origin (on-screen)
  48594. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  48595. * @param result defines the ray where to store the picking ray
  48596. * @param camera defines the camera to use for the picking
  48597. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  48598. * @returns the current scene
  48599. */
  48600. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  48601. /**
  48602. * Creates a ray that can be used to pick in the scene
  48603. * @param x defines the x coordinate of the origin (on-screen)
  48604. * @param y defines the y coordinate of the origin (on-screen)
  48605. * @param camera defines the camera to use for the picking
  48606. * @returns a Ray
  48607. */
  48608. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  48609. /**
  48610. * Creates a ray that can be used to pick in the scene
  48611. * @param x defines the x coordinate of the origin (on-screen)
  48612. * @param y defines the y coordinate of the origin (on-screen)
  48613. * @param result defines the ray where to store the picking ray
  48614. * @param camera defines the camera to use for the picking
  48615. * @returns the current scene
  48616. */
  48617. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  48618. /** Launch a ray to try to pick a mesh in the scene
  48619. * @param x position on screen
  48620. * @param y position on screen
  48621. * @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
  48622. * @param fastCheck defines if the first intersection will be used (and not the closest)
  48623. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  48624. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  48625. * @returns a PickingInfo
  48626. */
  48627. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  48628. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  48629. * @param x position on screen
  48630. * @param y position on screen
  48631. * @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
  48632. * @param fastCheck defines if the first intersection will be used (and not the closest)
  48633. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  48634. * @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)
  48635. */
  48636. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  48637. /** Use the given ray to pick a mesh in the scene
  48638. * @param ray The ray to use to pick meshes
  48639. * @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
  48640. * @param fastCheck defines if the first intersection will be used (and not the closest)
  48641. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  48642. * @returns a PickingInfo
  48643. */
  48644. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  48645. /**
  48646. * Launch a ray to try to pick a mesh in the scene
  48647. * @param x X position on screen
  48648. * @param y Y position on screen
  48649. * @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
  48650. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  48651. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  48652. * @returns an array of PickingInfo
  48653. */
  48654. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  48655. /**
  48656. * Launch a ray to try to pick a mesh in the scene
  48657. * @param ray Ray to use
  48658. * @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
  48659. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  48660. * @returns an array of PickingInfo
  48661. */
  48662. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  48663. /**
  48664. * Force the value of meshUnderPointer
  48665. * @param mesh defines the mesh to use
  48666. * @param pointerId optional pointer id when using more than one pointer
  48667. */
  48668. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  48669. /**
  48670. * Gets the mesh under the pointer
  48671. * @returns a Mesh or null if no mesh is under the pointer
  48672. */
  48673. getPointerOverMesh(): Nullable<AbstractMesh>;
  48674. /** @hidden */
  48675. _rebuildGeometries(): void;
  48676. /** @hidden */
  48677. _rebuildTextures(): void;
  48678. private _getByTags;
  48679. /**
  48680. * Get a list of meshes by tags
  48681. * @param tagsQuery defines the tags query to use
  48682. * @param forEach defines a predicate used to filter results
  48683. * @returns an array of Mesh
  48684. */
  48685. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  48686. /**
  48687. * Get a list of cameras by tags
  48688. * @param tagsQuery defines the tags query to use
  48689. * @param forEach defines a predicate used to filter results
  48690. * @returns an array of Camera
  48691. */
  48692. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  48693. /**
  48694. * Get a list of lights by tags
  48695. * @param tagsQuery defines the tags query to use
  48696. * @param forEach defines a predicate used to filter results
  48697. * @returns an array of Light
  48698. */
  48699. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  48700. /**
  48701. * Get a list of materials by tags
  48702. * @param tagsQuery defines the tags query to use
  48703. * @param forEach defines a predicate used to filter results
  48704. * @returns an array of Material
  48705. */
  48706. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  48707. /**
  48708. * Get a list of transform nodes by tags
  48709. * @param tagsQuery defines the tags query to use
  48710. * @param forEach defines a predicate used to filter results
  48711. * @returns an array of TransformNode
  48712. */
  48713. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  48714. /**
  48715. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  48716. * This allowed control for front to back rendering or reversly depending of the special needs.
  48717. *
  48718. * @param renderingGroupId The rendering group id corresponding to its index
  48719. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  48720. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  48721. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  48722. */
  48723. 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;
  48724. /**
  48725. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  48726. *
  48727. * @param renderingGroupId The rendering group id corresponding to its index
  48728. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  48729. * @param depth Automatically clears depth between groups if true and autoClear is true.
  48730. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  48731. */
  48732. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  48733. /**
  48734. * Gets the current auto clear configuration for one rendering group of the rendering
  48735. * manager.
  48736. * @param index the rendering group index to get the information for
  48737. * @returns The auto clear setup for the requested rendering group
  48738. */
  48739. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  48740. private _blockMaterialDirtyMechanism;
  48741. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  48742. get blockMaterialDirtyMechanism(): boolean;
  48743. set blockMaterialDirtyMechanism(value: boolean);
  48744. /**
  48745. * Will flag all materials as dirty to trigger new shader compilation
  48746. * @param flag defines the flag used to specify which material part must be marked as dirty
  48747. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  48748. */
  48749. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  48750. /** @hidden */
  48751. _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;
  48752. /** @hidden */
  48753. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  48754. /** @hidden */
  48755. _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;
  48756. /** @hidden */
  48757. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  48758. /** @hidden */
  48759. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  48760. /** @hidden */
  48761. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  48762. }
  48763. }
  48764. declare module BABYLON {
  48765. /**
  48766. * Set of assets to keep when moving a scene into an asset container.
  48767. */
  48768. export class KeepAssets extends AbstractScene {
  48769. }
  48770. /**
  48771. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  48772. */
  48773. export class InstantiatedEntries {
  48774. /**
  48775. * List of new root nodes (eg. nodes with no parent)
  48776. */
  48777. rootNodes: TransformNode[];
  48778. /**
  48779. * List of new skeletons
  48780. */
  48781. skeletons: Skeleton[];
  48782. /**
  48783. * List of new animation groups
  48784. */
  48785. animationGroups: AnimationGroup[];
  48786. }
  48787. /**
  48788. * Container with a set of assets that can be added or removed from a scene.
  48789. */
  48790. export class AssetContainer extends AbstractScene {
  48791. private _wasAddedToScene;
  48792. /**
  48793. * The scene the AssetContainer belongs to.
  48794. */
  48795. scene: Scene;
  48796. /**
  48797. * Instantiates an AssetContainer.
  48798. * @param scene The scene the AssetContainer belongs to.
  48799. */
  48800. constructor(scene: Scene);
  48801. /**
  48802. * Instantiate or clone all meshes and add the new ones to the scene.
  48803. * Skeletons and animation groups will all be cloned
  48804. * @param nameFunction defines an optional function used to get new names for clones
  48805. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  48806. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  48807. */
  48808. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  48809. /**
  48810. * Adds all the assets from the container to the scene.
  48811. */
  48812. addAllToScene(): void;
  48813. /**
  48814. * Removes all the assets in the container from the scene
  48815. */
  48816. removeAllFromScene(): void;
  48817. /**
  48818. * Disposes all the assets in the container
  48819. */
  48820. dispose(): void;
  48821. private _moveAssets;
  48822. /**
  48823. * Removes all the assets contained in the scene and adds them to the container.
  48824. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  48825. */
  48826. moveAllFromScene(keepAssets?: KeepAssets): void;
  48827. /**
  48828. * 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.
  48829. * @returns the root mesh
  48830. */
  48831. createRootMesh(): Mesh;
  48832. /**
  48833. * Merge animations (direct and animation groups) from this asset container into a scene
  48834. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48835. * @param animatables set of animatables to retarget to a node from the scene
  48836. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  48837. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  48838. */
  48839. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  48840. }
  48841. }
  48842. declare module BABYLON {
  48843. /**
  48844. * Defines how the parser contract is defined.
  48845. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  48846. */
  48847. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  48848. /**
  48849. * Defines how the individual parser contract is defined.
  48850. * These parser can parse an individual asset
  48851. */
  48852. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  48853. /**
  48854. * Base class of the scene acting as a container for the different elements composing a scene.
  48855. * This class is dynamically extended by the different components of the scene increasing
  48856. * flexibility and reducing coupling
  48857. */
  48858. export abstract class AbstractScene {
  48859. /**
  48860. * Stores the list of available parsers in the application.
  48861. */
  48862. private static _BabylonFileParsers;
  48863. /**
  48864. * Stores the list of available individual parsers in the application.
  48865. */
  48866. private static _IndividualBabylonFileParsers;
  48867. /**
  48868. * Adds a parser in the list of available ones
  48869. * @param name Defines the name of the parser
  48870. * @param parser Defines the parser to add
  48871. */
  48872. static AddParser(name: string, parser: BabylonFileParser): void;
  48873. /**
  48874. * Gets a general parser from the list of avaialble ones
  48875. * @param name Defines the name of the parser
  48876. * @returns the requested parser or null
  48877. */
  48878. static GetParser(name: string): Nullable<BabylonFileParser>;
  48879. /**
  48880. * Adds n individual parser in the list of available ones
  48881. * @param name Defines the name of the parser
  48882. * @param parser Defines the parser to add
  48883. */
  48884. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  48885. /**
  48886. * Gets an individual parser from the list of avaialble ones
  48887. * @param name Defines the name of the parser
  48888. * @returns the requested parser or null
  48889. */
  48890. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  48891. /**
  48892. * Parser json data and populate both a scene and its associated container object
  48893. * @param jsonData Defines the data to parse
  48894. * @param scene Defines the scene to parse the data for
  48895. * @param container Defines the container attached to the parsing sequence
  48896. * @param rootUrl Defines the root url of the data
  48897. */
  48898. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  48899. /**
  48900. * Gets the list of root nodes (ie. nodes with no parent)
  48901. */
  48902. rootNodes: Node[];
  48903. /** All of the cameras added to this scene
  48904. * @see https://doc.babylonjs.com/babylon101/cameras
  48905. */
  48906. cameras: Camera[];
  48907. /**
  48908. * All of the lights added to this scene
  48909. * @see https://doc.babylonjs.com/babylon101/lights
  48910. */
  48911. lights: Light[];
  48912. /**
  48913. * All of the (abstract) meshes added to this scene
  48914. */
  48915. meshes: AbstractMesh[];
  48916. /**
  48917. * The list of skeletons added to the scene
  48918. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  48919. */
  48920. skeletons: Skeleton[];
  48921. /**
  48922. * All of the particle systems added to this scene
  48923. * @see https://doc.babylonjs.com/babylon101/particles
  48924. */
  48925. particleSystems: IParticleSystem[];
  48926. /**
  48927. * Gets a list of Animations associated with the scene
  48928. */
  48929. animations: Animation[];
  48930. /**
  48931. * All of the animation groups added to this scene
  48932. * @see https://doc.babylonjs.com/how_to/group
  48933. */
  48934. animationGroups: AnimationGroup[];
  48935. /**
  48936. * All of the multi-materials added to this scene
  48937. * @see https://doc.babylonjs.com/how_to/multi_materials
  48938. */
  48939. multiMaterials: MultiMaterial[];
  48940. /**
  48941. * All of the materials added to this scene
  48942. * In the context of a Scene, it is not supposed to be modified manually.
  48943. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  48944. * Note also that the order of the Material within the array is not significant and might change.
  48945. * @see https://doc.babylonjs.com/babylon101/materials
  48946. */
  48947. materials: Material[];
  48948. /**
  48949. * The list of morph target managers added to the scene
  48950. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  48951. */
  48952. morphTargetManagers: MorphTargetManager[];
  48953. /**
  48954. * The list of geometries used in the scene.
  48955. */
  48956. geometries: Geometry[];
  48957. /**
  48958. * All of the tranform nodes added to this scene
  48959. * In the context of a Scene, it is not supposed to be modified manually.
  48960. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  48961. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  48962. * @see https://doc.babylonjs.com/how_to/transformnode
  48963. */
  48964. transformNodes: TransformNode[];
  48965. /**
  48966. * ActionManagers available on the scene.
  48967. */
  48968. actionManagers: AbstractActionManager[];
  48969. /**
  48970. * Textures to keep.
  48971. */
  48972. textures: BaseTexture[];
  48973. /** @hidden */
  48974. protected _environmentTexture: Nullable<BaseTexture>;
  48975. /**
  48976. * Texture used in all pbr material as the reflection texture.
  48977. * As in the majority of the scene they are the same (exception for multi room and so on),
  48978. * this is easier to reference from here than from all the materials.
  48979. */
  48980. get environmentTexture(): Nullable<BaseTexture>;
  48981. set environmentTexture(value: Nullable<BaseTexture>);
  48982. /**
  48983. * The list of postprocesses added to the scene
  48984. */
  48985. postProcesses: PostProcess[];
  48986. /**
  48987. * @returns all meshes, lights, cameras, transformNodes and bones
  48988. */
  48989. getNodes(): Array<Node>;
  48990. }
  48991. }
  48992. declare module BABYLON {
  48993. /**
  48994. * Interface used to define options for Sound class
  48995. */
  48996. export interface ISoundOptions {
  48997. /**
  48998. * Does the sound autoplay once loaded.
  48999. */
  49000. autoplay?: boolean;
  49001. /**
  49002. * Does the sound loop after it finishes playing once.
  49003. */
  49004. loop?: boolean;
  49005. /**
  49006. * Sound's volume
  49007. */
  49008. volume?: number;
  49009. /**
  49010. * Is it a spatial sound?
  49011. */
  49012. spatialSound?: boolean;
  49013. /**
  49014. * Maximum distance to hear that sound
  49015. */
  49016. maxDistance?: number;
  49017. /**
  49018. * Uses user defined attenuation function
  49019. */
  49020. useCustomAttenuation?: boolean;
  49021. /**
  49022. * Define the roll off factor of spatial sounds.
  49023. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  49024. */
  49025. rolloffFactor?: number;
  49026. /**
  49027. * Define the reference distance the sound should be heard perfectly.
  49028. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  49029. */
  49030. refDistance?: number;
  49031. /**
  49032. * Define the distance attenuation model the sound will follow.
  49033. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  49034. */
  49035. distanceModel?: string;
  49036. /**
  49037. * Defines the playback speed (1 by default)
  49038. */
  49039. playbackRate?: number;
  49040. /**
  49041. * Defines if the sound is from a streaming source
  49042. */
  49043. streaming?: boolean;
  49044. /**
  49045. * Defines an optional length (in seconds) inside the sound file
  49046. */
  49047. length?: number;
  49048. /**
  49049. * Defines an optional offset (in seconds) inside the sound file
  49050. */
  49051. offset?: number;
  49052. /**
  49053. * If true, URLs will not be required to state the audio file codec to use.
  49054. */
  49055. skipCodecCheck?: boolean;
  49056. }
  49057. }
  49058. declare module BABYLON {
  49059. /**
  49060. * Defines a sound that can be played in the application.
  49061. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  49062. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  49063. */
  49064. export class Sound {
  49065. /**
  49066. * The name of the sound in the scene.
  49067. */
  49068. name: string;
  49069. /**
  49070. * Does the sound autoplay once loaded.
  49071. */
  49072. autoplay: boolean;
  49073. private _loop;
  49074. /**
  49075. * Does the sound loop after it finishes playing once.
  49076. */
  49077. get loop(): boolean;
  49078. set loop(value: boolean);
  49079. /**
  49080. * Does the sound use a custom attenuation curve to simulate the falloff
  49081. * happening when the source gets further away from the camera.
  49082. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  49083. */
  49084. useCustomAttenuation: boolean;
  49085. /**
  49086. * The sound track id this sound belongs to.
  49087. */
  49088. soundTrackId: number;
  49089. /**
  49090. * Is this sound currently played.
  49091. */
  49092. isPlaying: boolean;
  49093. /**
  49094. * Is this sound currently paused.
  49095. */
  49096. isPaused: boolean;
  49097. /**
  49098. * Does this sound enables spatial sound.
  49099. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  49100. */
  49101. spatialSound: boolean;
  49102. /**
  49103. * Define the reference distance the sound should be heard perfectly.
  49104. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  49105. */
  49106. refDistance: number;
  49107. /**
  49108. * Define the roll off factor of spatial sounds.
  49109. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  49110. */
  49111. rolloffFactor: number;
  49112. /**
  49113. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  49114. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  49115. */
  49116. maxDistance: number;
  49117. /**
  49118. * Define the distance attenuation model the sound will follow.
  49119. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  49120. */
  49121. distanceModel: string;
  49122. /**
  49123. * @hidden
  49124. * Back Compat
  49125. **/
  49126. onended: () => any;
  49127. /**
  49128. * Gets or sets an object used to store user defined information for the sound.
  49129. */
  49130. metadata: any;
  49131. /**
  49132. * Observable event when the current playing sound finishes.
  49133. */
  49134. onEndedObservable: Observable<Sound>;
  49135. /**
  49136. * Gets the current time for the sound.
  49137. */
  49138. get currentTime(): number;
  49139. private _panningModel;
  49140. private _playbackRate;
  49141. private _streaming;
  49142. private _startTime;
  49143. private _startOffset;
  49144. private _position;
  49145. /** @hidden */
  49146. _positionInEmitterSpace: boolean;
  49147. private _localDirection;
  49148. private _volume;
  49149. private _isReadyToPlay;
  49150. private _isDirectional;
  49151. private _readyToPlayCallback;
  49152. private _audioBuffer;
  49153. private _soundSource;
  49154. private _streamingSource;
  49155. private _soundPanner;
  49156. private _soundGain;
  49157. private _inputAudioNode;
  49158. private _outputAudioNode;
  49159. private _coneInnerAngle;
  49160. private _coneOuterAngle;
  49161. private _coneOuterGain;
  49162. private _scene;
  49163. private _connectedTransformNode;
  49164. private _customAttenuationFunction;
  49165. private _registerFunc;
  49166. private _isOutputConnected;
  49167. private _htmlAudioElement;
  49168. private _urlType;
  49169. private _length?;
  49170. private _offset?;
  49171. /** @hidden */
  49172. static _SceneComponentInitialization: (scene: Scene) => void;
  49173. /**
  49174. * Create a sound and attach it to a scene
  49175. * @param name Name of your sound
  49176. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  49177. * @param scene defines the scene the sound belongs to
  49178. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  49179. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  49180. */
  49181. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  49182. /**
  49183. * Release the sound and its associated resources
  49184. */
  49185. dispose(): void;
  49186. /**
  49187. * Gets if the sounds is ready to be played or not.
  49188. * @returns true if ready, otherwise false
  49189. */
  49190. isReady(): boolean;
  49191. /**
  49192. * Get the current class name.
  49193. * @returns current class name
  49194. */
  49195. getClassName(): string;
  49196. private _soundLoaded;
  49197. /**
  49198. * Sets the data of the sound from an audiobuffer
  49199. * @param audioBuffer The audioBuffer containing the data
  49200. */
  49201. setAudioBuffer(audioBuffer: AudioBuffer): void;
  49202. /**
  49203. * Updates the current sounds options such as maxdistance, loop...
  49204. * @param options A JSON object containing values named as the object properties
  49205. */
  49206. updateOptions(options: ISoundOptions): void;
  49207. private _createSpatialParameters;
  49208. private _updateSpatialParameters;
  49209. /**
  49210. * Switch the panning model to HRTF:
  49211. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  49212. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  49213. */
  49214. switchPanningModelToHRTF(): void;
  49215. /**
  49216. * Switch the panning model to Equal Power:
  49217. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  49218. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  49219. */
  49220. switchPanningModelToEqualPower(): void;
  49221. private _switchPanningModel;
  49222. /**
  49223. * Connect this sound to a sound track audio node like gain...
  49224. * @param soundTrackAudioNode the sound track audio node to connect to
  49225. */
  49226. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  49227. /**
  49228. * Transform this sound into a directional source
  49229. * @param coneInnerAngle Size of the inner cone in degree
  49230. * @param coneOuterAngle Size of the outer cone in degree
  49231. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  49232. */
  49233. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  49234. /**
  49235. * Gets or sets the inner angle for the directional cone.
  49236. */
  49237. get directionalConeInnerAngle(): number;
  49238. /**
  49239. * Gets or sets the inner angle for the directional cone.
  49240. */
  49241. set directionalConeInnerAngle(value: number);
  49242. /**
  49243. * Gets or sets the outer angle for the directional cone.
  49244. */
  49245. get directionalConeOuterAngle(): number;
  49246. /**
  49247. * Gets or sets the outer angle for the directional cone.
  49248. */
  49249. set directionalConeOuterAngle(value: number);
  49250. /**
  49251. * Sets the position of the emitter if spatial sound is enabled
  49252. * @param newPosition Defines the new position
  49253. */
  49254. setPosition(newPosition: Vector3): void;
  49255. /**
  49256. * Sets the local direction of the emitter if spatial sound is enabled
  49257. * @param newLocalDirection Defines the new local direction
  49258. */
  49259. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  49260. private _updateDirection;
  49261. /** @hidden */
  49262. updateDistanceFromListener(): void;
  49263. /**
  49264. * Sets a new custom attenuation function for the sound.
  49265. * @param callback Defines the function used for the attenuation
  49266. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  49267. */
  49268. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  49269. /**
  49270. * Play the sound
  49271. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  49272. * @param offset (optional) Start the sound at a specific time in seconds
  49273. * @param length (optional) Sound duration (in seconds)
  49274. */
  49275. play(time?: number, offset?: number, length?: number): void;
  49276. private _onended;
  49277. /**
  49278. * Stop the sound
  49279. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  49280. */
  49281. stop(time?: number): void;
  49282. /**
  49283. * Put the sound in pause
  49284. */
  49285. pause(): void;
  49286. /**
  49287. * Sets a dedicated volume for this sounds
  49288. * @param newVolume Define the new volume of the sound
  49289. * @param time Define time for gradual change to new volume
  49290. */
  49291. setVolume(newVolume: number, time?: number): void;
  49292. /**
  49293. * Set the sound play back rate
  49294. * @param newPlaybackRate Define the playback rate the sound should be played at
  49295. */
  49296. setPlaybackRate(newPlaybackRate: number): void;
  49297. /**
  49298. * Gets the volume of the sound.
  49299. * @returns the volume of the sound
  49300. */
  49301. getVolume(): number;
  49302. /**
  49303. * Attach the sound to a dedicated mesh
  49304. * @param transformNode The transform node to connect the sound with
  49305. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  49306. */
  49307. attachToMesh(transformNode: TransformNode): void;
  49308. /**
  49309. * Detach the sound from the previously attached mesh
  49310. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  49311. */
  49312. detachFromMesh(): void;
  49313. private _onRegisterAfterWorldMatrixUpdate;
  49314. /**
  49315. * Clone the current sound in the scene.
  49316. * @returns the new sound clone
  49317. */
  49318. clone(): Nullable<Sound>;
  49319. /**
  49320. * Gets the current underlying audio buffer containing the data
  49321. * @returns the audio buffer
  49322. */
  49323. getAudioBuffer(): Nullable<AudioBuffer>;
  49324. /**
  49325. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  49326. * @returns the source node
  49327. */
  49328. getSoundSource(): Nullable<AudioBufferSourceNode>;
  49329. /**
  49330. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  49331. * @returns the gain node
  49332. */
  49333. getSoundGain(): Nullable<GainNode>;
  49334. /**
  49335. * Serializes the Sound in a JSON representation
  49336. * @returns the JSON representation of the sound
  49337. */
  49338. serialize(): any;
  49339. /**
  49340. * Parse a JSON representation of a sound to instantiate in a given scene
  49341. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  49342. * @param scene Define the scene the new parsed sound should be created in
  49343. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  49344. * @param sourceSound Define a sound place holder if do not need to instantiate a new one
  49345. * @returns the newly parsed sound
  49346. */
  49347. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  49348. }
  49349. }
  49350. declare module BABYLON {
  49351. /**
  49352. * This defines an action helpful to play a defined sound on a triggered action.
  49353. */
  49354. export class PlaySoundAction extends Action {
  49355. private _sound;
  49356. /**
  49357. * Instantiate the action
  49358. * @param triggerOptions defines the trigger options
  49359. * @param sound defines the sound to play
  49360. * @param condition defines the trigger related conditions
  49361. */
  49362. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  49363. /** @hidden */
  49364. _prepare(): void;
  49365. /**
  49366. * Execute the action and play the sound.
  49367. */
  49368. execute(): void;
  49369. /**
  49370. * Serializes the actions and its related information.
  49371. * @param parent defines the object to serialize in
  49372. * @returns the serialized object
  49373. */
  49374. serialize(parent: any): any;
  49375. }
  49376. /**
  49377. * This defines an action helpful to stop a defined sound on a triggered action.
  49378. */
  49379. export class StopSoundAction extends Action {
  49380. private _sound;
  49381. /**
  49382. * Instantiate the action
  49383. * @param triggerOptions defines the trigger options
  49384. * @param sound defines the sound to stop
  49385. * @param condition defines the trigger related conditions
  49386. */
  49387. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  49388. /** @hidden */
  49389. _prepare(): void;
  49390. /**
  49391. * Execute the action and stop the sound.
  49392. */
  49393. execute(): void;
  49394. /**
  49395. * Serializes the actions and its related information.
  49396. * @param parent defines the object to serialize in
  49397. * @returns the serialized object
  49398. */
  49399. serialize(parent: any): any;
  49400. }
  49401. }
  49402. declare module BABYLON {
  49403. /**
  49404. * This defines an action responsible to change the value of a property
  49405. * by interpolating between its current value and the newly set one once triggered.
  49406. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  49407. */
  49408. export class InterpolateValueAction extends Action {
  49409. /**
  49410. * Defines the path of the property where the value should be interpolated
  49411. */
  49412. propertyPath: string;
  49413. /**
  49414. * Defines the target value at the end of the interpolation.
  49415. */
  49416. value: any;
  49417. /**
  49418. * Defines the time it will take for the property to interpolate to the value.
  49419. */
  49420. duration: number;
  49421. /**
  49422. * Defines if the other scene animations should be stopped when the action has been triggered
  49423. */
  49424. stopOtherAnimations?: boolean;
  49425. /**
  49426. * Defines a callback raised once the interpolation animation has been done.
  49427. */
  49428. onInterpolationDone?: () => void;
  49429. /**
  49430. * Observable triggered once the interpolation animation has been done.
  49431. */
  49432. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  49433. private _target;
  49434. private _effectiveTarget;
  49435. private _property;
  49436. /**
  49437. * Instantiate the action
  49438. * @param triggerOptions defines the trigger options
  49439. * @param target defines the object containing the value to interpolate
  49440. * @param propertyPath defines the path to the property in the target object
  49441. * @param value defines the target value at the end of the interpolation
  49442. * @param duration defines the time it will take for the property to interpolate to the value.
  49443. * @param condition defines the trigger related conditions
  49444. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  49445. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  49446. */
  49447. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  49448. /** @hidden */
  49449. _prepare(): void;
  49450. /**
  49451. * Execute the action starts the value interpolation.
  49452. */
  49453. execute(): void;
  49454. /**
  49455. * Serializes the actions and its related information.
  49456. * @param parent defines the object to serialize in
  49457. * @returns the serialized object
  49458. */
  49459. serialize(parent: any): any;
  49460. }
  49461. }
  49462. declare module BABYLON {
  49463. /**
  49464. * A cursor which tracks a point on a path
  49465. */
  49466. export class PathCursor {
  49467. private path;
  49468. /**
  49469. * Stores path cursor callbacks for when an onchange event is triggered
  49470. */
  49471. private _onchange;
  49472. /**
  49473. * The value of the path cursor
  49474. */
  49475. value: number;
  49476. /**
  49477. * The animation array of the path cursor
  49478. */
  49479. animations: Animation[];
  49480. /**
  49481. * Initializes the path cursor
  49482. * @param path The path to track
  49483. */
  49484. constructor(path: Path2);
  49485. /**
  49486. * Gets the cursor point on the path
  49487. * @returns A point on the path cursor at the cursor location
  49488. */
  49489. getPoint(): Vector3;
  49490. /**
  49491. * Moves the cursor ahead by the step amount
  49492. * @param step The amount to move the cursor forward
  49493. * @returns This path cursor
  49494. */
  49495. moveAhead(step?: number): PathCursor;
  49496. /**
  49497. * Moves the cursor behind by the step amount
  49498. * @param step The amount to move the cursor back
  49499. * @returns This path cursor
  49500. */
  49501. moveBack(step?: number): PathCursor;
  49502. /**
  49503. * Moves the cursor by the step amount
  49504. * If the step amount is greater than one, an exception is thrown
  49505. * @param step The amount to move the cursor
  49506. * @returns This path cursor
  49507. */
  49508. move(step: number): PathCursor;
  49509. /**
  49510. * Ensures that the value is limited between zero and one
  49511. * @returns This path cursor
  49512. */
  49513. private ensureLimits;
  49514. /**
  49515. * Runs onchange callbacks on change (used by the animation engine)
  49516. * @returns This path cursor
  49517. */
  49518. private raiseOnChange;
  49519. /**
  49520. * Executes a function on change
  49521. * @param f A path cursor onchange callback
  49522. * @returns This path cursor
  49523. */
  49524. onchange(f: (cursor: PathCursor) => void): PathCursor;
  49525. }
  49526. }
  49527. declare module BABYLON {
  49528. /**
  49529. * This represents the default audio engine used in babylon.
  49530. * It is responsible to play, synchronize and analyse sounds throughout the application.
  49531. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  49532. */
  49533. export class AudioEngine implements IAudioEngine {
  49534. private _audioContext;
  49535. private _audioContextInitialized;
  49536. private _muteButton;
  49537. private _hostElement;
  49538. /**
  49539. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  49540. */
  49541. canUseWebAudio: boolean;
  49542. /**
  49543. * The master gain node defines the global audio volume of your audio engine.
  49544. */
  49545. masterGain: GainNode;
  49546. /**
  49547. * Defines if Babylon should emit a warning if WebAudio is not supported.
  49548. * @ignoreNaming
  49549. */
  49550. WarnedWebAudioUnsupported: boolean;
  49551. /**
  49552. * Gets whether or not mp3 are supported by your browser.
  49553. */
  49554. isMP3supported: boolean;
  49555. /**
  49556. * Gets whether or not ogg are supported by your browser.
  49557. */
  49558. isOGGsupported: boolean;
  49559. /**
  49560. * Gets whether audio has been unlocked on the device.
  49561. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  49562. * a user interaction has happened.
  49563. */
  49564. unlocked: boolean;
  49565. /**
  49566. * Defines if the audio engine relies on a custom unlocked button.
  49567. * In this case, the embedded button will not be displayed.
  49568. */
  49569. useCustomUnlockedButton: boolean;
  49570. /**
  49571. * Event raised when audio has been unlocked on the browser.
  49572. */
  49573. onAudioUnlockedObservable: Observable<IAudioEngine>;
  49574. /**
  49575. * Event raised when audio has been locked on the browser.
  49576. */
  49577. onAudioLockedObservable: Observable<IAudioEngine>;
  49578. /**
  49579. * Gets the current AudioContext if available.
  49580. */
  49581. get audioContext(): Nullable<AudioContext>;
  49582. private _connectedAnalyser;
  49583. /**
  49584. * Instantiates a new audio engine.
  49585. *
  49586. * There should be only one per page as some browsers restrict the number
  49587. * of audio contexts you can create.
  49588. * @param hostElement defines the host element where to display the mute icon if necessary
  49589. */
  49590. constructor(hostElement?: Nullable<HTMLElement>);
  49591. /**
  49592. * Flags the audio engine in Locked state.
  49593. * This happens due to new browser policies preventing audio to autoplay.
  49594. */
  49595. lock(): void;
  49596. /**
  49597. * Unlocks the audio engine once a user action has been done on the dom.
  49598. * This is helpful to resume play once browser policies have been satisfied.
  49599. */
  49600. unlock(): void;
  49601. private _resumeAudioContext;
  49602. private _initializeAudioContext;
  49603. private _tryToRun;
  49604. private _triggerRunningState;
  49605. private _triggerSuspendedState;
  49606. private _displayMuteButton;
  49607. private _moveButtonToTopLeft;
  49608. private _onResize;
  49609. private _hideMuteButton;
  49610. /**
  49611. * Destroy and release the resources associated with the audio context.
  49612. */
  49613. dispose(): void;
  49614. /**
  49615. * Gets the global volume sets on the master gain.
  49616. * @returns the global volume if set or -1 otherwise
  49617. */
  49618. getGlobalVolume(): number;
  49619. /**
  49620. * Sets the global volume of your experience (sets on the master gain).
  49621. * @param newVolume Defines the new global volume of the application
  49622. */
  49623. setGlobalVolume(newVolume: number): void;
  49624. /**
  49625. * Connect the audio engine to an audio analyser allowing some amazing
  49626. * synchronization between the sounds/music and your visualization (VuMeter for instance).
  49627. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  49628. * @param analyser The analyser to connect to the engine
  49629. */
  49630. connectToAnalyser(analyser: Analyser): void;
  49631. }
  49632. }
  49633. declare module BABYLON {
  49634. /**
  49635. * Options allowed during the creation of a sound track.
  49636. */
  49637. export interface ISoundTrackOptions {
  49638. /**
  49639. * The volume the sound track should take during creation
  49640. */
  49641. volume?: number;
  49642. /**
  49643. * Define if the sound track is the main sound track of the scene
  49644. */
  49645. mainTrack?: boolean;
  49646. }
  49647. /**
  49648. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  49649. * It will be also used in a future release to apply effects on a specific track.
  49650. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  49651. */
  49652. export class SoundTrack {
  49653. /**
  49654. * The unique identifier of the sound track in the scene.
  49655. */
  49656. id: number;
  49657. /**
  49658. * The list of sounds included in the sound track.
  49659. */
  49660. soundCollection: Array<Sound>;
  49661. private _outputAudioNode;
  49662. private _scene;
  49663. private _connectedAnalyser;
  49664. private _options;
  49665. private _isInitialized;
  49666. /**
  49667. * Creates a new sound track.
  49668. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  49669. * @param scene Define the scene the sound track belongs to
  49670. * @param options
  49671. */
  49672. constructor(scene: Scene, options?: ISoundTrackOptions);
  49673. private _initializeSoundTrackAudioGraph;
  49674. /**
  49675. * Release the sound track and its associated resources
  49676. */
  49677. dispose(): void;
  49678. /**
  49679. * Adds a sound to this sound track
  49680. * @param sound define the sound to add
  49681. * @ignoreNaming
  49682. */
  49683. addSound(sound: Sound): void;
  49684. /**
  49685. * Removes a sound to this sound track
  49686. * @param sound define the sound to remove
  49687. * @ignoreNaming
  49688. */
  49689. removeSound(sound: Sound): void;
  49690. /**
  49691. * Set a global volume for the full sound track.
  49692. * @param newVolume Define the new volume of the sound track
  49693. */
  49694. setVolume(newVolume: number): void;
  49695. /**
  49696. * Switch the panning model to HRTF:
  49697. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  49698. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  49699. */
  49700. switchPanningModelToHRTF(): void;
  49701. /**
  49702. * Switch the panning model to Equal Power:
  49703. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  49704. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  49705. */
  49706. switchPanningModelToEqualPower(): void;
  49707. /**
  49708. * Connect the sound track to an audio analyser allowing some amazing
  49709. * synchronization between the sounds/music and your visualization (VuMeter for instance).
  49710. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  49711. * @param analyser The analyser to connect to the engine
  49712. */
  49713. connectToAnalyser(analyser: Analyser): void;
  49714. }
  49715. }
  49716. declare module BABYLON {
  49717. interface AbstractScene {
  49718. /**
  49719. * The list of sounds used in the scene.
  49720. */
  49721. sounds: Nullable<Array<Sound>>;
  49722. }
  49723. interface Scene {
  49724. /**
  49725. * @hidden
  49726. * Backing field
  49727. */
  49728. _mainSoundTrack: SoundTrack;
  49729. /**
  49730. * The main sound track played by the scene.
  49731. * It contains your primary collection of sounds.
  49732. */
  49733. mainSoundTrack: SoundTrack;
  49734. /**
  49735. * The list of sound tracks added to the scene
  49736. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  49737. */
  49738. soundTracks: Nullable<Array<SoundTrack>>;
  49739. /**
  49740. * Gets a sound using a given name
  49741. * @param name defines the name to search for
  49742. * @return the found sound or null if not found at all.
  49743. */
  49744. getSoundByName(name: string): Nullable<Sound>;
  49745. /**
  49746. * Gets or sets if audio support is enabled
  49747. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  49748. */
  49749. audioEnabled: boolean;
  49750. /**
  49751. * Gets or sets if audio will be output to headphones
  49752. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  49753. */
  49754. headphone: boolean;
  49755. /**
  49756. * Gets or sets custom audio listener position provider
  49757. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  49758. */
  49759. audioListenerPositionProvider: Nullable<() => Vector3>;
  49760. /**
  49761. * Gets or sets a refresh rate when using 3D audio positioning
  49762. */
  49763. audioPositioningRefreshRate: number;
  49764. }
  49765. /**
  49766. * Defines the sound scene component responsible to manage any sounds
  49767. * in a given scene.
  49768. */
  49769. export class AudioSceneComponent implements ISceneSerializableComponent {
  49770. private static _CameraDirectionLH;
  49771. private static _CameraDirectionRH;
  49772. /**
  49773. * The component name helpful to identify the component in the list of scene components.
  49774. */
  49775. readonly name: string;
  49776. /**
  49777. * The scene the component belongs to.
  49778. */
  49779. scene: Scene;
  49780. private _audioEnabled;
  49781. /**
  49782. * Gets whether audio is enabled or not.
  49783. * Please use related enable/disable method to switch state.
  49784. */
  49785. get audioEnabled(): boolean;
  49786. private _headphone;
  49787. /**
  49788. * Gets whether audio is outputting to headphone or not.
  49789. * Please use the according Switch methods to change output.
  49790. */
  49791. get headphone(): boolean;
  49792. /**
  49793. * Gets or sets a refresh rate when using 3D audio positioning
  49794. */
  49795. audioPositioningRefreshRate: number;
  49796. private _audioListenerPositionProvider;
  49797. /**
  49798. * Gets the current audio listener position provider
  49799. */
  49800. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  49801. /**
  49802. * Sets a custom listener position for all sounds in the scene
  49803. * By default, this is the position of the first active camera
  49804. */
  49805. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  49806. /**
  49807. * Creates a new instance of the component for the given scene
  49808. * @param scene Defines the scene to register the component in
  49809. */
  49810. constructor(scene: Scene);
  49811. /**
  49812. * Registers the component in a given scene
  49813. */
  49814. register(): void;
  49815. /**
  49816. * Rebuilds the elements related to this component in case of
  49817. * context lost for instance.
  49818. */
  49819. rebuild(): void;
  49820. /**
  49821. * Serializes the component data to the specified json object
  49822. * @param serializationObject The object to serialize to
  49823. */
  49824. serialize(serializationObject: any): void;
  49825. /**
  49826. * Adds all the elements from the container to the scene
  49827. * @param container the container holding the elements
  49828. */
  49829. addFromContainer(container: AbstractScene): void;
  49830. /**
  49831. * Removes all the elements in the container from the scene
  49832. * @param container contains the elements to remove
  49833. * @param dispose if the removed element should be disposed (default: false)
  49834. */
  49835. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49836. /**
  49837. * Disposes the component and the associated resources.
  49838. */
  49839. dispose(): void;
  49840. /**
  49841. * Disables audio in the associated scene.
  49842. */
  49843. disableAudio(): void;
  49844. /**
  49845. * Enables audio in the associated scene.
  49846. */
  49847. enableAudio(): void;
  49848. /**
  49849. * Switch audio to headphone output.
  49850. */
  49851. switchAudioModeForHeadphones(): void;
  49852. /**
  49853. * Switch audio to normal speakers.
  49854. */
  49855. switchAudioModeForNormalSpeakers(): void;
  49856. private _cachedCameraDirection;
  49857. private _cachedCameraPosition;
  49858. private _lastCheck;
  49859. private _afterRender;
  49860. }
  49861. }
  49862. declare module BABYLON {
  49863. /**
  49864. * Wraps one or more Sound objects and selects one with random weight for playback.
  49865. */
  49866. export class WeightedSound {
  49867. /** When true a Sound will be selected and played when the current playing Sound completes. */
  49868. loop: boolean;
  49869. private _coneInnerAngle;
  49870. private _coneOuterAngle;
  49871. private _volume;
  49872. /** A Sound is currently playing. */
  49873. isPlaying: boolean;
  49874. /** A Sound is currently paused. */
  49875. isPaused: boolean;
  49876. private _sounds;
  49877. private _weights;
  49878. private _currentIndex?;
  49879. /**
  49880. * Creates a new WeightedSound from the list of sounds given.
  49881. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  49882. * @param sounds Array of Sounds that will be selected from.
  49883. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  49884. */
  49885. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  49886. /**
  49887. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  49888. */
  49889. get directionalConeInnerAngle(): number;
  49890. /**
  49891. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  49892. */
  49893. set directionalConeInnerAngle(value: number);
  49894. /**
  49895. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  49896. * Listener angles between innerAngle and outerAngle will falloff linearly.
  49897. */
  49898. get directionalConeOuterAngle(): number;
  49899. /**
  49900. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  49901. * Listener angles between innerAngle and outerAngle will falloff linearly.
  49902. */
  49903. set directionalConeOuterAngle(value: number);
  49904. /**
  49905. * Playback volume.
  49906. */
  49907. get volume(): number;
  49908. /**
  49909. * Playback volume.
  49910. */
  49911. set volume(value: number);
  49912. private _onended;
  49913. /**
  49914. * Suspend playback
  49915. */
  49916. pause(): void;
  49917. /**
  49918. * Stop playback
  49919. */
  49920. stop(): void;
  49921. /**
  49922. * Start playback.
  49923. * @param startOffset Position the clip head at a specific time in seconds.
  49924. */
  49925. play(startOffset?: number): void;
  49926. }
  49927. }
  49928. declare module BABYLON {
  49929. /**
  49930. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  49931. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  49932. */
  49933. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  49934. /**
  49935. * Gets the name of the behavior.
  49936. */
  49937. get name(): string;
  49938. /**
  49939. * The easing function used by animations
  49940. */
  49941. static EasingFunction: BackEase;
  49942. /**
  49943. * The easing mode used by animations
  49944. */
  49945. static EasingMode: number;
  49946. /**
  49947. * The duration of the animation, in milliseconds
  49948. */
  49949. transitionDuration: number;
  49950. /**
  49951. * Length of the distance animated by the transition when lower radius is reached
  49952. */
  49953. lowerRadiusTransitionRange: number;
  49954. /**
  49955. * Length of the distance animated by the transition when upper radius is reached
  49956. */
  49957. upperRadiusTransitionRange: number;
  49958. private _autoTransitionRange;
  49959. /**
  49960. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  49961. */
  49962. get autoTransitionRange(): boolean;
  49963. /**
  49964. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  49965. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  49966. */
  49967. set autoTransitionRange(value: boolean);
  49968. private _attachedCamera;
  49969. private _onAfterCheckInputsObserver;
  49970. private _onMeshTargetChangedObserver;
  49971. /**
  49972. * Initializes the behavior.
  49973. */
  49974. init(): void;
  49975. /**
  49976. * Attaches the behavior to its arc rotate camera.
  49977. * @param camera Defines the camera to attach the behavior to
  49978. */
  49979. attach(camera: ArcRotateCamera): void;
  49980. /**
  49981. * Detaches the behavior from its current arc rotate camera.
  49982. */
  49983. detach(): void;
  49984. private _radiusIsAnimating;
  49985. private _radiusBounceTransition;
  49986. private _animatables;
  49987. private _cachedWheelPrecision;
  49988. /**
  49989. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  49990. * @param radiusLimit The limit to check against.
  49991. * @return Bool to indicate if at limit.
  49992. */
  49993. private _isRadiusAtLimit;
  49994. /**
  49995. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  49996. * @param radiusDelta The delta by which to animate to. Can be negative.
  49997. */
  49998. private _applyBoundRadiusAnimation;
  49999. /**
  50000. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  50001. */
  50002. protected _clearAnimationLocks(): void;
  50003. /**
  50004. * Stops and removes all animations that have been applied to the camera
  50005. */
  50006. stopAllAnimations(): void;
  50007. }
  50008. }
  50009. declare module BABYLON {
  50010. /**
  50011. * 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.
  50012. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  50013. */
  50014. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  50015. /**
  50016. * Gets the name of the behavior.
  50017. */
  50018. get name(): string;
  50019. private _mode;
  50020. private _radiusScale;
  50021. private _positionScale;
  50022. private _defaultElevation;
  50023. private _elevationReturnTime;
  50024. private _elevationReturnWaitTime;
  50025. private _zoomStopsAnimation;
  50026. private _framingTime;
  50027. /**
  50028. * The easing function used by animations
  50029. */
  50030. static EasingFunction: ExponentialEase;
  50031. /**
  50032. * The easing mode used by animations
  50033. */
  50034. static EasingMode: number;
  50035. /**
  50036. * Sets the current mode used by the behavior
  50037. */
  50038. set mode(mode: number);
  50039. /**
  50040. * Gets current mode used by the behavior.
  50041. */
  50042. get mode(): number;
  50043. /**
  50044. * Sets the scale applied to the radius (1 by default)
  50045. */
  50046. set radiusScale(radius: number);
  50047. /**
  50048. * Gets the scale applied to the radius
  50049. */
  50050. get radiusScale(): number;
  50051. /**
  50052. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  50053. */
  50054. set positionScale(scale: number);
  50055. /**
  50056. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  50057. */
  50058. get positionScale(): number;
  50059. /**
  50060. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  50061. * behaviour is triggered, in radians.
  50062. */
  50063. set defaultElevation(elevation: number);
  50064. /**
  50065. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  50066. * behaviour is triggered, in radians.
  50067. */
  50068. get defaultElevation(): number;
  50069. /**
  50070. * Sets the time (in milliseconds) taken to return to the default beta position.
  50071. * Negative value indicates camera should not return to default.
  50072. */
  50073. set elevationReturnTime(speed: number);
  50074. /**
  50075. * Gets the time (in milliseconds) taken to return to the default beta position.
  50076. * Negative value indicates camera should not return to default.
  50077. */
  50078. get elevationReturnTime(): number;
  50079. /**
  50080. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  50081. */
  50082. set elevationReturnWaitTime(time: number);
  50083. /**
  50084. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  50085. */
  50086. get elevationReturnWaitTime(): number;
  50087. /**
  50088. * Sets the flag that indicates if user zooming should stop animation.
  50089. */
  50090. set zoomStopsAnimation(flag: boolean);
  50091. /**
  50092. * Gets the flag that indicates if user zooming should stop animation.
  50093. */
  50094. get zoomStopsAnimation(): boolean;
  50095. /**
  50096. * Sets the transition time when framing the mesh, in milliseconds
  50097. */
  50098. set framingTime(time: number);
  50099. /**
  50100. * Gets the transition time when framing the mesh, in milliseconds
  50101. */
  50102. get framingTime(): number;
  50103. /**
  50104. * Define if the behavior should automatically change the configured
  50105. * camera limits and sensibilities.
  50106. */
  50107. autoCorrectCameraLimitsAndSensibility: boolean;
  50108. private _onPrePointerObservableObserver;
  50109. private _onAfterCheckInputsObserver;
  50110. private _onMeshTargetChangedObserver;
  50111. private _attachedCamera;
  50112. private _isPointerDown;
  50113. private _lastInteractionTime;
  50114. /**
  50115. * Initializes the behavior.
  50116. */
  50117. init(): void;
  50118. /**
  50119. * Attaches the behavior to its arc rotate camera.
  50120. * @param camera Defines the camera to attach the behavior to
  50121. */
  50122. attach(camera: ArcRotateCamera): void;
  50123. /**
  50124. * Detaches the behavior from its current arc rotate camera.
  50125. */
  50126. detach(): void;
  50127. private _animatables;
  50128. private _betaIsAnimating;
  50129. private _betaTransition;
  50130. private _radiusTransition;
  50131. private _vectorTransition;
  50132. /**
  50133. * Targets the given mesh and updates zoom level accordingly.
  50134. * @param mesh The mesh to target.
  50135. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  50136. * @param onAnimationEnd Callback triggered at the end of the framing animation
  50137. */
  50138. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  50139. /**
  50140. * Targets the given mesh with its children and updates zoom level accordingly.
  50141. * @param mesh The mesh to target.
  50142. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  50143. * @param onAnimationEnd Callback triggered at the end of the framing animation
  50144. */
  50145. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  50146. /**
  50147. * Targets the given meshes with their children and updates zoom level accordingly.
  50148. * @param meshes The mesh to target.
  50149. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  50150. * @param onAnimationEnd Callback triggered at the end of the framing animation
  50151. */
  50152. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  50153. /**
  50154. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  50155. * @param minimumWorld Determines the smaller position of the bounding box extend
  50156. * @param maximumWorld Determines the bigger position of the bounding box extend
  50157. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  50158. * @param onAnimationEnd Callback triggered at the end of the framing animation
  50159. */
  50160. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  50161. /**
  50162. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  50163. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  50164. * frustum width.
  50165. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  50166. * to fully enclose the mesh in the viewing frustum.
  50167. */
  50168. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  50169. /**
  50170. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  50171. * is automatically returned to its default position (expected to be above ground plane).
  50172. */
  50173. private _maintainCameraAboveGround;
  50174. /**
  50175. * Returns the frustum slope based on the canvas ratio and camera FOV
  50176. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  50177. */
  50178. private _getFrustumSlope;
  50179. /**
  50180. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  50181. */
  50182. private _clearAnimationLocks;
  50183. /**
  50184. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  50185. */
  50186. private _applyUserInteraction;
  50187. /**
  50188. * Stops and removes all animations that have been applied to the camera
  50189. */
  50190. stopAllAnimations(): void;
  50191. /**
  50192. * Gets a value indicating if the user is moving the camera
  50193. */
  50194. get isUserIsMoving(): boolean;
  50195. /**
  50196. * The camera can move all the way towards the mesh.
  50197. */
  50198. static IgnoreBoundsSizeMode: number;
  50199. /**
  50200. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  50201. */
  50202. static FitFrustumSidesMode: number;
  50203. }
  50204. }
  50205. declare module BABYLON {
  50206. /**
  50207. * Base class for Camera Pointer Inputs.
  50208. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  50209. * for example usage.
  50210. */
  50211. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  50212. /**
  50213. * Defines the camera the input is attached to.
  50214. */
  50215. abstract camera: Camera;
  50216. /**
  50217. * Whether keyboard modifier keys are pressed at time of last mouse event.
  50218. */
  50219. protected _altKey: boolean;
  50220. protected _ctrlKey: boolean;
  50221. protected _metaKey: boolean;
  50222. protected _shiftKey: boolean;
  50223. /**
  50224. * Which mouse buttons were pressed at time of last mouse event.
  50225. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  50226. */
  50227. protected _buttonsPressed: number;
  50228. /**
  50229. * Defines the buttons associated with the input to handle camera move.
  50230. */
  50231. buttons: number[];
  50232. /**
  50233. * Attach the input controls to a specific dom element to get the input from.
  50234. * @param element Defines the element the controls should be listened from
  50235. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50236. */
  50237. attachControl(noPreventDefault?: boolean): void;
  50238. /**
  50239. * Detach the current controls from the specified dom element.
  50240. */
  50241. detachControl(): void;
  50242. /**
  50243. * Gets the class name of the current input.
  50244. * @returns the class name
  50245. */
  50246. getClassName(): string;
  50247. /**
  50248. * Get the friendly name associated with the input class.
  50249. * @returns the input friendly name
  50250. */
  50251. getSimpleName(): string;
  50252. /**
  50253. * Called on pointer POINTERDOUBLETAP event.
  50254. * Override this method to provide functionality on POINTERDOUBLETAP event.
  50255. */
  50256. protected onDoubleTap(type: string): void;
  50257. /**
  50258. * Called on pointer POINTERMOVE event if only a single touch is active.
  50259. * Override this method to provide functionality.
  50260. */
  50261. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  50262. /**
  50263. * Called on pointer POINTERMOVE event if multiple touches are active.
  50264. * Override this method to provide functionality.
  50265. */
  50266. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  50267. /**
  50268. * Called on JS contextmenu event.
  50269. * Override this method to provide functionality.
  50270. */
  50271. protected onContextMenu(evt: PointerEvent): void;
  50272. /**
  50273. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  50274. * press.
  50275. * Override this method to provide functionality.
  50276. */
  50277. protected onButtonDown(evt: IPointerEvent): void;
  50278. /**
  50279. * Called each time a new POINTERUP event occurs. Ie, for each button
  50280. * release.
  50281. * Override this method to provide functionality.
  50282. */
  50283. protected onButtonUp(evt: IPointerEvent): void;
  50284. /**
  50285. * Called when window becomes inactive.
  50286. * Override this method to provide functionality.
  50287. */
  50288. protected onLostFocus(): void;
  50289. private _pointerInput;
  50290. private _observer;
  50291. private _onLostFocus;
  50292. private pointA;
  50293. private pointB;
  50294. }
  50295. }
  50296. declare module BABYLON {
  50297. /**
  50298. * Manage the pointers inputs to control an arc rotate camera.
  50299. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50300. */
  50301. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  50302. /**
  50303. * Defines the camera the input is attached to.
  50304. */
  50305. camera: ArcRotateCamera;
  50306. /**
  50307. * Gets the class name of the current input.
  50308. * @returns the class name
  50309. */
  50310. getClassName(): string;
  50311. /**
  50312. * Defines the buttons associated with the input to handle camera move.
  50313. */
  50314. buttons: number[];
  50315. /**
  50316. * Defines the pointer angular sensibility along the X axis or how fast is
  50317. * the camera rotating.
  50318. */
  50319. angularSensibilityX: number;
  50320. /**
  50321. * Defines the pointer angular sensibility along the Y axis or how fast is
  50322. * the camera rotating.
  50323. */
  50324. angularSensibilityY: number;
  50325. /**
  50326. * Defines the pointer pinch precision or how fast is the camera zooming.
  50327. */
  50328. pinchPrecision: number;
  50329. /**
  50330. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  50331. * from 0.
  50332. * It defines the percentage of current camera.radius to use as delta when
  50333. * pinch zoom is used.
  50334. */
  50335. pinchDeltaPercentage: number;
  50336. /**
  50337. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  50338. * that any object in the plane at the camera's target point will scale
  50339. * perfectly with finger motion.
  50340. * Overrides pinchDeltaPercentage and pinchPrecision.
  50341. */
  50342. useNaturalPinchZoom: boolean;
  50343. /**
  50344. * Defines whether zoom (2 fingers pinch) is enabled through multitouch
  50345. */
  50346. pinchZoom: boolean;
  50347. /**
  50348. * Defines the pointer panning sensibility or how fast is the camera moving.
  50349. */
  50350. panningSensibility: number;
  50351. /**
  50352. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  50353. */
  50354. multiTouchPanning: boolean;
  50355. /**
  50356. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  50357. * zoom (pinch) through multitouch.
  50358. */
  50359. multiTouchPanAndZoom: boolean;
  50360. /**
  50361. * Revers pinch action direction.
  50362. */
  50363. pinchInwards: boolean;
  50364. private _isPanClick;
  50365. private _twoFingerActivityCount;
  50366. private _isPinching;
  50367. /**
  50368. * Move camera from multi touch panning positions.
  50369. */
  50370. private _computeMultiTouchPanning;
  50371. /**
  50372. * Move camera from pinch zoom distances.
  50373. */
  50374. private _computePinchZoom;
  50375. /**
  50376. * Called on pointer POINTERMOVE event if only a single touch is active.
  50377. */
  50378. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  50379. /**
  50380. * Called on pointer POINTERDOUBLETAP event.
  50381. */
  50382. protected onDoubleTap(type: string): void;
  50383. /**
  50384. * Called on pointer POINTERMOVE event if multiple touches are active.
  50385. */
  50386. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  50387. /**
  50388. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  50389. * press.
  50390. */
  50391. protected onButtonDown(evt: IPointerEvent): void;
  50392. /**
  50393. * Called each time a new POINTERUP event occurs. Ie, for each button
  50394. * release.
  50395. */
  50396. protected onButtonUp(evt: IPointerEvent): void;
  50397. /**
  50398. * Called when window becomes inactive.
  50399. */
  50400. protected onLostFocus(): void;
  50401. }
  50402. }
  50403. declare module BABYLON {
  50404. /**
  50405. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  50406. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50407. */
  50408. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  50409. /**
  50410. * Defines the camera the input is attached to.
  50411. */
  50412. camera: ArcRotateCamera;
  50413. /**
  50414. * Defines the list of key codes associated with the up action (increase alpha)
  50415. */
  50416. keysUp: number[];
  50417. /**
  50418. * Defines the list of key codes associated with the down action (decrease alpha)
  50419. */
  50420. keysDown: number[];
  50421. /**
  50422. * Defines the list of key codes associated with the left action (increase beta)
  50423. */
  50424. keysLeft: number[];
  50425. /**
  50426. * Defines the list of key codes associated with the right action (decrease beta)
  50427. */
  50428. keysRight: number[];
  50429. /**
  50430. * Defines the list of key codes associated with the reset action.
  50431. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  50432. */
  50433. keysReset: number[];
  50434. /**
  50435. * Defines the panning sensibility of the inputs.
  50436. * (How fast is the camera panning)
  50437. */
  50438. panningSensibility: number;
  50439. /**
  50440. * Defines the zooming sensibility of the inputs.
  50441. * (How fast is the camera zooming)
  50442. */
  50443. zoomingSensibility: number;
  50444. /**
  50445. * Defines whether maintaining the alt key down switch the movement mode from
  50446. * orientation to zoom.
  50447. */
  50448. useAltToZoom: boolean;
  50449. /**
  50450. * Rotation speed of the camera
  50451. */
  50452. angularSpeed: number;
  50453. private _keys;
  50454. private _ctrlPressed;
  50455. private _altPressed;
  50456. private _onCanvasBlurObserver;
  50457. private _onKeyboardObserver;
  50458. private _engine;
  50459. private _scene;
  50460. /**
  50461. * Attach the input controls to a specific dom element to get the input from.
  50462. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50463. */
  50464. attachControl(noPreventDefault?: boolean): void;
  50465. /**
  50466. * Detach the current controls from the specified dom element.
  50467. */
  50468. detachControl(): void;
  50469. /**
  50470. * Update the current camera state depending on the inputs that have been used this frame.
  50471. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  50472. */
  50473. checkInputs(): void;
  50474. /**
  50475. * Gets the class name of the current input.
  50476. * @returns the class name
  50477. */
  50478. getClassName(): string;
  50479. /**
  50480. * Get the friendly name associated with the input class.
  50481. * @returns the input friendly name
  50482. */
  50483. getSimpleName(): string;
  50484. }
  50485. }
  50486. declare module BABYLON {
  50487. /**
  50488. * Manage the mouse wheel inputs to control an arc rotate camera.
  50489. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50490. */
  50491. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  50492. /**
  50493. * Defines the camera the input is attached to.
  50494. */
  50495. camera: ArcRotateCamera;
  50496. /**
  50497. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  50498. */
  50499. wheelPrecision: number;
  50500. /**
  50501. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  50502. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  50503. */
  50504. wheelDeltaPercentage: number;
  50505. private _wheel;
  50506. private _observer;
  50507. private computeDeltaFromMouseWheelLegacyEvent;
  50508. /**
  50509. * Attach the input controls to a specific dom element to get the input from.
  50510. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50511. */
  50512. attachControl(noPreventDefault?: boolean): void;
  50513. /**
  50514. * Detach the current controls from the specified dom element.
  50515. */
  50516. detachControl(): void;
  50517. /**
  50518. * Gets the class name of the current input.
  50519. * @returns the class name
  50520. */
  50521. getClassName(): string;
  50522. /**
  50523. * Get the friendly name associated with the input class.
  50524. * @returns the input friendly name
  50525. */
  50526. getSimpleName(): string;
  50527. }
  50528. }
  50529. declare module BABYLON {
  50530. /**
  50531. * Default Inputs manager for the ArcRotateCamera.
  50532. * It groups all the default supported inputs for ease of use.
  50533. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50534. */
  50535. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  50536. /**
  50537. * Instantiates a new ArcRotateCameraInputsManager.
  50538. * @param camera Defines the camera the inputs belong to
  50539. */
  50540. constructor(camera: ArcRotateCamera);
  50541. /**
  50542. * Add mouse wheel input support to the input manager.
  50543. * @returns the current input manager
  50544. */
  50545. addMouseWheel(): ArcRotateCameraInputsManager;
  50546. /**
  50547. * Add pointers input support to the input manager.
  50548. * @returns the current input manager
  50549. */
  50550. addPointers(): ArcRotateCameraInputsManager;
  50551. /**
  50552. * Add keyboard input support to the input manager.
  50553. * @returns the current input manager
  50554. */
  50555. addKeyboard(): ArcRotateCameraInputsManager;
  50556. }
  50557. }
  50558. declare module BABYLON {
  50559. /**
  50560. * This represents an orbital type of camera.
  50561. *
  50562. * 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.
  50563. * 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.
  50564. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  50565. */
  50566. export class ArcRotateCamera extends TargetCamera {
  50567. /**
  50568. * Defines the rotation angle of the camera along the longitudinal axis.
  50569. */
  50570. alpha: number;
  50571. /**
  50572. * Defines the rotation angle of the camera along the latitudinal axis.
  50573. */
  50574. beta: number;
  50575. /**
  50576. * Defines the radius of the camera from it s target point.
  50577. */
  50578. radius: number;
  50579. protected _target: Vector3;
  50580. protected _targetHost: Nullable<AbstractMesh>;
  50581. /**
  50582. * Defines the target point of the camera.
  50583. * The camera looks towards it form the radius distance.
  50584. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  50585. */
  50586. get target(): Vector3;
  50587. set target(value: Vector3);
  50588. /**
  50589. * Define the current local position of the camera in the scene
  50590. */
  50591. get position(): Vector3;
  50592. set position(newPosition: Vector3);
  50593. protected _upToYMatrix: Matrix;
  50594. protected _YToUpMatrix: Matrix;
  50595. /**
  50596. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  50597. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  50598. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  50599. */
  50600. set upVector(vec: Vector3);
  50601. get upVector(): Vector3;
  50602. /**
  50603. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  50604. */
  50605. setMatUp(): void;
  50606. /**
  50607. * Current inertia value on the longitudinal axis.
  50608. * The bigger this number the longer it will take for the camera to stop.
  50609. */
  50610. inertialAlphaOffset: number;
  50611. /**
  50612. * Current inertia value on the latitudinal axis.
  50613. * The bigger this number the longer it will take for the camera to stop.
  50614. */
  50615. inertialBetaOffset: number;
  50616. /**
  50617. * Current inertia value on the radius axis.
  50618. * The bigger this number the longer it will take for the camera to stop.
  50619. */
  50620. inertialRadiusOffset: number;
  50621. /**
  50622. * Minimum allowed angle on the longitudinal axis.
  50623. * This can help limiting how the Camera is able to move in the scene.
  50624. */
  50625. lowerAlphaLimit: Nullable<number>;
  50626. /**
  50627. * Maximum allowed angle on the longitudinal axis.
  50628. * This can help limiting how the Camera is able to move in the scene.
  50629. */
  50630. upperAlphaLimit: Nullable<number>;
  50631. /**
  50632. * Minimum allowed angle on the latitudinal axis.
  50633. * This can help limiting how the Camera is able to move in the scene.
  50634. */
  50635. lowerBetaLimit: number;
  50636. /**
  50637. * Maximum allowed angle on the latitudinal axis.
  50638. * This can help limiting how the Camera is able to move in the scene.
  50639. */
  50640. upperBetaLimit: number;
  50641. /**
  50642. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  50643. * This can help limiting how the Camera is able to move in the scene.
  50644. */
  50645. lowerRadiusLimit: Nullable<number>;
  50646. /**
  50647. * Maximum allowed distance of the camera to the target (The camera can not get further).
  50648. * This can help limiting how the Camera is able to move in the scene.
  50649. */
  50650. upperRadiusLimit: Nullable<number>;
  50651. /**
  50652. * Defines the current inertia value used during panning of the camera along the X axis.
  50653. */
  50654. inertialPanningX: number;
  50655. /**
  50656. * Defines the current inertia value used during panning of the camera along the Y axis.
  50657. */
  50658. inertialPanningY: number;
  50659. /**
  50660. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  50661. * Basically if your fingers moves away from more than this distance you will be considered
  50662. * in pinch mode.
  50663. */
  50664. pinchToPanMaxDistance: number;
  50665. /**
  50666. * Defines the maximum distance the camera can pan.
  50667. * This could help keeping the camera always in your scene.
  50668. */
  50669. panningDistanceLimit: Nullable<number>;
  50670. /**
  50671. * Defines the target of the camera before panning.
  50672. */
  50673. panningOriginTarget: Vector3;
  50674. /**
  50675. * Defines the value of the inertia used during panning.
  50676. * 0 would mean stop inertia and one would mean no decelleration at all.
  50677. */
  50678. panningInertia: number;
  50679. /**
  50680. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  50681. */
  50682. get angularSensibilityX(): number;
  50683. set angularSensibilityX(value: number);
  50684. /**
  50685. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  50686. */
  50687. get angularSensibilityY(): number;
  50688. set angularSensibilityY(value: number);
  50689. /**
  50690. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  50691. */
  50692. get pinchPrecision(): number;
  50693. set pinchPrecision(value: number);
  50694. /**
  50695. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  50696. * It will be used instead of pinchDeltaPrecision if different from 0.
  50697. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  50698. */
  50699. get pinchDeltaPercentage(): number;
  50700. set pinchDeltaPercentage(value: number);
  50701. /**
  50702. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  50703. * and pinch delta percentage.
  50704. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  50705. * that any object in the plane at the camera's target point will scale
  50706. * perfectly with finger motion.
  50707. */
  50708. get useNaturalPinchZoom(): boolean;
  50709. set useNaturalPinchZoom(value: boolean);
  50710. /**
  50711. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  50712. */
  50713. get panningSensibility(): number;
  50714. set panningSensibility(value: number);
  50715. /**
  50716. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  50717. */
  50718. get keysUp(): number[];
  50719. set keysUp(value: number[]);
  50720. /**
  50721. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  50722. */
  50723. get keysDown(): number[];
  50724. set keysDown(value: number[]);
  50725. /**
  50726. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  50727. */
  50728. get keysLeft(): number[];
  50729. set keysLeft(value: number[]);
  50730. /**
  50731. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  50732. */
  50733. get keysRight(): number[];
  50734. set keysRight(value: number[]);
  50735. /**
  50736. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  50737. */
  50738. get wheelPrecision(): number;
  50739. set wheelPrecision(value: number);
  50740. /**
  50741. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  50742. * It will be used instead of pinchDeltaPrecision if different from 0.
  50743. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  50744. */
  50745. get wheelDeltaPercentage(): number;
  50746. set wheelDeltaPercentage(value: number);
  50747. /**
  50748. * Defines how much the radius should be scaled while zooming on a particular mesh (through the zoomOn function)
  50749. */
  50750. zoomOnFactor: number;
  50751. /**
  50752. * Defines a screen offset for the camera position.
  50753. */
  50754. targetScreenOffset: Vector2;
  50755. /**
  50756. * Allows the camera to be completely reversed.
  50757. * If false the camera can not arrive upside down.
  50758. */
  50759. allowUpsideDown: boolean;
  50760. /**
  50761. * Define if double tap/click is used to restore the previously saved state of the camera.
  50762. */
  50763. useInputToRestoreState: boolean;
  50764. /** @hidden */
  50765. _viewMatrix: Matrix;
  50766. /** @hidden */
  50767. _useCtrlForPanning: boolean;
  50768. /** @hidden */
  50769. _panningMouseButton: number;
  50770. /**
  50771. * Defines the input associated to the camera.
  50772. */
  50773. inputs: ArcRotateCameraInputsManager;
  50774. /** @hidden */
  50775. _reset: () => void;
  50776. /**
  50777. * Defines the allowed panning axis.
  50778. */
  50779. panningAxis: Vector3;
  50780. protected _transformedDirection: Vector3;
  50781. private _bouncingBehavior;
  50782. /**
  50783. * Gets the bouncing behavior of the camera if it has been enabled.
  50784. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  50785. */
  50786. get bouncingBehavior(): Nullable<BouncingBehavior>;
  50787. /**
  50788. * Defines if the bouncing behavior of the camera is enabled on the camera.
  50789. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  50790. */
  50791. get useBouncingBehavior(): boolean;
  50792. set useBouncingBehavior(value: boolean);
  50793. private _framingBehavior;
  50794. /**
  50795. * Gets the framing behavior of the camera if it has been enabled.
  50796. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  50797. */
  50798. get framingBehavior(): Nullable<FramingBehavior>;
  50799. /**
  50800. * Defines if the framing behavior of the camera is enabled on the camera.
  50801. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  50802. */
  50803. get useFramingBehavior(): boolean;
  50804. set useFramingBehavior(value: boolean);
  50805. private _autoRotationBehavior;
  50806. /**
  50807. * Gets the auto rotation behavior of the camera if it has been enabled.
  50808. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  50809. */
  50810. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  50811. /**
  50812. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  50813. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  50814. */
  50815. get useAutoRotationBehavior(): boolean;
  50816. set useAutoRotationBehavior(value: boolean);
  50817. /**
  50818. * Observable triggered when the mesh target has been changed on the camera.
  50819. */
  50820. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  50821. /**
  50822. * Event raised when the camera is colliding with a mesh.
  50823. */
  50824. onCollide: (collidedMesh: AbstractMesh) => void;
  50825. /**
  50826. * Defines whether the camera should check collision with the objects oh the scene.
  50827. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  50828. */
  50829. checkCollisions: boolean;
  50830. /**
  50831. * Defines the collision radius of the camera.
  50832. * This simulates a sphere around the camera.
  50833. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  50834. */
  50835. collisionRadius: Vector3;
  50836. protected _collider: Collider;
  50837. protected _previousPosition: Vector3;
  50838. protected _collisionVelocity: Vector3;
  50839. protected _newPosition: Vector3;
  50840. protected _previousAlpha: number;
  50841. protected _previousBeta: number;
  50842. protected _previousRadius: number;
  50843. protected _collisionTriggered: boolean;
  50844. protected _targetBoundingCenter: Nullable<Vector3>;
  50845. private _computationVector;
  50846. /**
  50847. * Instantiates a new ArcRotateCamera in a given scene
  50848. * @param name Defines the name of the camera
  50849. * @param alpha Defines the camera rotation along the longitudinal axis
  50850. * @param beta Defines the camera rotation along the latitudinal axis
  50851. * @param radius Defines the camera distance from its target
  50852. * @param target Defines the camera target
  50853. * @param scene Defines the scene the camera belongs to
  50854. * @param setActiveOnSceneIfNoneActive Defines whether the camera should be marked as active if not other active cameras have been defined
  50855. */
  50856. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  50857. /** @hidden */
  50858. _initCache(): void;
  50859. /** @hidden */
  50860. _updateCache(ignoreParentClass?: boolean): void;
  50861. protected _getTargetPosition(): Vector3;
  50862. private _storedAlpha;
  50863. private _storedBeta;
  50864. private _storedRadius;
  50865. private _storedTarget;
  50866. private _storedTargetScreenOffset;
  50867. /**
  50868. * Stores the current state of the camera (alpha, beta, radius and target)
  50869. * @returns the camera itself
  50870. */
  50871. storeState(): Camera;
  50872. /**
  50873. * @hidden
  50874. * Restored camera state. You must call storeState() first
  50875. */
  50876. _restoreStateValues(): boolean;
  50877. /** @hidden */
  50878. _isSynchronizedViewMatrix(): boolean;
  50879. /**
  50880. * Attach the input controls to a specific dom element to get the input from.
  50881. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50882. */
  50883. attachControl(noPreventDefault?: boolean): void;
  50884. /**
  50885. * Attach the input controls to a specific dom element to get the input from.
  50886. * @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
  50887. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50888. */
  50889. attachControl(ignored: any, noPreventDefault?: boolean): void;
  50890. /**
  50891. * Attached controls to the current camera.
  50892. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50893. * @param useCtrlForPanning Defines whether ctrl is used for panning within the controls
  50894. */
  50895. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  50896. /**
  50897. * Attached controls to the current camera.
  50898. * @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
  50899. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50900. * @param useCtrlForPanning Defines whether ctrl is used for panning within the controls
  50901. */
  50902. attachControl(ignored: any, noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  50903. /**
  50904. * Attached controls to the current camera.
  50905. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50906. * @param useCtrlForPanning Defines whether ctrl is used for panning within the controls
  50907. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  50908. */
  50909. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean, panningMouseButton: number): void;
  50910. /**
  50911. * Detach the current controls from the specified dom element.
  50912. */
  50913. detachControl(): void;
  50914. /**
  50915. * Detach the current controls from the specified dom element.
  50916. * @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
  50917. */
  50918. detachControl(ignored: any): void;
  50919. /** @hidden */
  50920. _checkInputs(): void;
  50921. protected _checkLimits(): void;
  50922. /**
  50923. * Rebuilds angles (alpha, beta) and radius from the give position and target
  50924. */
  50925. rebuildAnglesAndRadius(): void;
  50926. /**
  50927. * Use a position to define the current camera related information like alpha, beta and radius
  50928. * @param position Defines the position to set the camera at
  50929. */
  50930. setPosition(position: Vector3): void;
  50931. /**
  50932. * Defines the target the camera should look at.
  50933. * This will automatically adapt alpha beta and radius to fit within the new target.
  50934. * @param target Defines the new target as a Vector or a mesh
  50935. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  50936. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  50937. */
  50938. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  50939. /** @hidden */
  50940. _getViewMatrix(): Matrix;
  50941. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  50942. /**
  50943. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  50944. * @param meshes Defines the mesh to zoom on
  50945. * @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)
  50946. */
  50947. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  50948. /**
  50949. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  50950. * The target will be changed but the radius
  50951. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  50952. * @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)
  50953. */
  50954. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  50955. min: Vector3;
  50956. max: Vector3;
  50957. distance: number;
  50958. }, doNotUpdateMaxZ?: boolean): void;
  50959. /**
  50960. * @override
  50961. * Override Camera.createRigCamera
  50962. */
  50963. createRigCamera(name: string, cameraIndex: number): Camera;
  50964. /**
  50965. * @hidden
  50966. * @override
  50967. * Override Camera._updateRigCameras
  50968. */
  50969. _updateRigCameras(): void;
  50970. /**
  50971. * Destroy the camera and release the current resources hold by it.
  50972. */
  50973. dispose(): void;
  50974. /**
  50975. * Gets the current object class name.
  50976. * @return the class name
  50977. */
  50978. getClassName(): string;
  50979. }
  50980. }
  50981. declare module BABYLON {
  50982. /**
  50983. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  50984. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  50985. */
  50986. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  50987. /**
  50988. * Gets the name of the behavior.
  50989. */
  50990. get name(): string;
  50991. private _zoomStopsAnimation;
  50992. private _idleRotationSpeed;
  50993. private _idleRotationWaitTime;
  50994. private _idleRotationSpinupTime;
  50995. /**
  50996. * Sets the flag that indicates if user zooming should stop animation.
  50997. */
  50998. set zoomStopsAnimation(flag: boolean);
  50999. /**
  51000. * Gets the flag that indicates if user zooming should stop animation.
  51001. */
  51002. get zoomStopsAnimation(): boolean;
  51003. /**
  51004. * Sets the default speed at which the camera rotates around the model.
  51005. */
  51006. set idleRotationSpeed(speed: number);
  51007. /**
  51008. * Gets the default speed at which the camera rotates around the model.
  51009. */
  51010. get idleRotationSpeed(): number;
  51011. /**
  51012. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  51013. */
  51014. set idleRotationWaitTime(time: number);
  51015. /**
  51016. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  51017. */
  51018. get idleRotationWaitTime(): number;
  51019. /**
  51020. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  51021. */
  51022. set idleRotationSpinupTime(time: number);
  51023. /**
  51024. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  51025. */
  51026. get idleRotationSpinupTime(): number;
  51027. /**
  51028. * Gets a value indicating if the camera is currently rotating because of this behavior
  51029. */
  51030. get rotationInProgress(): boolean;
  51031. private _onPrePointerObservableObserver;
  51032. private _onAfterCheckInputsObserver;
  51033. private _attachedCamera;
  51034. private _isPointerDown;
  51035. private _lastFrameTime;
  51036. private _lastInteractionTime;
  51037. private _cameraRotationSpeed;
  51038. /**
  51039. * Initializes the behavior.
  51040. */
  51041. init(): void;
  51042. /**
  51043. * Attaches the behavior to its arc rotate camera.
  51044. * @param camera Defines the camera to attach the behavior to
  51045. */
  51046. attach(camera: ArcRotateCamera): void;
  51047. /**
  51048. * Detaches the behavior from its current arc rotate camera.
  51049. */
  51050. detach(): void;
  51051. /**
  51052. * Returns true if user is scrolling.
  51053. * @return true if user is scrolling.
  51054. */
  51055. private _userIsZooming;
  51056. private _lastFrameRadius;
  51057. private _shouldAnimationStopForInteraction;
  51058. /**
  51059. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  51060. */
  51061. private _applyUserInteraction;
  51062. private _userIsMoving;
  51063. }
  51064. }
  51065. declare module BABYLON {
  51066. /**
  51067. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  51068. */
  51069. export class AttachToBoxBehavior implements Behavior<Mesh> {
  51070. private ui;
  51071. /**
  51072. * The name of the behavior
  51073. */
  51074. name: string;
  51075. /**
  51076. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  51077. */
  51078. distanceAwayFromFace: number;
  51079. /**
  51080. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  51081. */
  51082. distanceAwayFromBottomOfFace: number;
  51083. private _faceVectors;
  51084. private _target;
  51085. private _scene;
  51086. private _onRenderObserver;
  51087. private _tmpMatrix;
  51088. private _tmpVector;
  51089. /**
  51090. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  51091. * @param ui The transform node that should be attached to the mesh
  51092. */
  51093. constructor(ui: TransformNode);
  51094. /**
  51095. * Initializes the behavior
  51096. */
  51097. init(): void;
  51098. private _closestFace;
  51099. private _zeroVector;
  51100. private _lookAtTmpMatrix;
  51101. private _lookAtToRef;
  51102. /**
  51103. * Attaches the AttachToBoxBehavior to the passed in mesh
  51104. * @param target The mesh that the specified node will be attached to
  51105. */
  51106. attach(target: Mesh): void;
  51107. /**
  51108. * Detaches the behavior from the mesh
  51109. */
  51110. detach(): void;
  51111. }
  51112. }
  51113. declare module BABYLON {
  51114. /**
  51115. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  51116. */
  51117. export class FadeInOutBehavior implements Behavior<Mesh> {
  51118. /**
  51119. * Time in milliseconds to delay before fading in (Default: 0)
  51120. */
  51121. delay: number;
  51122. /**
  51123. * Time in milliseconds for the mesh to fade in (Default: 300)
  51124. */
  51125. fadeInTime: number;
  51126. private _millisecondsPerFrame;
  51127. private _hovered;
  51128. private _hoverValue;
  51129. private _ownerNode;
  51130. /**
  51131. * Instantiates the FadeInOutBehavior
  51132. */
  51133. constructor();
  51134. /**
  51135. * The name of the behavior
  51136. */
  51137. get name(): string;
  51138. /**
  51139. * Initializes the behavior
  51140. */
  51141. init(): void;
  51142. /**
  51143. * Attaches the fade behavior on the passed in mesh
  51144. * @param ownerNode The mesh that will be faded in/out once attached
  51145. */
  51146. attach(ownerNode: Mesh): void;
  51147. /**
  51148. * Detaches the behavior from the mesh
  51149. */
  51150. detach(): void;
  51151. /**
  51152. * Triggers the mesh to begin fading in or out
  51153. * @param value if the object should fade in or out (true to fade in)
  51154. */
  51155. fadeIn(value: boolean): void;
  51156. private _update;
  51157. private _setAllVisibility;
  51158. }
  51159. }
  51160. declare module BABYLON {
  51161. /**
  51162. * Class containing a set of static utilities functions for managing Pivots
  51163. * @hidden
  51164. */
  51165. export class PivotTools {
  51166. private static _PivotCached;
  51167. private static _OldPivotPoint;
  51168. private static _PivotTranslation;
  51169. private static _PivotTmpVector;
  51170. private static _PivotPostMultiplyPivotMatrix;
  51171. /** @hidden */
  51172. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  51173. /** @hidden */
  51174. static _RestorePivotPoint(mesh: AbstractMesh): void;
  51175. }
  51176. }
  51177. declare module BABYLON {
  51178. /**
  51179. * Class containing static functions to help procedurally build meshes
  51180. */
  51181. export class PlaneBuilder {
  51182. /**
  51183. * Creates a plane mesh
  51184. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  51185. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  51186. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  51187. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51188. * * 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
  51189. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51190. * @param name defines the name of the mesh
  51191. * @param options defines the options used to create the mesh
  51192. * @param scene defines the hosting scene
  51193. * @returns the plane mesh
  51194. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  51195. */
  51196. static CreatePlane(name: string, options: {
  51197. size?: number;
  51198. width?: number;
  51199. height?: number;
  51200. sideOrientation?: number;
  51201. frontUVs?: Vector4;
  51202. backUVs?: Vector4;
  51203. updatable?: boolean;
  51204. sourcePlane?: Plane;
  51205. }, scene?: Nullable<Scene>): Mesh;
  51206. }
  51207. }
  51208. declare module BABYLON {
  51209. /**
  51210. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  51211. */
  51212. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  51213. private static _AnyMouseID;
  51214. /**
  51215. * Abstract mesh the behavior is set on
  51216. */
  51217. attachedNode: AbstractMesh;
  51218. private _dragPlane;
  51219. private _scene;
  51220. private _pointerObserver;
  51221. private _beforeRenderObserver;
  51222. private static _planeScene;
  51223. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  51224. /**
  51225. * 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)
  51226. */
  51227. maxDragAngle: number;
  51228. /**
  51229. * @hidden
  51230. */
  51231. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  51232. /**
  51233. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  51234. */
  51235. currentDraggingPointerID: number;
  51236. /**
  51237. * The last position where the pointer hit the drag plane in world space
  51238. */
  51239. lastDragPosition: Vector3;
  51240. /**
  51241. * If the behavior is currently in a dragging state
  51242. */
  51243. dragging: boolean;
  51244. /**
  51245. * 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)
  51246. */
  51247. dragDeltaRatio: number;
  51248. /**
  51249. * If the drag plane orientation should be updated during the dragging (Default: true)
  51250. */
  51251. updateDragPlane: boolean;
  51252. private _debugMode;
  51253. private _moving;
  51254. /**
  51255. * Fires each time the attached mesh is dragged with the pointer
  51256. * * delta between last drag position and current drag position in world space
  51257. * * dragDistance along the drag axis
  51258. * * dragPlaneNormal normal of the current drag plane used during the drag
  51259. * * dragPlanePoint in world space where the drag intersects the drag plane
  51260. */
  51261. onDragObservable: Observable<{
  51262. delta: Vector3;
  51263. dragPlanePoint: Vector3;
  51264. dragPlaneNormal: Vector3;
  51265. dragDistance: number;
  51266. pointerId: number;
  51267. }>;
  51268. /**
  51269. * Fires each time a drag begins (eg. mouse down on mesh)
  51270. */
  51271. onDragStartObservable: Observable<{
  51272. dragPlanePoint: Vector3;
  51273. pointerId: number;
  51274. }>;
  51275. /**
  51276. * Fires each time a drag ends (eg. mouse release after drag)
  51277. */
  51278. onDragEndObservable: Observable<{
  51279. dragPlanePoint: Vector3;
  51280. pointerId: number;
  51281. }>;
  51282. /**
  51283. * If the attached mesh should be moved when dragged
  51284. */
  51285. moveAttached: boolean;
  51286. /**
  51287. * If the drag behavior will react to drag events (Default: true)
  51288. */
  51289. enabled: boolean;
  51290. /**
  51291. * If pointer events should start and release the drag (Default: true)
  51292. */
  51293. startAndReleaseDragOnPointerEvents: boolean;
  51294. /**
  51295. * If camera controls should be detached during the drag
  51296. */
  51297. detachCameraControls: boolean;
  51298. /**
  51299. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  51300. */
  51301. useObjectOrientationForDragging: boolean;
  51302. private _options;
  51303. /**
  51304. * Gets the options used by the behavior
  51305. */
  51306. get options(): {
  51307. dragAxis?: Vector3;
  51308. dragPlaneNormal?: Vector3;
  51309. };
  51310. /**
  51311. * Sets the options used by the behavior
  51312. */
  51313. set options(options: {
  51314. dragAxis?: Vector3;
  51315. dragPlaneNormal?: Vector3;
  51316. });
  51317. /**
  51318. * Creates a pointer drag behavior that can be attached to a mesh
  51319. * @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)
  51320. */
  51321. constructor(options?: {
  51322. dragAxis?: Vector3;
  51323. dragPlaneNormal?: Vector3;
  51324. });
  51325. /**
  51326. * Predicate to determine if it is valid to move the object to a new position when it is moved
  51327. */
  51328. validateDrag: (targetPosition: Vector3) => boolean;
  51329. /**
  51330. * The name of the behavior
  51331. */
  51332. get name(): string;
  51333. /**
  51334. * Initializes the behavior
  51335. */
  51336. init(): void;
  51337. private _tmpVector;
  51338. private _alternatePickedPoint;
  51339. private _worldDragAxis;
  51340. private _targetPosition;
  51341. private _attachedToElement;
  51342. /**
  51343. * Attaches the drag behavior the passed in mesh
  51344. * @param ownerNode The mesh that will be dragged around once attached
  51345. * @param predicate Predicate to use for pick filtering
  51346. */
  51347. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  51348. /**
  51349. * Force release the drag action by code.
  51350. */
  51351. releaseDrag(): void;
  51352. private _startDragRay;
  51353. private _lastPointerRay;
  51354. /**
  51355. * Simulates the start of a pointer drag event on the behavior
  51356. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  51357. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  51358. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  51359. */
  51360. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  51361. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  51362. private _dragDelta;
  51363. protected _moveDrag(ray: Ray): void;
  51364. private _pickWithRayOnDragPlane;
  51365. private _pointA;
  51366. private _pointC;
  51367. private _localAxis;
  51368. private _lookAt;
  51369. private _updateDragPlanePosition;
  51370. /**
  51371. * Detaches the behavior from the mesh
  51372. */
  51373. detach(): void;
  51374. }
  51375. }
  51376. declare module BABYLON {
  51377. /**
  51378. * A behavior that when attached to a mesh will allow the mesh to be scaled
  51379. */
  51380. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  51381. private _dragBehaviorA;
  51382. private _dragBehaviorB;
  51383. private _startDistance;
  51384. private _initialScale;
  51385. private _targetScale;
  51386. private _ownerNode;
  51387. private _sceneRenderObserver;
  51388. /**
  51389. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  51390. */
  51391. constructor();
  51392. /**
  51393. * The name of the behavior
  51394. */
  51395. get name(): string;
  51396. /**
  51397. * Initializes the behavior
  51398. */
  51399. init(): void;
  51400. private _getCurrentDistance;
  51401. /**
  51402. * Attaches the scale behavior the passed in mesh
  51403. * @param ownerNode The mesh that will be scaled around once attached
  51404. */
  51405. attach(ownerNode: Mesh): void;
  51406. /**
  51407. * Detaches the behavior from the mesh
  51408. */
  51409. detach(): void;
  51410. }
  51411. }
  51412. declare module BABYLON {
  51413. /**
  51414. * 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
  51415. */
  51416. export class SixDofDragBehavior implements Behavior<Mesh> {
  51417. private static _virtualScene;
  51418. private _ownerNode;
  51419. private _sceneRenderObserver;
  51420. private _scene;
  51421. private _targetPosition;
  51422. private _virtualOriginMesh;
  51423. private _virtualDragMesh;
  51424. private _pointerObserver;
  51425. private _moving;
  51426. private _startingOrientation;
  51427. private _attachedToElement;
  51428. /**
  51429. * 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)
  51430. */
  51431. private zDragFactor;
  51432. /**
  51433. * If the object should rotate to face the drag origin
  51434. */
  51435. rotateDraggedObject: boolean;
  51436. /**
  51437. * If the behavior is currently in a dragging state
  51438. */
  51439. dragging: boolean;
  51440. /**
  51441. * 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)
  51442. */
  51443. dragDeltaRatio: number;
  51444. /**
  51445. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  51446. */
  51447. currentDraggingPointerID: number;
  51448. /**
  51449. * If camera controls should be detached during the drag
  51450. */
  51451. detachCameraControls: boolean;
  51452. /**
  51453. * Fires each time a drag starts
  51454. */
  51455. onDragStartObservable: Observable<{}>;
  51456. /**
  51457. * Fires each time a drag happens
  51458. */
  51459. onDragObservable: Observable<void>;
  51460. /**
  51461. * Fires each time a drag ends (eg. mouse release after drag)
  51462. */
  51463. onDragEndObservable: Observable<{}>;
  51464. /**
  51465. * 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
  51466. */
  51467. constructor();
  51468. /**
  51469. * The name of the behavior
  51470. */
  51471. get name(): string;
  51472. /**
  51473. * Initializes the behavior
  51474. */
  51475. init(): void;
  51476. /**
  51477. * In the case of multiple active cameras, the cameraToUseForPointers should be used if set instead of active camera
  51478. */
  51479. private get _pointerCamera();
  51480. /**
  51481. * Attaches the scale behavior the passed in mesh
  51482. * @param ownerNode The mesh that will be scaled around once attached
  51483. */
  51484. attach(ownerNode: Mesh): void;
  51485. /**
  51486. * Detaches the behavior from the mesh
  51487. */
  51488. detach(): void;
  51489. }
  51490. }
  51491. declare module BABYLON {
  51492. /**
  51493. * Class used to apply inverse kinematics to bones
  51494. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  51495. */
  51496. export class BoneIKController {
  51497. private static _tmpVecs;
  51498. private static _tmpQuat;
  51499. private static _tmpMats;
  51500. /**
  51501. * Gets or sets the target mesh
  51502. */
  51503. targetMesh: AbstractMesh;
  51504. /** Gets or sets the mesh used as pole */
  51505. poleTargetMesh: AbstractMesh;
  51506. /**
  51507. * Gets or sets the bone used as pole
  51508. */
  51509. poleTargetBone: Nullable<Bone>;
  51510. /**
  51511. * Gets or sets the target position
  51512. */
  51513. targetPosition: Vector3;
  51514. /**
  51515. * Gets or sets the pole target position
  51516. */
  51517. poleTargetPosition: Vector3;
  51518. /**
  51519. * Gets or sets the pole target local offset
  51520. */
  51521. poleTargetLocalOffset: Vector3;
  51522. /**
  51523. * Gets or sets the pole angle
  51524. */
  51525. poleAngle: number;
  51526. /**
  51527. * Gets or sets the mesh associated with the controller
  51528. */
  51529. mesh: AbstractMesh;
  51530. /**
  51531. * 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)
  51532. */
  51533. slerpAmount: number;
  51534. private _bone1Quat;
  51535. private _bone1Mat;
  51536. private _bone2Ang;
  51537. private _bone1;
  51538. private _bone2;
  51539. private _bone1Length;
  51540. private _bone2Length;
  51541. private _maxAngle;
  51542. private _maxReach;
  51543. private _rightHandedSystem;
  51544. private _bendAxis;
  51545. private _slerping;
  51546. private _adjustRoll;
  51547. /**
  51548. * Gets or sets maximum allowed angle
  51549. */
  51550. get maxAngle(): number;
  51551. set maxAngle(value: number);
  51552. /**
  51553. * Creates a new BoneIKController
  51554. * @param mesh defines the mesh to control
  51555. * @param bone defines the bone to control
  51556. * @param options defines options to set up the controller
  51557. */
  51558. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  51559. targetMesh?: AbstractMesh;
  51560. poleTargetMesh?: AbstractMesh;
  51561. poleTargetBone?: Bone;
  51562. poleTargetLocalOffset?: Vector3;
  51563. poleAngle?: number;
  51564. bendAxis?: Vector3;
  51565. maxAngle?: number;
  51566. slerpAmount?: number;
  51567. });
  51568. private _setMaxAngle;
  51569. /**
  51570. * Force the controller to update the bones
  51571. */
  51572. update(): void;
  51573. }
  51574. }
  51575. declare module BABYLON {
  51576. /**
  51577. * Class used to make a bone look toward a point in space
  51578. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  51579. */
  51580. export class BoneLookController {
  51581. private static _tmpVecs;
  51582. private static _tmpQuat;
  51583. private static _tmpMats;
  51584. /**
  51585. * The target Vector3 that the bone will look at
  51586. */
  51587. target: Vector3;
  51588. /**
  51589. * The mesh that the bone is attached to
  51590. */
  51591. mesh: AbstractMesh;
  51592. /**
  51593. * The bone that will be looking to the target
  51594. */
  51595. bone: Bone;
  51596. /**
  51597. * The up axis of the coordinate system that is used when the bone is rotated
  51598. */
  51599. upAxis: Vector3;
  51600. /**
  51601. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  51602. */
  51603. upAxisSpace: Space;
  51604. /**
  51605. * Used to make an adjustment to the yaw of the bone
  51606. */
  51607. adjustYaw: number;
  51608. /**
  51609. * Used to make an adjustment to the pitch of the bone
  51610. */
  51611. adjustPitch: number;
  51612. /**
  51613. * Used to make an adjustment to the roll of the bone
  51614. */
  51615. adjustRoll: number;
  51616. /**
  51617. * 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)
  51618. */
  51619. slerpAmount: number;
  51620. private _minYaw;
  51621. private _maxYaw;
  51622. private _minPitch;
  51623. private _maxPitch;
  51624. private _minYawSin;
  51625. private _minYawCos;
  51626. private _maxYawSin;
  51627. private _maxYawCos;
  51628. private _midYawConstraint;
  51629. private _minPitchTan;
  51630. private _maxPitchTan;
  51631. private _boneQuat;
  51632. private _slerping;
  51633. private _transformYawPitch;
  51634. private _transformYawPitchInv;
  51635. private _firstFrameSkipped;
  51636. private _yawRange;
  51637. private _fowardAxis;
  51638. /**
  51639. * Gets or sets the minimum yaw angle that the bone can look to
  51640. */
  51641. get minYaw(): number;
  51642. set minYaw(value: number);
  51643. /**
  51644. * Gets or sets the maximum yaw angle that the bone can look to
  51645. */
  51646. get maxYaw(): number;
  51647. set maxYaw(value: number);
  51648. /**
  51649. * Gets or sets the minimum pitch angle that the bone can look to
  51650. */
  51651. get minPitch(): number;
  51652. set minPitch(value: number);
  51653. /**
  51654. * Gets or sets the maximum pitch angle that the bone can look to
  51655. */
  51656. get maxPitch(): number;
  51657. set maxPitch(value: number);
  51658. /**
  51659. * Create a BoneLookController
  51660. * @param mesh the mesh that the bone belongs to
  51661. * @param bone the bone that will be looking to the target
  51662. * @param target the target Vector3 to look at
  51663. * @param options optional settings:
  51664. * * maxYaw: the maximum angle the bone will yaw to
  51665. * * minYaw: the minimum angle the bone will yaw to
  51666. * * maxPitch: the maximum angle the bone will pitch to
  51667. * * minPitch: the minimum angle the bone will yaw to
  51668. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  51669. * * upAxis: the up axis of the coordinate system
  51670. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  51671. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  51672. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  51673. * * adjustYaw: used to make an adjustment to the yaw of the bone
  51674. * * adjustPitch: used to make an adjustment to the pitch of the bone
  51675. * * adjustRoll: used to make an adjustment to the roll of the bone
  51676. **/
  51677. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  51678. maxYaw?: number;
  51679. minYaw?: number;
  51680. maxPitch?: number;
  51681. minPitch?: number;
  51682. slerpAmount?: number;
  51683. upAxis?: Vector3;
  51684. upAxisSpace?: Space;
  51685. yawAxis?: Vector3;
  51686. pitchAxis?: Vector3;
  51687. adjustYaw?: number;
  51688. adjustPitch?: number;
  51689. adjustRoll?: number;
  51690. });
  51691. /**
  51692. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  51693. */
  51694. update(): void;
  51695. private _getAngleDiff;
  51696. private _getAngleBetween;
  51697. private _isAngleBetween;
  51698. }
  51699. }
  51700. declare module BABYLON {
  51701. /**
  51702. * Manage the gamepad inputs to control an arc rotate camera.
  51703. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51704. */
  51705. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  51706. /**
  51707. * Defines the camera the input is attached to.
  51708. */
  51709. camera: ArcRotateCamera;
  51710. /**
  51711. * Defines the gamepad the input is gathering event from.
  51712. */
  51713. gamepad: Nullable<Gamepad>;
  51714. /**
  51715. * Defines the gamepad rotation sensiblity.
  51716. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  51717. */
  51718. gamepadRotationSensibility: number;
  51719. /**
  51720. * Defines the gamepad move sensiblity.
  51721. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  51722. */
  51723. gamepadMoveSensibility: number;
  51724. private _yAxisScale;
  51725. /**
  51726. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  51727. */
  51728. get invertYAxis(): boolean;
  51729. set invertYAxis(value: boolean);
  51730. private _onGamepadConnectedObserver;
  51731. private _onGamepadDisconnectedObserver;
  51732. /**
  51733. * Attach the input controls to a specific dom element to get the input from.
  51734. */
  51735. attachControl(): void;
  51736. /**
  51737. * Detach the current controls from the specified dom element.
  51738. */
  51739. detachControl(): void;
  51740. /**
  51741. * Update the current camera state depending on the inputs that have been used this frame.
  51742. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  51743. */
  51744. checkInputs(): void;
  51745. /**
  51746. * Gets the class name of the current intput.
  51747. * @returns the class name
  51748. */
  51749. getClassName(): string;
  51750. /**
  51751. * Get the friendly name associated with the input class.
  51752. * @returns the input friendly name
  51753. */
  51754. getSimpleName(): string;
  51755. }
  51756. }
  51757. declare module BABYLON {
  51758. interface ArcRotateCameraInputsManager {
  51759. /**
  51760. * Add orientation input support to the input manager.
  51761. * @returns the current input manager
  51762. */
  51763. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  51764. }
  51765. /**
  51766. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  51767. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51768. */
  51769. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  51770. /**
  51771. * Defines the camera the input is attached to.
  51772. */
  51773. camera: ArcRotateCamera;
  51774. /**
  51775. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  51776. */
  51777. alphaCorrection: number;
  51778. /**
  51779. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  51780. */
  51781. gammaCorrection: number;
  51782. private _alpha;
  51783. private _gamma;
  51784. private _dirty;
  51785. private _deviceOrientationHandler;
  51786. /**
  51787. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  51788. */
  51789. constructor();
  51790. /**
  51791. * Attach the input controls to a specific dom element to get the input from.
  51792. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51793. */
  51794. attachControl(noPreventDefault?: boolean): void;
  51795. /** @hidden */
  51796. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  51797. /**
  51798. * Update the current camera state depending on the inputs that have been used this frame.
  51799. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  51800. */
  51801. checkInputs(): void;
  51802. /**
  51803. * Detach the current controls from the specified dom element.
  51804. */
  51805. detachControl(): void;
  51806. /**
  51807. * Gets the class name of the current input.
  51808. * @returns the class name
  51809. */
  51810. getClassName(): string;
  51811. /**
  51812. * Get the friendly name associated with the input class.
  51813. * @returns the input friendly name
  51814. */
  51815. getSimpleName(): string;
  51816. }
  51817. }
  51818. declare module BABYLON {
  51819. /**
  51820. * Listen to mouse events to control the camera.
  51821. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51822. */
  51823. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  51824. /**
  51825. * Defines the camera the input is attached to.
  51826. */
  51827. camera: FlyCamera;
  51828. /**
  51829. * Defines if touch is enabled. (Default is true.)
  51830. */
  51831. touchEnabled: boolean;
  51832. /**
  51833. * Defines the buttons associated with the input to handle camera rotation.
  51834. */
  51835. buttons: number[];
  51836. /**
  51837. * Assign buttons for Yaw control.
  51838. */
  51839. buttonsYaw: number[];
  51840. /**
  51841. * Assign buttons for Pitch control.
  51842. */
  51843. buttonsPitch: number[];
  51844. /**
  51845. * Assign buttons for Roll control.
  51846. */
  51847. buttonsRoll: number[];
  51848. /**
  51849. * Detect if any button is being pressed while mouse is moved.
  51850. * -1 = Mouse locked.
  51851. * 0 = Left button.
  51852. * 1 = Middle Button.
  51853. * 2 = Right Button.
  51854. */
  51855. activeButton: number;
  51856. /**
  51857. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  51858. * Higher values reduce its sensitivity.
  51859. */
  51860. angularSensibility: number;
  51861. private _observer;
  51862. private _rollObserver;
  51863. private previousPosition;
  51864. private noPreventDefault;
  51865. private element;
  51866. /**
  51867. * Listen to mouse events to control the camera.
  51868. * @param touchEnabled Define if touch is enabled. (Default is true.)
  51869. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51870. */
  51871. constructor(touchEnabled?: boolean);
  51872. /**
  51873. * Attach the mouse control to the HTML DOM element.
  51874. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  51875. */
  51876. attachControl(noPreventDefault?: boolean): void;
  51877. /**
  51878. * Detach the current controls from the specified dom element.
  51879. */
  51880. detachControl(): void;
  51881. /**
  51882. * Gets the class name of the current input.
  51883. * @returns the class name.
  51884. */
  51885. getClassName(): string;
  51886. /**
  51887. * Get the friendly name associated with the input class.
  51888. * @returns the input's friendly name.
  51889. */
  51890. getSimpleName(): string;
  51891. private _pointerInput;
  51892. private _onMouseMove;
  51893. /**
  51894. * Rotate camera by mouse offset.
  51895. */
  51896. private rotateCamera;
  51897. }
  51898. }
  51899. declare module BABYLON {
  51900. /**
  51901. * Default Inputs manager for the FlyCamera.
  51902. * It groups all the default supported inputs for ease of use.
  51903. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51904. */
  51905. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  51906. /**
  51907. * Instantiates a new FlyCameraInputsManager.
  51908. * @param camera Defines the camera the inputs belong to.
  51909. */
  51910. constructor(camera: FlyCamera);
  51911. /**
  51912. * Add keyboard input support to the input manager.
  51913. * @returns the new FlyCameraKeyboardMoveInput().
  51914. */
  51915. addKeyboard(): FlyCameraInputsManager;
  51916. /**
  51917. * Add mouse input support to the input manager.
  51918. * @param touchEnabled Enable touch screen support.
  51919. * @returns the new FlyCameraMouseInput().
  51920. */
  51921. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  51922. }
  51923. }
  51924. declare module BABYLON {
  51925. /**
  51926. * This is a flying camera, designed for 3D movement and rotation in all directions,
  51927. * such as in a 3D Space Shooter or a Flight Simulator.
  51928. */
  51929. export class FlyCamera extends TargetCamera {
  51930. /**
  51931. * Define the collision ellipsoid of the camera.
  51932. * This is helpful for simulating a camera body, like a player's body.
  51933. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  51934. */
  51935. ellipsoid: Vector3;
  51936. /**
  51937. * Define an offset for the position of the ellipsoid around the camera.
  51938. * This can be helpful if the camera is attached away from the player's body center,
  51939. * such as at its head.
  51940. */
  51941. ellipsoidOffset: Vector3;
  51942. /**
  51943. * Enable or disable collisions of the camera with the rest of the scene objects.
  51944. */
  51945. checkCollisions: boolean;
  51946. /**
  51947. * Enable or disable gravity on the camera.
  51948. */
  51949. applyGravity: boolean;
  51950. /**
  51951. * Define the current direction the camera is moving to.
  51952. */
  51953. cameraDirection: Vector3;
  51954. /**
  51955. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  51956. * This overrides and empties cameraRotation.
  51957. */
  51958. rotationQuaternion: Quaternion;
  51959. /**
  51960. * Track Roll to maintain the wanted Rolling when looking around.
  51961. */
  51962. _trackRoll: number;
  51963. /**
  51964. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  51965. */
  51966. rollCorrect: number;
  51967. /**
  51968. * Mimic a banked turn, Rolling the camera when Yawing.
  51969. * It's recommended to use rollCorrect = 10 for faster banking correction.
  51970. */
  51971. bankedTurn: boolean;
  51972. /**
  51973. * Limit in radians for how much Roll banking will add. (Default: 90°)
  51974. */
  51975. bankedTurnLimit: number;
  51976. /**
  51977. * Value of 0 disables the banked Roll.
  51978. * Value of 1 is equal to the Yaw angle in radians.
  51979. */
  51980. bankedTurnMultiplier: number;
  51981. /**
  51982. * The inputs manager loads all the input sources, such as keyboard and mouse.
  51983. */
  51984. inputs: FlyCameraInputsManager;
  51985. /**
  51986. * Gets the input sensibility for mouse input.
  51987. * Higher values reduce sensitivity.
  51988. */
  51989. get angularSensibility(): number;
  51990. /**
  51991. * Sets the input sensibility for a mouse input.
  51992. * Higher values reduce sensitivity.
  51993. */
  51994. set angularSensibility(value: number);
  51995. /**
  51996. * Get the keys for camera movement forward.
  51997. */
  51998. get keysForward(): number[];
  51999. /**
  52000. * Set the keys for camera movement forward.
  52001. */
  52002. set keysForward(value: number[]);
  52003. /**
  52004. * Get the keys for camera movement backward.
  52005. */
  52006. get keysBackward(): number[];
  52007. set keysBackward(value: number[]);
  52008. /**
  52009. * Get the keys for camera movement up.
  52010. */
  52011. get keysUp(): number[];
  52012. /**
  52013. * Set the keys for camera movement up.
  52014. */
  52015. set keysUp(value: number[]);
  52016. /**
  52017. * Get the keys for camera movement down.
  52018. */
  52019. get keysDown(): number[];
  52020. /**
  52021. * Set the keys for camera movement down.
  52022. */
  52023. set keysDown(value: number[]);
  52024. /**
  52025. * Get the keys for camera movement left.
  52026. */
  52027. get keysLeft(): number[];
  52028. /**
  52029. * Set the keys for camera movement left.
  52030. */
  52031. set keysLeft(value: number[]);
  52032. /**
  52033. * Set the keys for camera movement right.
  52034. */
  52035. get keysRight(): number[];
  52036. /**
  52037. * Set the keys for camera movement right.
  52038. */
  52039. set keysRight(value: number[]);
  52040. /**
  52041. * Event raised when the camera collides with a mesh in the scene.
  52042. */
  52043. onCollide: (collidedMesh: AbstractMesh) => void;
  52044. private _collider;
  52045. private _needMoveForGravity;
  52046. private _oldPosition;
  52047. private _diffPosition;
  52048. private _newPosition;
  52049. /** @hidden */
  52050. _localDirection: Vector3;
  52051. /** @hidden */
  52052. _transformedDirection: Vector3;
  52053. /**
  52054. * Instantiates a FlyCamera.
  52055. * This is a flying camera, designed for 3D movement and rotation in all directions,
  52056. * such as in a 3D Space Shooter or a Flight Simulator.
  52057. * @param name Define the name of the camera in the scene.
  52058. * @param position Define the starting position of the camera in the scene.
  52059. * @param scene Define the scene the camera belongs to.
  52060. * @param setActiveOnSceneIfNoneActive Defines whether the camera should be marked as active, if no other camera has been defined as active.
  52061. */
  52062. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  52063. /**
  52064. * Attach the input controls to a specific dom element to get the input from.
  52065. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  52066. */
  52067. attachControl(noPreventDefault?: boolean): void;
  52068. /**
  52069. * Detach a control from the HTML DOM element.
  52070. * The camera will stop reacting to that input.
  52071. */
  52072. detachControl(): void;
  52073. private _collisionMask;
  52074. /**
  52075. * Get the mask that the camera ignores in collision events.
  52076. */
  52077. get collisionMask(): number;
  52078. /**
  52079. * Set the mask that the camera ignores in collision events.
  52080. */
  52081. set collisionMask(mask: number);
  52082. /** @hidden */
  52083. _collideWithWorld(displacement: Vector3): void;
  52084. /** @hidden */
  52085. private _onCollisionPositionChange;
  52086. /** @hidden */
  52087. _checkInputs(): void;
  52088. /** @hidden */
  52089. _decideIfNeedsToMove(): boolean;
  52090. /** @hidden */
  52091. _updatePosition(): void;
  52092. /**
  52093. * Restore the Roll to its target value at the rate specified.
  52094. * @param rate - Higher means slower restoring.
  52095. * @hidden
  52096. */
  52097. restoreRoll(rate: number): void;
  52098. /**
  52099. * Destroy the camera and release the current resources held by it.
  52100. */
  52101. dispose(): void;
  52102. /**
  52103. * Get the current object class name.
  52104. * @returns the class name.
  52105. */
  52106. getClassName(): string;
  52107. }
  52108. }
  52109. declare module BABYLON {
  52110. /**
  52111. * Listen to keyboard events to control the camera.
  52112. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  52113. */
  52114. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  52115. /**
  52116. * Defines the camera the input is attached to.
  52117. */
  52118. camera: FlyCamera;
  52119. /**
  52120. * The list of keyboard keys used to control the forward move of the camera.
  52121. */
  52122. keysForward: number[];
  52123. /**
  52124. * The list of keyboard keys used to control the backward move of the camera.
  52125. */
  52126. keysBackward: number[];
  52127. /**
  52128. * The list of keyboard keys used to control the forward move of the camera.
  52129. */
  52130. keysUp: number[];
  52131. /**
  52132. * The list of keyboard keys used to control the backward move of the camera.
  52133. */
  52134. keysDown: number[];
  52135. /**
  52136. * The list of keyboard keys used to control the right strafe move of the camera.
  52137. */
  52138. keysRight: number[];
  52139. /**
  52140. * The list of keyboard keys used to control the left strafe move of the camera.
  52141. */
  52142. keysLeft: number[];
  52143. private _keys;
  52144. private _onCanvasBlurObserver;
  52145. private _onKeyboardObserver;
  52146. private _engine;
  52147. private _scene;
  52148. /**
  52149. * Attach the input controls to a specific dom element to get the input from.
  52150. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  52151. */
  52152. attachControl(noPreventDefault?: boolean): void;
  52153. /**
  52154. * Detach the current controls from the specified dom element.
  52155. */
  52156. detachControl(): void;
  52157. /**
  52158. * Gets the class name of the current intput.
  52159. * @returns the class name
  52160. */
  52161. getClassName(): string;
  52162. /** @hidden */
  52163. _onLostFocus(e: FocusEvent): void;
  52164. /**
  52165. * Get the friendly name associated with the input class.
  52166. * @returns the input friendly name
  52167. */
  52168. getSimpleName(): string;
  52169. /**
  52170. * Update the current camera state depending on the inputs that have been used this frame.
  52171. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  52172. */
  52173. checkInputs(): void;
  52174. }
  52175. }
  52176. declare module BABYLON {
  52177. /**
  52178. * Manage the mouse wheel inputs to control a follow camera.
  52179. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  52180. */
  52181. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  52182. /**
  52183. * Defines the camera the input is attached to.
  52184. */
  52185. camera: FollowCamera;
  52186. /**
  52187. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  52188. */
  52189. axisControlRadius: boolean;
  52190. /**
  52191. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  52192. */
  52193. axisControlHeight: boolean;
  52194. /**
  52195. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  52196. */
  52197. axisControlRotation: boolean;
  52198. /**
  52199. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  52200. * relation to mouseWheel events.
  52201. */
  52202. wheelPrecision: number;
  52203. /**
  52204. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  52205. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  52206. */
  52207. wheelDeltaPercentage: number;
  52208. private _wheel;
  52209. private _observer;
  52210. /**
  52211. * Attach the input controls to a specific dom element to get the input from.
  52212. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  52213. */
  52214. attachControl(noPreventDefault?: boolean): void;
  52215. /**
  52216. * Detach the current controls from the specified dom element.
  52217. */
  52218. detachControl(): void;
  52219. /**
  52220. * Gets the class name of the current input.
  52221. * @returns the class name
  52222. */
  52223. getClassName(): string;
  52224. /**
  52225. * Get the friendly name associated with the input class.
  52226. * @returns the input friendly name
  52227. */
  52228. getSimpleName(): string;
  52229. }
  52230. }
  52231. declare module BABYLON {
  52232. /**
  52233. * Manage the pointers inputs to control an follow camera.
  52234. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  52235. */
  52236. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  52237. /**
  52238. * Defines the camera the input is attached to.
  52239. */
  52240. camera: FollowCamera;
  52241. /**
  52242. * Gets the class name of the current input.
  52243. * @returns the class name
  52244. */
  52245. getClassName(): string;
  52246. /**
  52247. * Defines the pointer angular sensibility along the X axis or how fast is
  52248. * the camera rotating.
  52249. * A negative number will reverse the axis direction.
  52250. */
  52251. angularSensibilityX: number;
  52252. /**
  52253. * Defines the pointer angular sensibility along the Y axis or how fast is
  52254. * the camera rotating.
  52255. * A negative number will reverse the axis direction.
  52256. */
  52257. angularSensibilityY: number;
  52258. /**
  52259. * Defines the pointer pinch precision or how fast is the camera zooming.
  52260. * A negative number will reverse the axis direction.
  52261. */
  52262. pinchPrecision: number;
  52263. /**
  52264. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  52265. * from 0.
  52266. * It defines the percentage of current camera.radius to use as delta when
  52267. * pinch zoom is used.
  52268. */
  52269. pinchDeltaPercentage: number;
  52270. /**
  52271. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  52272. */
  52273. axisXControlRadius: boolean;
  52274. /**
  52275. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  52276. */
  52277. axisXControlHeight: boolean;
  52278. /**
  52279. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  52280. */
  52281. axisXControlRotation: boolean;
  52282. /**
  52283. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  52284. */
  52285. axisYControlRadius: boolean;
  52286. /**
  52287. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  52288. */
  52289. axisYControlHeight: boolean;
  52290. /**
  52291. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  52292. */
  52293. axisYControlRotation: boolean;
  52294. /**
  52295. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  52296. */
  52297. axisPinchControlRadius: boolean;
  52298. /**
  52299. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  52300. */
  52301. axisPinchControlHeight: boolean;
  52302. /**
  52303. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  52304. */
  52305. axisPinchControlRotation: boolean;
  52306. /**
  52307. * Log error messages if basic misconfiguration has occurred.
  52308. */
  52309. warningEnable: boolean;
  52310. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  52311. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  52312. private _warningCounter;
  52313. private _warning;
  52314. }
  52315. }
  52316. declare module BABYLON {
  52317. /**
  52318. * Default Inputs manager for the FollowCamera.
  52319. * It groups all the default supported inputs for ease of use.
  52320. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  52321. */
  52322. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  52323. /**
  52324. * Instantiates a new FollowCameraInputsManager.
  52325. * @param camera Defines the camera the inputs belong to
  52326. */
  52327. constructor(camera: FollowCamera);
  52328. /**
  52329. * Add keyboard input support to the input manager.
  52330. * @returns the current input manager
  52331. */
  52332. addKeyboard(): FollowCameraInputsManager;
  52333. /**
  52334. * Add mouse wheel input support to the input manager.
  52335. * @returns the current input manager
  52336. */
  52337. addMouseWheel(): FollowCameraInputsManager;
  52338. /**
  52339. * Add pointers input support to the input manager.
  52340. * @returns the current input manager
  52341. */
  52342. addPointers(): FollowCameraInputsManager;
  52343. /**
  52344. * Add orientation input support to the input manager.
  52345. * @returns the current input manager
  52346. */
  52347. addVRDeviceOrientation(): FollowCameraInputsManager;
  52348. }
  52349. }
  52350. declare module BABYLON {
  52351. /**
  52352. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  52353. * an arc rotate version arcFollowCamera are available.
  52354. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  52355. */
  52356. export class FollowCamera extends TargetCamera {
  52357. /**
  52358. * Distance the follow camera should follow an object at
  52359. */
  52360. radius: number;
  52361. /**
  52362. * Minimum allowed distance of the camera to the axis of rotation
  52363. * (The camera can not get closer).
  52364. * This can help limiting how the Camera is able to move in the scene.
  52365. */
  52366. lowerRadiusLimit: Nullable<number>;
  52367. /**
  52368. * Maximum allowed distance of the camera to the axis of rotation
  52369. * (The camera can not get further).
  52370. * This can help limiting how the Camera is able to move in the scene.
  52371. */
  52372. upperRadiusLimit: Nullable<number>;
  52373. /**
  52374. * Define a rotation offset between the camera and the object it follows
  52375. */
  52376. rotationOffset: number;
  52377. /**
  52378. * Minimum allowed angle to camera position relative to target object.
  52379. * This can help limiting how the Camera is able to move in the scene.
  52380. */
  52381. lowerRotationOffsetLimit: Nullable<number>;
  52382. /**
  52383. * Maximum allowed angle to camera position relative to target object.
  52384. * This can help limiting how the Camera is able to move in the scene.
  52385. */
  52386. upperRotationOffsetLimit: Nullable<number>;
  52387. /**
  52388. * Define a height offset between the camera and the object it follows.
  52389. * It can help following an object from the top (like a car chasing a plane)
  52390. */
  52391. heightOffset: number;
  52392. /**
  52393. * Minimum allowed height of camera position relative to target object.
  52394. * This can help limiting how the Camera is able to move in the scene.
  52395. */
  52396. lowerHeightOffsetLimit: Nullable<number>;
  52397. /**
  52398. * Maximum allowed height of camera position relative to target object.
  52399. * This can help limiting how the Camera is able to move in the scene.
  52400. */
  52401. upperHeightOffsetLimit: Nullable<number>;
  52402. /**
  52403. * Define how fast the camera can accelerate to follow it s target.
  52404. */
  52405. cameraAcceleration: number;
  52406. /**
  52407. * Define the speed limit of the camera following an object.
  52408. */
  52409. maxCameraSpeed: number;
  52410. /**
  52411. * Define the target of the camera.
  52412. */
  52413. lockedTarget: Nullable<AbstractMesh>;
  52414. /**
  52415. * Defines the input associated with the camera.
  52416. */
  52417. inputs: FollowCameraInputsManager;
  52418. /**
  52419. * Instantiates the follow camera.
  52420. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  52421. * @param name Define the name of the camera in the scene
  52422. * @param position Define the position of the camera
  52423. * @param scene Define the scene the camera belong to
  52424. * @param lockedTarget Define the target of the camera
  52425. */
  52426. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  52427. private _follow;
  52428. /**
  52429. * Attach the input controls to a specific dom element to get the input from.
  52430. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  52431. */
  52432. attachControl(noPreventDefault?: boolean): void;
  52433. /**
  52434. * Detach the current controls from the specified dom element.
  52435. */
  52436. detachControl(): void;
  52437. /** @hidden */
  52438. _checkInputs(): void;
  52439. private _checkLimits;
  52440. /**
  52441. * Gets the camera class name.
  52442. * @returns the class name
  52443. */
  52444. getClassName(): string;
  52445. }
  52446. /**
  52447. * Arc Rotate version of the follow camera.
  52448. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  52449. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  52450. */
  52451. export class ArcFollowCamera extends TargetCamera {
  52452. /** The longitudinal angle of the camera */
  52453. alpha: number;
  52454. /** The latitudinal angle of the camera */
  52455. beta: number;
  52456. /** The radius of the camera from its target */
  52457. radius: number;
  52458. private _cartesianCoordinates;
  52459. /** Define the camera target (the mesh it should follow) */
  52460. private _meshTarget;
  52461. /**
  52462. * Instantiates a new ArcFollowCamera
  52463. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  52464. * @param name Define the name of the camera
  52465. * @param alpha Define the rotation angle of the camera around the longitudinal axis
  52466. * @param beta Define the rotation angle of the camera around the elevation axis
  52467. * @param radius Define the radius of the camera from its target point
  52468. * @param target Define the target of the camera
  52469. * @param scene Define the scene the camera belongs to
  52470. */
  52471. constructor(name: string,
  52472. /** The longitudinal angle of the camera */
  52473. alpha: number,
  52474. /** The latitudinal angle of the camera */
  52475. beta: number,
  52476. /** The radius of the camera from its target */
  52477. radius: number,
  52478. /** Define the camera target (the mesh it should follow) */
  52479. target: Nullable<AbstractMesh>, scene: Scene);
  52480. private _follow;
  52481. /** @hidden */
  52482. _checkInputs(): void;
  52483. /**
  52484. * Returns the class name of the object.
  52485. * It is mostly used internally for serialization purposes.
  52486. */
  52487. getClassName(): string;
  52488. }
  52489. }
  52490. declare module BABYLON {
  52491. /**
  52492. * Manage the keyboard inputs to control the movement of a follow camera.
  52493. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  52494. */
  52495. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  52496. /**
  52497. * Defines the camera the input is attached to.
  52498. */
  52499. camera: FollowCamera;
  52500. /**
  52501. * Defines the list of key codes associated with the up action (increase heightOffset)
  52502. */
  52503. keysHeightOffsetIncr: number[];
  52504. /**
  52505. * Defines the list of key codes associated with the down action (decrease heightOffset)
  52506. */
  52507. keysHeightOffsetDecr: number[];
  52508. /**
  52509. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  52510. */
  52511. keysHeightOffsetModifierAlt: boolean;
  52512. /**
  52513. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  52514. */
  52515. keysHeightOffsetModifierCtrl: boolean;
  52516. /**
  52517. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  52518. */
  52519. keysHeightOffsetModifierShift: boolean;
  52520. /**
  52521. * Defines the list of key codes associated with the left action (increase rotationOffset)
  52522. */
  52523. keysRotationOffsetIncr: number[];
  52524. /**
  52525. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  52526. */
  52527. keysRotationOffsetDecr: number[];
  52528. /**
  52529. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  52530. */
  52531. keysRotationOffsetModifierAlt: boolean;
  52532. /**
  52533. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  52534. */
  52535. keysRotationOffsetModifierCtrl: boolean;
  52536. /**
  52537. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  52538. */
  52539. keysRotationOffsetModifierShift: boolean;
  52540. /**
  52541. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  52542. */
  52543. keysRadiusIncr: number[];
  52544. /**
  52545. * Defines the list of key codes associated with the zoom-out action (increase radius)
  52546. */
  52547. keysRadiusDecr: number[];
  52548. /**
  52549. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  52550. */
  52551. keysRadiusModifierAlt: boolean;
  52552. /**
  52553. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  52554. */
  52555. keysRadiusModifierCtrl: boolean;
  52556. /**
  52557. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  52558. */
  52559. keysRadiusModifierShift: boolean;
  52560. /**
  52561. * Defines the rate of change of heightOffset.
  52562. */
  52563. heightSensibility: number;
  52564. /**
  52565. * Defines the rate of change of rotationOffset.
  52566. */
  52567. rotationSensibility: number;
  52568. /**
  52569. * Defines the rate of change of radius.
  52570. */
  52571. radiusSensibility: number;
  52572. private _keys;
  52573. private _ctrlPressed;
  52574. private _altPressed;
  52575. private _shiftPressed;
  52576. private _onCanvasBlurObserver;
  52577. private _onKeyboardObserver;
  52578. private _engine;
  52579. private _scene;
  52580. /**
  52581. * Attach the input controls to a specific dom element to get the input from.
  52582. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  52583. */
  52584. attachControl(noPreventDefault?: boolean): void;
  52585. /**
  52586. * Detach the current controls from the specified dom element.
  52587. */
  52588. detachControl(): void;
  52589. /**
  52590. * Update the current camera state depending on the inputs that have been used this frame.
  52591. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  52592. */
  52593. checkInputs(): void;
  52594. /**
  52595. * Gets the class name of the current input.
  52596. * @returns the class name
  52597. */
  52598. getClassName(): string;
  52599. /**
  52600. * Get the friendly name associated with the input class.
  52601. * @returns the input friendly name
  52602. */
  52603. getSimpleName(): string;
  52604. /**
  52605. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  52606. * allow modification of the heightOffset value.
  52607. */
  52608. private _modifierHeightOffset;
  52609. /**
  52610. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  52611. * allow modification of the rotationOffset value.
  52612. */
  52613. private _modifierRotationOffset;
  52614. /**
  52615. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  52616. * allow modification of the radius value.
  52617. */
  52618. private _modifierRadius;
  52619. }
  52620. }
  52621. declare module BABYLON {
  52622. interface FreeCameraInputsManager {
  52623. /**
  52624. * @hidden
  52625. */
  52626. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  52627. /**
  52628. * Add orientation input support to the input manager.
  52629. * @returns the current input manager
  52630. */
  52631. addDeviceOrientation(): FreeCameraInputsManager;
  52632. }
  52633. /**
  52634. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  52635. * Screen rotation is taken into account.
  52636. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  52637. */
  52638. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  52639. private _camera;
  52640. private _screenOrientationAngle;
  52641. private _constantTranform;
  52642. private _screenQuaternion;
  52643. private _alpha;
  52644. private _beta;
  52645. private _gamma;
  52646. /**
  52647. * Can be used to detect if a device orientation sensor is available on a device
  52648. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  52649. * @returns a promise that will resolve on orientation change
  52650. */
  52651. static WaitForOrientationChangeAsync(timeout?: number): Promise<void>;
  52652. /**
  52653. * @hidden
  52654. */
  52655. _onDeviceOrientationChangedObservable: Observable<void>;
  52656. /**
  52657. * Instantiates a new input
  52658. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  52659. */
  52660. constructor();
  52661. /**
  52662. * Define the camera controlled by the input.
  52663. */
  52664. get camera(): FreeCamera;
  52665. set camera(camera: FreeCamera);
  52666. /**
  52667. * Attach the input controls to a specific dom element to get the input from.
  52668. */
  52669. attachControl(): void;
  52670. private _orientationChanged;
  52671. private _deviceOrientation;
  52672. /**
  52673. * Detach the current controls from the specified dom element.
  52674. */
  52675. detachControl(): void;
  52676. /**
  52677. * Update the current camera state depending on the inputs that have been used this frame.
  52678. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  52679. */
  52680. checkInputs(): void;
  52681. /**
  52682. * Gets the class name of the current input.
  52683. * @returns the class name
  52684. */
  52685. getClassName(): string;
  52686. /**
  52687. * Get the friendly name associated with the input class.
  52688. * @returns the input friendly name
  52689. */
  52690. getSimpleName(): string;
  52691. }
  52692. }
  52693. declare module BABYLON {
  52694. /**
  52695. * Manage the gamepad inputs to control a free camera.
  52696. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  52697. */
  52698. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  52699. /**
  52700. * Define the camera the input is attached to.
  52701. */
  52702. camera: FreeCamera;
  52703. /**
  52704. * Define the Gamepad controlling the input
  52705. */
  52706. gamepad: Nullable<Gamepad>;
  52707. /**
  52708. * Defines the gamepad rotation sensiblity.
  52709. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  52710. */
  52711. gamepadAngularSensibility: number;
  52712. /**
  52713. * Defines the gamepad move sensiblity.
  52714. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  52715. */
  52716. gamepadMoveSensibility: number;
  52717. private _yAxisScale;
  52718. /**
  52719. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  52720. */
  52721. get invertYAxis(): boolean;
  52722. set invertYAxis(value: boolean);
  52723. private _onGamepadConnectedObserver;
  52724. private _onGamepadDisconnectedObserver;
  52725. private _cameraTransform;
  52726. private _deltaTransform;
  52727. private _vector3;
  52728. private _vector2;
  52729. /**
  52730. * Attach the input controls to a specific dom element to get the input from.
  52731. */
  52732. attachControl(): void;
  52733. /**
  52734. * Detach the current controls from the specified dom element.
  52735. */
  52736. detachControl(): void;
  52737. /**
  52738. * Update the current camera state depending on the inputs that have been used this frame.
  52739. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  52740. */
  52741. checkInputs(): void;
  52742. /**
  52743. * Gets the class name of the current input.
  52744. * @returns the class name
  52745. */
  52746. getClassName(): string;
  52747. /**
  52748. * Get the friendly name associated with the input class.
  52749. * @returns the input friendly name
  52750. */
  52751. getSimpleName(): string;
  52752. }
  52753. }
  52754. declare module BABYLON {
  52755. /**
  52756. * Defines the potential axis of a Joystick
  52757. */
  52758. export enum JoystickAxis {
  52759. /** X axis */
  52760. X = 0,
  52761. /** Y axis */
  52762. Y = 1,
  52763. /** Z axis */
  52764. Z = 2
  52765. }
  52766. /**
  52767. * Represents the different customization options available
  52768. * for VirtualJoystick
  52769. */
  52770. interface VirtualJoystickCustomizations {
  52771. /**
  52772. * Size of the joystick's puck
  52773. */
  52774. puckSize: number;
  52775. /**
  52776. * Size of the joystick's container
  52777. */
  52778. containerSize: number;
  52779. /**
  52780. * Color of the joystick && puck
  52781. */
  52782. color: string;
  52783. /**
  52784. * Image URL for the joystick's puck
  52785. */
  52786. puckImage?: string;
  52787. /**
  52788. * Image URL for the joystick's container
  52789. */
  52790. containerImage?: string;
  52791. /**
  52792. * Defines the unmoving position of the joystick container
  52793. */
  52794. position?: {
  52795. x: number;
  52796. y: number;
  52797. };
  52798. /**
  52799. * Defines whether or not the joystick container is always visible
  52800. */
  52801. alwaysVisible: boolean;
  52802. /**
  52803. * Defines whether or not to limit the movement of the puck to the joystick's container
  52804. */
  52805. limitToContainer: boolean;
  52806. }
  52807. /**
  52808. * Class used to define virtual joystick (used in touch mode)
  52809. */
  52810. export class VirtualJoystick {
  52811. /**
  52812. * Gets or sets a boolean indicating that left and right values must be inverted
  52813. */
  52814. reverseLeftRight: boolean;
  52815. /**
  52816. * Gets or sets a boolean indicating that up and down values must be inverted
  52817. */
  52818. reverseUpDown: boolean;
  52819. /**
  52820. * Gets the offset value for the position (ie. the change of the position value)
  52821. */
  52822. deltaPosition: Vector3;
  52823. /**
  52824. * Gets a boolean indicating if the virtual joystick was pressed
  52825. */
  52826. pressed: boolean;
  52827. /**
  52828. * Canvas the virtual joystick will render onto, default z-index of this is 5
  52829. */
  52830. static Canvas: Nullable<HTMLCanvasElement>;
  52831. /**
  52832. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  52833. */
  52834. limitToContainer: boolean;
  52835. private static _globalJoystickIndex;
  52836. private static _alwaysVisibleSticks;
  52837. private static vjCanvasContext;
  52838. private static vjCanvasWidth;
  52839. private static vjCanvasHeight;
  52840. private static halfWidth;
  52841. private static _GetDefaultOptions;
  52842. private _action;
  52843. private _axisTargetedByLeftAndRight;
  52844. private _axisTargetedByUpAndDown;
  52845. private _joystickSensibility;
  52846. private _inversedSensibility;
  52847. private _joystickPointerID;
  52848. private _joystickColor;
  52849. private _joystickPointerPos;
  52850. private _joystickPreviousPointerPos;
  52851. private _joystickPointerStartPos;
  52852. private _deltaJoystickVector;
  52853. private _leftJoystick;
  52854. private _touches;
  52855. private _joystickPosition;
  52856. private _alwaysVisible;
  52857. private _puckImage;
  52858. private _containerImage;
  52859. private _joystickPuckSize;
  52860. private _joystickContainerSize;
  52861. private _clearPuckSize;
  52862. private _clearContainerSize;
  52863. private _clearPuckSizeOffset;
  52864. private _clearContainerSizeOffset;
  52865. private _onPointerDownHandlerRef;
  52866. private _onPointerMoveHandlerRef;
  52867. private _onPointerUpHandlerRef;
  52868. private _onResize;
  52869. /**
  52870. * Creates a new virtual joystick
  52871. * @param leftJoystick defines that the joystick is for left hand (false by default)
  52872. * @param customizations Defines the options we want to customize the VirtualJoystick
  52873. */
  52874. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  52875. /**
  52876. * Defines joystick sensibility (ie. the ratio between a physical move and virtual joystick position change)
  52877. * @param newJoystickSensibility defines the new sensibility
  52878. */
  52879. setJoystickSensibility(newJoystickSensibility: number): void;
  52880. private _onPointerDown;
  52881. private _onPointerMove;
  52882. private _onPointerUp;
  52883. /**
  52884. * Change the color of the virtual joystick
  52885. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  52886. */
  52887. setJoystickColor(newColor: string): void;
  52888. /**
  52889. * Size of the joystick's container
  52890. */
  52891. set containerSize(newSize: number);
  52892. get containerSize(): number;
  52893. /**
  52894. * Size of the joystick's puck
  52895. */
  52896. set puckSize(newSize: number);
  52897. get puckSize(): number;
  52898. /**
  52899. * Clears the set position of the joystick
  52900. */
  52901. clearPosition(): void;
  52902. /**
  52903. * Defines whether or not the joystick container is always visible
  52904. */
  52905. set alwaysVisible(value: boolean);
  52906. get alwaysVisible(): boolean;
  52907. /**
  52908. * Sets the constant position of the Joystick container
  52909. * @param x X axis coordinate
  52910. * @param y Y axis coordinate
  52911. */
  52912. setPosition(x: number, y: number): void;
  52913. /**
  52914. * Defines a callback to call when the joystick is touched
  52915. * @param action defines the callback
  52916. */
  52917. setActionOnTouch(action: () => any): void;
  52918. /**
  52919. * Defines which axis you'd like to control for left & right
  52920. * @param axis defines the axis to use
  52921. */
  52922. setAxisForLeftRight(axis: JoystickAxis): void;
  52923. /**
  52924. * Defines which axis you'd like to control for up & down
  52925. * @param axis defines the axis to use
  52926. */
  52927. setAxisForUpDown(axis: JoystickAxis): void;
  52928. /**
  52929. * Clears the canvas from the previous puck / container draw
  52930. */
  52931. private _clearPreviousDraw;
  52932. /**
  52933. * Loads `urlPath` to be used for the container's image
  52934. * @param urlPath defines the urlPath of an image to use
  52935. */
  52936. setContainerImage(urlPath: string): void;
  52937. /**
  52938. * Loads `urlPath` to be used for the puck's image
  52939. * @param urlPath defines the urlPath of an image to use
  52940. */
  52941. setPuckImage(urlPath: string): void;
  52942. /**
  52943. * Draws the Virtual Joystick's container
  52944. */
  52945. private _drawContainer;
  52946. /**
  52947. * Draws the Virtual Joystick's puck
  52948. */
  52949. private _drawPuck;
  52950. private _drawVirtualJoystick;
  52951. /**
  52952. * Release internal HTML canvas
  52953. */
  52954. releaseCanvas(): void;
  52955. }
  52956. }
  52957. declare module BABYLON {
  52958. interface FreeCameraInputsManager {
  52959. /**
  52960. * Add virtual joystick input support to the input manager.
  52961. * @returns the current input manager
  52962. */
  52963. addVirtualJoystick(): FreeCameraInputsManager;
  52964. }
  52965. /**
  52966. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  52967. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  52968. */
  52969. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  52970. /**
  52971. * Defines the camera the input is attached to.
  52972. */
  52973. camera: FreeCamera;
  52974. private _leftjoystick;
  52975. private _rightjoystick;
  52976. /**
  52977. * Gets the left stick of the virtual joystick.
  52978. * @returns The virtual Joystick
  52979. */
  52980. getLeftJoystick(): VirtualJoystick;
  52981. /**
  52982. * Gets the right stick of the virtual joystick.
  52983. * @returns The virtual Joystick
  52984. */
  52985. getRightJoystick(): VirtualJoystick;
  52986. /**
  52987. * Update the current camera state depending on the inputs that have been used this frame.
  52988. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  52989. */
  52990. checkInputs(): void;
  52991. /**
  52992. * Attach the input controls to a specific dom element to get the input from.
  52993. */
  52994. attachControl(): void;
  52995. /**
  52996. * Detach the current controls from the specified dom element.
  52997. */
  52998. detachControl(): void;
  52999. /**
  53000. * Gets the class name of the current input.
  53001. * @returns the class name
  53002. */
  53003. getClassName(): string;
  53004. /**
  53005. * Get the friendly name associated with the input class.
  53006. * @returns the input friendly name
  53007. */
  53008. getSimpleName(): string;
  53009. }
  53010. }
  53011. declare module BABYLON {
  53012. /**
  53013. * This represents a FPS type of camera controlled by touch.
  53014. * This is like a universal camera minus the Gamepad controls.
  53015. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  53016. */
  53017. export class TouchCamera extends FreeCamera {
  53018. /**
  53019. * Defines the touch sensibility for rotation.
  53020. * The higher the faster.
  53021. */
  53022. get touchAngularSensibility(): number;
  53023. set touchAngularSensibility(value: number);
  53024. /**
  53025. * Defines the touch sensibility for move.
  53026. * The higher the faster.
  53027. */
  53028. get touchMoveSensibility(): number;
  53029. set touchMoveSensibility(value: number);
  53030. /**
  53031. * Instantiates a new touch camera.
  53032. * This represents a FPS type of camera controlled by touch.
  53033. * This is like a universal camera minus the Gamepad controls.
  53034. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  53035. * @param name Define the name of the camera in the scene
  53036. * @param position Define the start position of the camera in the scene
  53037. * @param scene Define the scene the camera belongs to
  53038. */
  53039. constructor(name: string, position: Vector3, scene: Scene);
  53040. /**
  53041. * Gets the current object class name.
  53042. * @return the class name
  53043. */
  53044. getClassName(): string;
  53045. /** @hidden */
  53046. _setupInputs(): void;
  53047. }
  53048. }
  53049. declare module BABYLON {
  53050. /**
  53051. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  53052. * being tilted forward or back and left or right.
  53053. */
  53054. export class DeviceOrientationCamera extends FreeCamera {
  53055. private _initialQuaternion;
  53056. private _quaternionCache;
  53057. private _tmpDragQuaternion;
  53058. private _disablePointerInputWhenUsingDeviceOrientation;
  53059. /**
  53060. * Creates a new device orientation camera
  53061. * @param name The name of the camera
  53062. * @param position The start position camera
  53063. * @param scene The scene the camera belongs to
  53064. */
  53065. constructor(name: string, position: Vector3, scene: Scene);
  53066. /**
  53067. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  53068. */
  53069. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  53070. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  53071. private _dragFactor;
  53072. /**
  53073. * Enabled turning on the y axis when the orientation sensor is active
  53074. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  53075. */
  53076. enableHorizontalDragging(dragFactor?: number): void;
  53077. /**
  53078. * Gets the current instance class name ("DeviceOrientationCamera").
  53079. * This helps avoiding instanceof at run time.
  53080. * @returns the class name
  53081. */
  53082. getClassName(): string;
  53083. /**
  53084. * @hidden
  53085. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  53086. */
  53087. _checkInputs(): void;
  53088. /**
  53089. * Reset the camera to its default orientation on the specified axis only.
  53090. * @param axis The axis to reset
  53091. */
  53092. resetToCurrentRotation(axis?: Axis): void;
  53093. }
  53094. }
  53095. declare module BABYLON {
  53096. /**
  53097. * Defines supported buttons for XBox360 compatible gamepads
  53098. */
  53099. export enum Xbox360Button {
  53100. /** A */
  53101. A = 0,
  53102. /** B */
  53103. B = 1,
  53104. /** X */
  53105. X = 2,
  53106. /** Y */
  53107. Y = 3,
  53108. /** Left button */
  53109. LB = 4,
  53110. /** Right button */
  53111. RB = 5,
  53112. /** Back */
  53113. Back = 8,
  53114. /** Start */
  53115. Start = 9,
  53116. /** Left stick */
  53117. LeftStick = 10,
  53118. /** Right stick */
  53119. RightStick = 11
  53120. }
  53121. /** Defines values for XBox360 DPad */
  53122. export enum Xbox360Dpad {
  53123. /** Up */
  53124. Up = 12,
  53125. /** Down */
  53126. Down = 13,
  53127. /** Left */
  53128. Left = 14,
  53129. /** Right */
  53130. Right = 15
  53131. }
  53132. /**
  53133. * Defines a XBox360 gamepad
  53134. */
  53135. export class Xbox360Pad extends Gamepad {
  53136. private _leftTrigger;
  53137. private _rightTrigger;
  53138. private _onlefttriggerchanged;
  53139. private _onrighttriggerchanged;
  53140. private _onbuttondown;
  53141. private _onbuttonup;
  53142. private _ondpaddown;
  53143. private _ondpadup;
  53144. /** Observable raised when a button is pressed */
  53145. onButtonDownObservable: Observable<Xbox360Button>;
  53146. /** Observable raised when a button is released */
  53147. onButtonUpObservable: Observable<Xbox360Button>;
  53148. /** Observable raised when a pad is pressed */
  53149. onPadDownObservable: Observable<Xbox360Dpad>;
  53150. /** Observable raised when a pad is released */
  53151. onPadUpObservable: Observable<Xbox360Dpad>;
  53152. private _buttonA;
  53153. private _buttonB;
  53154. private _buttonX;
  53155. private _buttonY;
  53156. private _buttonBack;
  53157. private _buttonStart;
  53158. private _buttonLB;
  53159. private _buttonRB;
  53160. private _buttonLeftStick;
  53161. private _buttonRightStick;
  53162. private _dPadUp;
  53163. private _dPadDown;
  53164. private _dPadLeft;
  53165. private _dPadRight;
  53166. private _isXboxOnePad;
  53167. /**
  53168. * Creates a new XBox360 gamepad object
  53169. * @param id defines the id of this gamepad
  53170. * @param index defines its index
  53171. * @param gamepad defines the internal HTML gamepad object
  53172. * @param xboxOne defines if it is a XBox One gamepad
  53173. */
  53174. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  53175. /**
  53176. * Defines the callback to call when left trigger is pressed
  53177. * @param callback defines the callback to use
  53178. */
  53179. onlefttriggerchanged(callback: (value: number) => void): void;
  53180. /**
  53181. * Defines the callback to call when right trigger is pressed
  53182. * @param callback defines the callback to use
  53183. */
  53184. onrighttriggerchanged(callback: (value: number) => void): void;
  53185. /**
  53186. * Gets the left trigger value
  53187. */
  53188. get leftTrigger(): number;
  53189. /**
  53190. * Sets the left trigger value
  53191. */
  53192. set leftTrigger(newValue: number);
  53193. /**
  53194. * Gets the right trigger value
  53195. */
  53196. get rightTrigger(): number;
  53197. /**
  53198. * Sets the right trigger value
  53199. */
  53200. set rightTrigger(newValue: number);
  53201. /**
  53202. * Defines the callback to call when a button is pressed
  53203. * @param callback defines the callback to use
  53204. */
  53205. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  53206. /**
  53207. * Defines the callback to call when a button is released
  53208. * @param callback defines the callback to use
  53209. */
  53210. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  53211. /**
  53212. * Defines the callback to call when a pad is pressed
  53213. * @param callback defines the callback to use
  53214. */
  53215. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  53216. /**
  53217. * Defines the callback to call when a pad is released
  53218. * @param callback defines the callback to use
  53219. */
  53220. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  53221. private _setButtonValue;
  53222. private _setDPadValue;
  53223. /**
  53224. * Gets the value of the `A` button
  53225. */
  53226. get buttonA(): number;
  53227. /**
  53228. * Sets the value of the `A` button
  53229. */
  53230. set buttonA(value: number);
  53231. /**
  53232. * Gets the value of the `B` button
  53233. */
  53234. get buttonB(): number;
  53235. /**
  53236. * Sets the value of the `B` button
  53237. */
  53238. set buttonB(value: number);
  53239. /**
  53240. * Gets the value of the `X` button
  53241. */
  53242. get buttonX(): number;
  53243. /**
  53244. * Sets the value of the `X` button
  53245. */
  53246. set buttonX(value: number);
  53247. /**
  53248. * Gets the value of the `Y` button
  53249. */
  53250. get buttonY(): number;
  53251. /**
  53252. * Sets the value of the `Y` button
  53253. */
  53254. set buttonY(value: number);
  53255. /**
  53256. * Gets the value of the `Start` button
  53257. */
  53258. get buttonStart(): number;
  53259. /**
  53260. * Sets the value of the `Start` button
  53261. */
  53262. set buttonStart(value: number);
  53263. /**
  53264. * Gets the value of the `Back` button
  53265. */
  53266. get buttonBack(): number;
  53267. /**
  53268. * Sets the value of the `Back` button
  53269. */
  53270. set buttonBack(value: number);
  53271. /**
  53272. * Gets the value of the `Left` button
  53273. */
  53274. get buttonLB(): number;
  53275. /**
  53276. * Sets the value of the `Left` button
  53277. */
  53278. set buttonLB(value: number);
  53279. /**
  53280. * Gets the value of the `Right` button
  53281. */
  53282. get buttonRB(): number;
  53283. /**
  53284. * Sets the value of the `Right` button
  53285. */
  53286. set buttonRB(value: number);
  53287. /**
  53288. * Gets the value of the Left joystick
  53289. */
  53290. get buttonLeftStick(): number;
  53291. /**
  53292. * Sets the value of the Left joystick
  53293. */
  53294. set buttonLeftStick(value: number);
  53295. /**
  53296. * Gets the value of the Right joystick
  53297. */
  53298. get buttonRightStick(): number;
  53299. /**
  53300. * Sets the value of the Right joystick
  53301. */
  53302. set buttonRightStick(value: number);
  53303. /**
  53304. * Gets the value of D-pad up
  53305. */
  53306. get dPadUp(): number;
  53307. /**
  53308. * Sets the value of D-pad up
  53309. */
  53310. set dPadUp(value: number);
  53311. /**
  53312. * Gets the value of D-pad down
  53313. */
  53314. get dPadDown(): number;
  53315. /**
  53316. * Sets the value of D-pad down
  53317. */
  53318. set dPadDown(value: number);
  53319. /**
  53320. * Gets the value of D-pad left
  53321. */
  53322. get dPadLeft(): number;
  53323. /**
  53324. * Sets the value of D-pad left
  53325. */
  53326. set dPadLeft(value: number);
  53327. /**
  53328. * Gets the value of D-pad right
  53329. */
  53330. get dPadRight(): number;
  53331. /**
  53332. * Sets the value of D-pad right
  53333. */
  53334. set dPadRight(value: number);
  53335. /**
  53336. * Force the gamepad to synchronize with device values
  53337. */
  53338. update(): void;
  53339. /**
  53340. * Disposes the gamepad
  53341. */
  53342. dispose(): void;
  53343. }
  53344. }
  53345. declare module BABYLON {
  53346. /**
  53347. * Defines supported buttons for DualShock compatible gamepads
  53348. */
  53349. export enum DualShockButton {
  53350. /** Cross */
  53351. Cross = 0,
  53352. /** Circle */
  53353. Circle = 1,
  53354. /** Square */
  53355. Square = 2,
  53356. /** Triangle */
  53357. Triangle = 3,
  53358. /** L1 */
  53359. L1 = 4,
  53360. /** R1 */
  53361. R1 = 5,
  53362. /** Share */
  53363. Share = 8,
  53364. /** Options */
  53365. Options = 9,
  53366. /** Left stick */
  53367. LeftStick = 10,
  53368. /** Right stick */
  53369. RightStick = 11
  53370. }
  53371. /** Defines values for DualShock DPad */
  53372. export enum DualShockDpad {
  53373. /** Up */
  53374. Up = 12,
  53375. /** Down */
  53376. Down = 13,
  53377. /** Left */
  53378. Left = 14,
  53379. /** Right */
  53380. Right = 15
  53381. }
  53382. /**
  53383. * Defines a DualShock gamepad
  53384. */
  53385. export class DualShockPad extends Gamepad {
  53386. private _leftTrigger;
  53387. private _rightTrigger;
  53388. private _onlefttriggerchanged;
  53389. private _onrighttriggerchanged;
  53390. private _onbuttondown;
  53391. private _onbuttonup;
  53392. private _ondpaddown;
  53393. private _ondpadup;
  53394. /** Observable raised when a button is pressed */
  53395. onButtonDownObservable: Observable<DualShockButton>;
  53396. /** Observable raised when a button is released */
  53397. onButtonUpObservable: Observable<DualShockButton>;
  53398. /** Observable raised when a pad is pressed */
  53399. onPadDownObservable: Observable<DualShockDpad>;
  53400. /** Observable raised when a pad is released */
  53401. onPadUpObservable: Observable<DualShockDpad>;
  53402. private _buttonCross;
  53403. private _buttonCircle;
  53404. private _buttonSquare;
  53405. private _buttonTriangle;
  53406. private _buttonShare;
  53407. private _buttonOptions;
  53408. private _buttonL1;
  53409. private _buttonR1;
  53410. private _buttonLeftStick;
  53411. private _buttonRightStick;
  53412. private _dPadUp;
  53413. private _dPadDown;
  53414. private _dPadLeft;
  53415. private _dPadRight;
  53416. /**
  53417. * Creates a new DualShock gamepad object
  53418. * @param id defines the id of this gamepad
  53419. * @param index defines its index
  53420. * @param gamepad defines the internal HTML gamepad object
  53421. */
  53422. constructor(id: string, index: number, gamepad: any);
  53423. /**
  53424. * Defines the callback to call when left trigger is pressed
  53425. * @param callback defines the callback to use
  53426. */
  53427. onlefttriggerchanged(callback: (value: number) => void): void;
  53428. /**
  53429. * Defines the callback to call when right trigger is pressed
  53430. * @param callback defines the callback to use
  53431. */
  53432. onrighttriggerchanged(callback: (value: number) => void): void;
  53433. /**
  53434. * Gets the left trigger value
  53435. */
  53436. get leftTrigger(): number;
  53437. /**
  53438. * Sets the left trigger value
  53439. */
  53440. set leftTrigger(newValue: number);
  53441. /**
  53442. * Gets the right trigger value
  53443. */
  53444. get rightTrigger(): number;
  53445. /**
  53446. * Sets the right trigger value
  53447. */
  53448. set rightTrigger(newValue: number);
  53449. /**
  53450. * Defines the callback to call when a button is pressed
  53451. * @param callback defines the callback to use
  53452. */
  53453. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  53454. /**
  53455. * Defines the callback to call when a button is released
  53456. * @param callback defines the callback to use
  53457. */
  53458. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  53459. /**
  53460. * Defines the callback to call when a pad is pressed
  53461. * @param callback defines the callback to use
  53462. */
  53463. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  53464. /**
  53465. * Defines the callback to call when a pad is released
  53466. * @param callback defines the callback to use
  53467. */
  53468. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  53469. private _setButtonValue;
  53470. private _setDPadValue;
  53471. /**
  53472. * Gets the value of the `Cross` button
  53473. */
  53474. get buttonCross(): number;
  53475. /**
  53476. * Sets the value of the `Cross` button
  53477. */
  53478. set buttonCross(value: number);
  53479. /**
  53480. * Gets the value of the `Circle` button
  53481. */
  53482. get buttonCircle(): number;
  53483. /**
  53484. * Sets the value of the `Circle` button
  53485. */
  53486. set buttonCircle(value: number);
  53487. /**
  53488. * Gets the value of the `Square` button
  53489. */
  53490. get buttonSquare(): number;
  53491. /**
  53492. * Sets the value of the `Square` button
  53493. */
  53494. set buttonSquare(value: number);
  53495. /**
  53496. * Gets the value of the `Triangle` button
  53497. */
  53498. get buttonTriangle(): number;
  53499. /**
  53500. * Sets the value of the `Triangle` button
  53501. */
  53502. set buttonTriangle(value: number);
  53503. /**
  53504. * Gets the value of the `Options` button
  53505. */
  53506. get buttonOptions(): number;
  53507. /**
  53508. * Sets the value of the `Options` button
  53509. */
  53510. set buttonOptions(value: number);
  53511. /**
  53512. * Gets the value of the `Share` button
  53513. */
  53514. get buttonShare(): number;
  53515. /**
  53516. * Sets the value of the `Share` button
  53517. */
  53518. set buttonShare(value: number);
  53519. /**
  53520. * Gets the value of the `L1` button
  53521. */
  53522. get buttonL1(): number;
  53523. /**
  53524. * Sets the value of the `L1` button
  53525. */
  53526. set buttonL1(value: number);
  53527. /**
  53528. * Gets the value of the `R1` button
  53529. */
  53530. get buttonR1(): number;
  53531. /**
  53532. * Sets the value of the `R1` button
  53533. */
  53534. set buttonR1(value: number);
  53535. /**
  53536. * Gets the value of the Left joystick
  53537. */
  53538. get buttonLeftStick(): number;
  53539. /**
  53540. * Sets the value of the Left joystick
  53541. */
  53542. set buttonLeftStick(value: number);
  53543. /**
  53544. * Gets the value of the Right joystick
  53545. */
  53546. get buttonRightStick(): number;
  53547. /**
  53548. * Sets the value of the Right joystick
  53549. */
  53550. set buttonRightStick(value: number);
  53551. /**
  53552. * Gets the value of D-pad up
  53553. */
  53554. get dPadUp(): number;
  53555. /**
  53556. * Sets the value of D-pad up
  53557. */
  53558. set dPadUp(value: number);
  53559. /**
  53560. * Gets the value of D-pad down
  53561. */
  53562. get dPadDown(): number;
  53563. /**
  53564. * Sets the value of D-pad down
  53565. */
  53566. set dPadDown(value: number);
  53567. /**
  53568. * Gets the value of D-pad left
  53569. */
  53570. get dPadLeft(): number;
  53571. /**
  53572. * Sets the value of D-pad left
  53573. */
  53574. set dPadLeft(value: number);
  53575. /**
  53576. * Gets the value of D-pad right
  53577. */
  53578. get dPadRight(): number;
  53579. /**
  53580. * Sets the value of D-pad right
  53581. */
  53582. set dPadRight(value: number);
  53583. /**
  53584. * Force the gamepad to synchronize with device values
  53585. */
  53586. update(): void;
  53587. /**
  53588. * Disposes the gamepad
  53589. */
  53590. dispose(): void;
  53591. }
  53592. }
  53593. declare module BABYLON {
  53594. /**
  53595. * Manager for handling gamepads
  53596. */
  53597. export class GamepadManager {
  53598. private _scene?;
  53599. private _babylonGamepads;
  53600. private _oneGamepadConnected;
  53601. /** @hidden */
  53602. _isMonitoring: boolean;
  53603. private _gamepadEventSupported;
  53604. private _gamepadSupport?;
  53605. /**
  53606. * observable to be triggered when the gamepad controller has been connected
  53607. */
  53608. onGamepadConnectedObservable: Observable<Gamepad>;
  53609. /**
  53610. * observable to be triggered when the gamepad controller has been disconnected
  53611. */
  53612. onGamepadDisconnectedObservable: Observable<Gamepad>;
  53613. private _onGamepadConnectedEvent;
  53614. private _onGamepadDisconnectedEvent;
  53615. /**
  53616. * Initializes the gamepad manager
  53617. * @param _scene BabylonJS scene
  53618. */
  53619. constructor(_scene?: Scene | undefined);
  53620. /**
  53621. * The gamepads in the game pad manager
  53622. */
  53623. get gamepads(): Gamepad[];
  53624. /**
  53625. * Get the gamepad controllers based on type
  53626. * @param type The type of gamepad controller
  53627. * @returns Nullable gamepad
  53628. */
  53629. getGamepadByType(type?: number): Nullable<Gamepad>;
  53630. /**
  53631. * Disposes the gamepad manager
  53632. */
  53633. dispose(): void;
  53634. private _addNewGamepad;
  53635. private _startMonitoringGamepads;
  53636. private _stopMonitoringGamepads;
  53637. /** @hidden */
  53638. _checkGamepadsStatus(): void;
  53639. private _updateGamepadObjects;
  53640. }
  53641. }
  53642. declare module BABYLON {
  53643. interface Scene {
  53644. /** @hidden */
  53645. _gamepadManager: Nullable<GamepadManager>;
  53646. /**
  53647. * Gets the gamepad manager associated with the scene
  53648. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  53649. */
  53650. gamepadManager: GamepadManager;
  53651. }
  53652. /**
  53653. * Interface representing a free camera inputs manager
  53654. */
  53655. interface FreeCameraInputsManager {
  53656. /**
  53657. * Adds gamepad input support to the FreeCameraInputsManager.
  53658. * @returns the FreeCameraInputsManager
  53659. */
  53660. addGamepad(): FreeCameraInputsManager;
  53661. }
  53662. /**
  53663. * Interface representing an arc rotate camera inputs manager
  53664. */
  53665. interface ArcRotateCameraInputsManager {
  53666. /**
  53667. * Adds gamepad input support to the ArcRotateCamera InputManager.
  53668. * @returns the camera inputs manager
  53669. */
  53670. addGamepad(): ArcRotateCameraInputsManager;
  53671. }
  53672. /**
  53673. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  53674. */
  53675. export class GamepadSystemSceneComponent implements ISceneComponent {
  53676. /**
  53677. * The component name helpfull to identify the component in the list of scene components.
  53678. */
  53679. readonly name: string;
  53680. /**
  53681. * The scene the component belongs to.
  53682. */
  53683. scene: Scene;
  53684. /**
  53685. * Creates a new instance of the component for the given scene
  53686. * @param scene Defines the scene to register the component in
  53687. */
  53688. constructor(scene: Scene);
  53689. /**
  53690. * Registers the component in a given scene
  53691. */
  53692. register(): void;
  53693. /**
  53694. * Rebuilds the elements related to this component in case of
  53695. * context lost for instance.
  53696. */
  53697. rebuild(): void;
  53698. /**
  53699. * Disposes the component and the associated ressources
  53700. */
  53701. dispose(): void;
  53702. private _beforeCameraUpdate;
  53703. }
  53704. }
  53705. declare module BABYLON {
  53706. /**
  53707. * 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,
  53708. * which still works and will still be found in many Playgrounds.
  53709. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  53710. */
  53711. export class UniversalCamera extends TouchCamera {
  53712. /**
  53713. * Defines the gamepad rotation sensiblity.
  53714. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  53715. */
  53716. get gamepadAngularSensibility(): number;
  53717. set gamepadAngularSensibility(value: number);
  53718. /**
  53719. * Defines the gamepad move sensiblity.
  53720. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  53721. */
  53722. get gamepadMoveSensibility(): number;
  53723. set gamepadMoveSensibility(value: number);
  53724. /**
  53725. * 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,
  53726. * which still works and will still be found in many Playgrounds.
  53727. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  53728. * @param name Define the name of the camera in the scene
  53729. * @param position Define the start position of the camera in the scene
  53730. * @param scene Define the scene the camera belongs to
  53731. */
  53732. constructor(name: string, position: Vector3, scene: Scene);
  53733. /**
  53734. * Gets the current object class name.
  53735. * @return the class name
  53736. */
  53737. getClassName(): string;
  53738. }
  53739. }
  53740. declare module BABYLON {
  53741. /**
  53742. * This represents a FPS type of camera. This is only here for back compat purpose.
  53743. * Please use the UniversalCamera instead as both are identical.
  53744. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  53745. */
  53746. export class GamepadCamera extends UniversalCamera {
  53747. /**
  53748. * Instantiates a new Gamepad Camera
  53749. * This represents a FPS type of camera. This is only here for back compat purpose.
  53750. * Please use the UniversalCamera instead as both are identical.
  53751. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  53752. * @param name Define the name of the camera in the scene
  53753. * @param position Define the start position of the camera in the scene
  53754. * @param scene Define the scene the camera belongs to
  53755. */
  53756. constructor(name: string, position: Vector3, scene: Scene);
  53757. /**
  53758. * Gets the current object class name.
  53759. * @return the class name
  53760. */
  53761. getClassName(): string;
  53762. }
  53763. }
  53764. declare module BABYLON {
  53765. /** @hidden */
  53766. export var anaglyphPixelShader: {
  53767. name: string;
  53768. shader: string;
  53769. };
  53770. }
  53771. declare module BABYLON {
  53772. /**
  53773. * Postprocess used to generate anaglyphic rendering
  53774. */
  53775. export class AnaglyphPostProcess extends PostProcess {
  53776. private _passedProcess;
  53777. /**
  53778. * Gets a string identifying the name of the class
  53779. * @returns "AnaglyphPostProcess" string
  53780. */
  53781. getClassName(): string;
  53782. /**
  53783. * Creates a new AnaglyphPostProcess
  53784. * @param name defines postprocess name
  53785. * @param options defines creation options or target ratio scale
  53786. * @param rigCameras defines cameras using this postprocess
  53787. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  53788. * @param engine defines hosting engine
  53789. * @param reusable defines if the postprocess will be reused multiple times per frame
  53790. */
  53791. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  53792. }
  53793. }
  53794. declare module BABYLON {
  53795. /**
  53796. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  53797. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  53798. */
  53799. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  53800. /**
  53801. * Creates a new AnaglyphArcRotateCamera
  53802. * @param name defines camera name
  53803. * @param alpha defines alpha angle (in radians)
  53804. * @param beta defines beta angle (in radians)
  53805. * @param radius defines radius
  53806. * @param target defines camera target
  53807. * @param interaxialDistance defines distance between each color axis
  53808. * @param scene defines the hosting scene
  53809. */
  53810. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  53811. /**
  53812. * Gets camera class name
  53813. * @returns AnaglyphArcRotateCamera
  53814. */
  53815. getClassName(): string;
  53816. }
  53817. }
  53818. declare module BABYLON {
  53819. /**
  53820. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  53821. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  53822. */
  53823. export class AnaglyphFreeCamera extends FreeCamera {
  53824. /**
  53825. * Creates a new AnaglyphFreeCamera
  53826. * @param name defines camera name
  53827. * @param position defines initial position
  53828. * @param interaxialDistance defines distance between each color axis
  53829. * @param scene defines the hosting scene
  53830. */
  53831. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  53832. /**
  53833. * Gets camera class name
  53834. * @returns AnaglyphFreeCamera
  53835. */
  53836. getClassName(): string;
  53837. }
  53838. }
  53839. declare module BABYLON {
  53840. /**
  53841. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  53842. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  53843. */
  53844. export class AnaglyphGamepadCamera extends GamepadCamera {
  53845. /**
  53846. * Creates a new AnaglyphGamepadCamera
  53847. * @param name defines camera name
  53848. * @param position defines initial position
  53849. * @param interaxialDistance defines distance between each color axis
  53850. * @param scene defines the hosting scene
  53851. */
  53852. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  53853. /**
  53854. * Gets camera class name
  53855. * @returns AnaglyphGamepadCamera
  53856. */
  53857. getClassName(): string;
  53858. }
  53859. }
  53860. declare module BABYLON {
  53861. /**
  53862. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  53863. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  53864. */
  53865. export class AnaglyphUniversalCamera extends UniversalCamera {
  53866. /**
  53867. * Creates a new AnaglyphUniversalCamera
  53868. * @param name defines camera name
  53869. * @param position defines initial position
  53870. * @param interaxialDistance defines distance between each color axis
  53871. * @param scene defines the hosting scene
  53872. */
  53873. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  53874. /**
  53875. * Gets camera class name
  53876. * @returns AnaglyphUniversalCamera
  53877. */
  53878. getClassName(): string;
  53879. }
  53880. }
  53881. declare module BABYLON {
  53882. /** @hidden */
  53883. export var stereoscopicInterlacePixelShader: {
  53884. name: string;
  53885. shader: string;
  53886. };
  53887. }
  53888. declare module BABYLON {
  53889. /**
  53890. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  53891. */
  53892. export class StereoscopicInterlacePostProcessI extends PostProcess {
  53893. private _stepSize;
  53894. private _passedProcess;
  53895. /**
  53896. * Gets a string identifying the name of the class
  53897. * @returns "StereoscopicInterlacePostProcessI" string
  53898. */
  53899. getClassName(): string;
  53900. /**
  53901. * Initializes a StereoscopicInterlacePostProcessI
  53902. * @param name The name of the effect.
  53903. * @param rigCameras The rig cameras to be applied to the post process
  53904. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  53905. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  53906. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53907. * @param engine The engine which the post process will be applied. (default: current engine)
  53908. * @param reusable If the post process can be reused on the same frame. (default: false)
  53909. */
  53910. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53911. }
  53912. /**
  53913. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  53914. */
  53915. export class StereoscopicInterlacePostProcess extends PostProcess {
  53916. private _stepSize;
  53917. private _passedProcess;
  53918. /**
  53919. * Gets a string identifying the name of the class
  53920. * @returns "StereoscopicInterlacePostProcess" string
  53921. */
  53922. getClassName(): string;
  53923. /**
  53924. * Initializes a StereoscopicInterlacePostProcess
  53925. * @param name The name of the effect.
  53926. * @param rigCameras The rig cameras to be applied to the post process
  53927. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  53928. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53929. * @param engine The engine which the post process will be applied. (default: current engine)
  53930. * @param reusable If the post process can be reused on the same frame. (default: false)
  53931. */
  53932. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53933. }
  53934. }
  53935. declare module BABYLON {
  53936. /**
  53937. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  53938. * @see https://doc.babylonjs.com/features/cameras
  53939. */
  53940. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  53941. /**
  53942. * Creates a new StereoscopicArcRotateCamera
  53943. * @param name defines camera name
  53944. * @param alpha defines alpha angle (in radians)
  53945. * @param beta defines beta angle (in radians)
  53946. * @param radius defines radius
  53947. * @param target defines camera target
  53948. * @param interaxialDistance defines distance between each color axis
  53949. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  53950. * @param scene defines the hosting scene
  53951. */
  53952. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  53953. /**
  53954. * Gets camera class name
  53955. * @returns StereoscopicArcRotateCamera
  53956. */
  53957. getClassName(): string;
  53958. }
  53959. }
  53960. declare module BABYLON {
  53961. /**
  53962. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  53963. * @see https://doc.babylonjs.com/features/cameras
  53964. */
  53965. export class StereoscopicFreeCamera extends FreeCamera {
  53966. /**
  53967. * Creates a new StereoscopicFreeCamera
  53968. * @param name defines camera name
  53969. * @param position defines initial position
  53970. * @param interaxialDistance defines distance between each color axis
  53971. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  53972. * @param scene defines the hosting scene
  53973. */
  53974. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  53975. /**
  53976. * Gets camera class name
  53977. * @returns StereoscopicFreeCamera
  53978. */
  53979. getClassName(): string;
  53980. }
  53981. }
  53982. declare module BABYLON {
  53983. /**
  53984. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  53985. * @see https://doc.babylonjs.com/features/cameras
  53986. */
  53987. export class StereoscopicGamepadCamera extends GamepadCamera {
  53988. /**
  53989. * Creates a new StereoscopicGamepadCamera
  53990. * @param name defines camera name
  53991. * @param position defines initial position
  53992. * @param interaxialDistance defines distance between each color axis
  53993. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  53994. * @param scene defines the hosting scene
  53995. */
  53996. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  53997. /**
  53998. * Gets camera class name
  53999. * @returns StereoscopicGamepadCamera
  54000. */
  54001. getClassName(): string;
  54002. }
  54003. }
  54004. declare module BABYLON {
  54005. /**
  54006. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  54007. * @see https://doc.babylonjs.com/features/cameras
  54008. */
  54009. export class StereoscopicUniversalCamera extends UniversalCamera {
  54010. /**
  54011. * Creates a new StereoscopicUniversalCamera
  54012. * @param name defines camera name
  54013. * @param position defines initial position
  54014. * @param interaxialDistance defines distance between each color axis
  54015. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  54016. * @param scene defines the hosting scene
  54017. */
  54018. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  54019. /**
  54020. * Gets camera class name
  54021. * @returns StereoscopicUniversalCamera
  54022. */
  54023. getClassName(): string;
  54024. }
  54025. }
  54026. declare module BABYLON {
  54027. /**
  54028. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  54029. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  54030. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  54031. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  54032. */
  54033. export class VirtualJoysticksCamera extends FreeCamera {
  54034. /**
  54035. * Instantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  54036. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  54037. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  54038. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  54039. * @param name Define the name of the camera in the scene
  54040. * @param position Define the start position of the camera in the scene
  54041. * @param scene Define the scene the camera belongs to
  54042. */
  54043. constructor(name: string, position: Vector3, scene: Scene);
  54044. /**
  54045. * Gets the current object class name.
  54046. * @return the class name
  54047. */
  54048. getClassName(): string;
  54049. }
  54050. }
  54051. declare module BABYLON {
  54052. /**
  54053. * This represents all the required metrics to create a VR camera.
  54054. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  54055. */
  54056. export class VRCameraMetrics {
  54057. /**
  54058. * Define the horizontal resolution off the screen.
  54059. */
  54060. hResolution: number;
  54061. /**
  54062. * Define the vertical resolution off the screen.
  54063. */
  54064. vResolution: number;
  54065. /**
  54066. * Define the horizontal screen size.
  54067. */
  54068. hScreenSize: number;
  54069. /**
  54070. * Define the vertical screen size.
  54071. */
  54072. vScreenSize: number;
  54073. /**
  54074. * Define the vertical screen center position.
  54075. */
  54076. vScreenCenter: number;
  54077. /**
  54078. * Define the distance of the eyes to the screen.
  54079. */
  54080. eyeToScreenDistance: number;
  54081. /**
  54082. * Define the distance between both lenses
  54083. */
  54084. lensSeparationDistance: number;
  54085. /**
  54086. * Define the distance between both viewer's eyes.
  54087. */
  54088. interpupillaryDistance: number;
  54089. /**
  54090. * Define the distortion factor of the VR postprocess.
  54091. * Please, touch with care.
  54092. */
  54093. distortionK: number[];
  54094. /**
  54095. * Define the chromatic aberration correction factors for the VR post process.
  54096. */
  54097. chromaAbCorrection: number[];
  54098. /**
  54099. * Define the scale factor of the post process.
  54100. * The smaller the better but the slower.
  54101. */
  54102. postProcessScaleFactor: number;
  54103. /**
  54104. * Define an offset for the lens center.
  54105. */
  54106. lensCenterOffset: number;
  54107. /**
  54108. * Define if the current vr camera should compensate the distortion of the lens or not.
  54109. */
  54110. compensateDistortion: boolean;
  54111. /**
  54112. * Defines if multiview should be enabled when rendering (Default: false)
  54113. */
  54114. multiviewEnabled: boolean;
  54115. /**
  54116. * Gets the rendering aspect ratio based on the provided resolutions.
  54117. */
  54118. get aspectRatio(): number;
  54119. /**
  54120. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  54121. */
  54122. get aspectRatioFov(): number;
  54123. /**
  54124. * @hidden
  54125. */
  54126. get leftHMatrix(): Matrix;
  54127. /**
  54128. * @hidden
  54129. */
  54130. get rightHMatrix(): Matrix;
  54131. /**
  54132. * @hidden
  54133. */
  54134. get leftPreViewMatrix(): Matrix;
  54135. /**
  54136. * @hidden
  54137. */
  54138. get rightPreViewMatrix(): Matrix;
  54139. /**
  54140. * Get the default VRMetrics based on the most generic setup.
  54141. * @returns the default vr metrics
  54142. */
  54143. static GetDefault(): VRCameraMetrics;
  54144. }
  54145. }
  54146. declare module BABYLON {
  54147. /** @hidden */
  54148. export var vrDistortionCorrectionPixelShader: {
  54149. name: string;
  54150. shader: string;
  54151. };
  54152. }
  54153. declare module BABYLON {
  54154. /**
  54155. * VRDistortionCorrectionPostProcess used for mobile VR
  54156. */
  54157. export class VRDistortionCorrectionPostProcess extends PostProcess {
  54158. private _isRightEye;
  54159. private _distortionFactors;
  54160. private _postProcessScaleFactor;
  54161. private _lensCenterOffset;
  54162. private _scaleIn;
  54163. private _scaleFactor;
  54164. private _lensCenter;
  54165. /**
  54166. * Gets a string identifying the name of the class
  54167. * @returns "VRDistortionCorrectionPostProcess" string
  54168. */
  54169. getClassName(): string;
  54170. /**
  54171. * Initializes the VRDistortionCorrectionPostProcess
  54172. * @param name The name of the effect.
  54173. * @param camera The camera to apply the render pass to.
  54174. * @param isRightEye If this is for the right eye distortion
  54175. * @param vrMetrics All the required metrics for the VR camera
  54176. */
  54177. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  54178. }
  54179. }
  54180. declare module BABYLON {
  54181. /**
  54182. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  54183. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  54184. */
  54185. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  54186. /**
  54187. * Creates a new VRDeviceOrientationArcRotateCamera
  54188. * @param name defines camera name
  54189. * @param alpha defines the camera rotation along the longitudinal axis
  54190. * @param beta defines the camera rotation along the latitudinal axis
  54191. * @param radius defines the camera distance from its target
  54192. * @param target defines the camera target
  54193. * @param scene defines the scene the camera belongs to
  54194. * @param compensateDistortion defines if the camera needs to compensate the lens distortion
  54195. * @param vrCameraMetrics defines the vr metrics associated to the camera
  54196. */
  54197. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  54198. /**
  54199. * Gets camera class name
  54200. * @returns VRDeviceOrientationArcRotateCamera
  54201. */
  54202. getClassName(): string;
  54203. }
  54204. }
  54205. declare module BABYLON {
  54206. /**
  54207. * Camera used to simulate VR rendering (based on FreeCamera)
  54208. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  54209. */
  54210. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  54211. /**
  54212. * Creates a new VRDeviceOrientationFreeCamera
  54213. * @param name defines camera name
  54214. * @param position defines the start position of the camera
  54215. * @param scene defines the scene the camera belongs to
  54216. * @param compensateDistortion defines if the camera needs to compensate the lens distortion
  54217. * @param vrCameraMetrics defines the vr metrics associated to the camera
  54218. */
  54219. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  54220. /**
  54221. * Gets camera class name
  54222. * @returns VRDeviceOrientationFreeCamera
  54223. */
  54224. getClassName(): string;
  54225. }
  54226. }
  54227. declare module BABYLON {
  54228. /**
  54229. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  54230. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  54231. */
  54232. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  54233. /**
  54234. * Creates a new VRDeviceOrientationGamepadCamera
  54235. * @param name defines camera name
  54236. * @param position defines the start position of the camera
  54237. * @param scene defines the scene the camera belongs to
  54238. * @param compensateDistortion defines if the camera needs to compensate the lens distortion
  54239. * @param vrCameraMetrics defines the vr metrics associated to the camera
  54240. */
  54241. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  54242. /**
  54243. * Gets camera class name
  54244. * @returns VRDeviceOrientationGamepadCamera
  54245. */
  54246. getClassName(): string;
  54247. }
  54248. }
  54249. declare module BABYLON {
  54250. /**
  54251. * A class extending Texture allowing drawing on a texture
  54252. * @see https://doc.babylonjs.com/how_to/dynamictexture
  54253. */
  54254. export class DynamicTexture extends Texture {
  54255. private _generateMipMaps;
  54256. private _canvas;
  54257. private _context;
  54258. /**
  54259. * Creates a DynamicTexture
  54260. * @param name defines the name of the texture
  54261. * @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
  54262. * @param scene defines the scene where you want the texture
  54263. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  54264. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54265. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  54266. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  54267. */
  54268. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  54269. /**
  54270. * Get the current class name of the texture useful for serialization or dynamic coding.
  54271. * @returns "DynamicTexture"
  54272. */
  54273. getClassName(): string;
  54274. /**
  54275. * Gets the current state of canRescale
  54276. */
  54277. get canRescale(): boolean;
  54278. private _recreate;
  54279. /**
  54280. * Scales the texture
  54281. * @param ratio the scale factor to apply to both width and height
  54282. */
  54283. scale(ratio: number): void;
  54284. /**
  54285. * Resizes the texture
  54286. * @param width the new width
  54287. * @param height the new height
  54288. */
  54289. scaleTo(width: number, height: number): void;
  54290. /**
  54291. * Gets the context of the canvas used by the texture
  54292. * @returns the canvas context of the dynamic texture
  54293. */
  54294. getContext(): CanvasRenderingContext2D;
  54295. /**
  54296. * Clears the texture
  54297. */
  54298. clear(): void;
  54299. /**
  54300. * Updates the texture
  54301. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  54302. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  54303. */
  54304. update(invertY?: boolean, premulAlpha?: boolean): void;
  54305. /**
  54306. * Draws text onto the texture
  54307. * @param text defines the text to be drawn
  54308. * @param x defines the placement of the text from the left
  54309. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  54310. * @param font defines the font to be used with font-style, font-size, font-name
  54311. * @param color defines the color used for the text
  54312. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  54313. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  54314. * @param update defines whether texture is immediately update (default is true)
  54315. */
  54316. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  54317. /**
  54318. * Clones the texture
  54319. * @returns the clone of the texture.
  54320. */
  54321. clone(): DynamicTexture;
  54322. /**
  54323. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  54324. * @returns a serialized dynamic texture object
  54325. */
  54326. serialize(): any;
  54327. private _IsCanvasElement;
  54328. /** @hidden */
  54329. _rebuild(): void;
  54330. }
  54331. }
  54332. declare module BABYLON {
  54333. /**
  54334. * Class containing static functions to help procedurally build meshes
  54335. */
  54336. export class GroundBuilder {
  54337. /**
  54338. * Creates a ground mesh
  54339. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  54340. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  54341. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54342. * @param name defines the name of the mesh
  54343. * @param options defines the options used to create the mesh
  54344. * @param scene defines the hosting scene
  54345. * @returns the ground mesh
  54346. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  54347. */
  54348. static CreateGround(name: string, options: {
  54349. width?: number;
  54350. height?: number;
  54351. subdivisions?: number;
  54352. subdivisionsX?: number;
  54353. subdivisionsY?: number;
  54354. updatable?: boolean;
  54355. }, scene: any): Mesh;
  54356. /**
  54357. * Creates a tiled ground mesh
  54358. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  54359. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  54360. * * 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
  54361. * * 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
  54362. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54363. * @param name defines the name of the mesh
  54364. * @param options defines the options used to create the mesh
  54365. * @param scene defines the hosting scene
  54366. * @returns the tiled ground mesh
  54367. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  54368. */
  54369. static CreateTiledGround(name: string, options: {
  54370. xmin: number;
  54371. zmin: number;
  54372. xmax: number;
  54373. zmax: number;
  54374. subdivisions?: {
  54375. w: number;
  54376. h: number;
  54377. };
  54378. precision?: {
  54379. w: number;
  54380. h: number;
  54381. };
  54382. updatable?: boolean;
  54383. }, scene?: Nullable<Scene>): Mesh;
  54384. /**
  54385. * Creates a ground mesh from a height map
  54386. * * The parameter `url` sets the URL of the height map image resource.
  54387. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  54388. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  54389. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  54390. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  54391. * * 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.
  54392. * * 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).
  54393. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  54394. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54395. * @param name defines the name of the mesh
  54396. * @param url defines the url to the height map
  54397. * @param options defines the options used to create the mesh
  54398. * @param scene defines the hosting scene
  54399. * @returns the ground mesh
  54400. * @see https://doc.babylonjs.com/babylon101/height_map
  54401. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  54402. */
  54403. static CreateGroundFromHeightMap(name: string, url: string, options: {
  54404. width?: number;
  54405. height?: number;
  54406. subdivisions?: number;
  54407. minHeight?: number;
  54408. maxHeight?: number;
  54409. colorFilter?: Color3;
  54410. alphaFilter?: number;
  54411. updatable?: boolean;
  54412. onReady?: (mesh: GroundMesh) => void;
  54413. }, scene?: Nullable<Scene>): GroundMesh;
  54414. }
  54415. }
  54416. declare module BABYLON {
  54417. /**
  54418. * Class containing static functions to help procedurally build meshes
  54419. */
  54420. export class TorusBuilder {
  54421. /**
  54422. * Creates a torus mesh
  54423. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  54424. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  54425. * * The parameter `tessellation` sets the number of torus sides (positive integer, default 16)
  54426. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54427. * * 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
  54428. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54429. * @param name defines the name of the mesh
  54430. * @param options defines the options used to create the mesh
  54431. * @param scene defines the hosting scene
  54432. * @returns the torus mesh
  54433. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  54434. */
  54435. static CreateTorus(name: string, options: {
  54436. diameter?: number;
  54437. thickness?: number;
  54438. tessellation?: number;
  54439. updatable?: boolean;
  54440. sideOrientation?: number;
  54441. frontUVs?: Vector4;
  54442. backUVs?: Vector4;
  54443. }, scene: any): Mesh;
  54444. }
  54445. }
  54446. declare module BABYLON {
  54447. /**
  54448. * Class containing static functions to help procedurally build meshes
  54449. */
  54450. export class CylinderBuilder {
  54451. /**
  54452. * Creates a cylinder or a cone mesh
  54453. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  54454. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  54455. * * 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.
  54456. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  54457. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  54458. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  54459. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  54460. * * 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).
  54461. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  54462. * * 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).
  54463. * * 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
  54464. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  54465. * * 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
  54466. * * 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.
  54467. * * If `enclose` is false, a ring surface is one element.
  54468. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  54469. * * 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
  54470. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54471. * * 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
  54472. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54473. * @param name defines the name of the mesh
  54474. * @param options defines the options used to create the mesh
  54475. * @param scene defines the hosting scene
  54476. * @returns the cylinder mesh
  54477. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  54478. */
  54479. static CreateCylinder(name: string, options: {
  54480. height?: number;
  54481. diameterTop?: number;
  54482. diameterBottom?: number;
  54483. diameter?: number;
  54484. tessellation?: number;
  54485. subdivisions?: number;
  54486. arc?: number;
  54487. faceColors?: Color4[];
  54488. faceUV?: Vector4[];
  54489. updatable?: boolean;
  54490. hasRings?: boolean;
  54491. enclose?: boolean;
  54492. cap?: number;
  54493. sideOrientation?: number;
  54494. frontUVs?: Vector4;
  54495. backUVs?: Vector4;
  54496. }, scene: any): Mesh;
  54497. }
  54498. }
  54499. declare module BABYLON {
  54500. /**
  54501. * States of the webXR experience
  54502. */
  54503. export enum WebXRState {
  54504. /**
  54505. * Transitioning to being in XR mode
  54506. */
  54507. ENTERING_XR = 0,
  54508. /**
  54509. * Transitioning to non XR mode
  54510. */
  54511. EXITING_XR = 1,
  54512. /**
  54513. * In XR mode and presenting
  54514. */
  54515. IN_XR = 2,
  54516. /**
  54517. * Not entered XR mode
  54518. */
  54519. NOT_IN_XR = 3
  54520. }
  54521. /**
  54522. * The state of the XR camera's tracking
  54523. */
  54524. export enum WebXRTrackingState {
  54525. /**
  54526. * No transformation received, device is not being tracked
  54527. */
  54528. NOT_TRACKING = 0,
  54529. /**
  54530. * Tracking lost - using emulated position
  54531. */
  54532. TRACKING_LOST = 1,
  54533. /**
  54534. * Transformation tracking works normally
  54535. */
  54536. TRACKING = 2
  54537. }
  54538. /**
  54539. * Abstraction of the XR render target
  54540. */
  54541. export interface WebXRRenderTarget extends IDisposable {
  54542. /**
  54543. * xrpresent context of the canvas which can be used to display/mirror xr content
  54544. */
  54545. canvasContext: WebGLRenderingContext;
  54546. /**
  54547. * xr layer for the canvas
  54548. */
  54549. xrLayer: Nullable<XRWebGLLayer>;
  54550. /**
  54551. * Initializes the xr layer for the session
  54552. * @param xrSession xr session
  54553. * @returns a promise that will resolve once the XR Layer has been created
  54554. */
  54555. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  54556. }
  54557. }
  54558. declare module BABYLON {
  54559. /**
  54560. * Configuration object for WebXR output canvas
  54561. */
  54562. export class WebXRManagedOutputCanvasOptions {
  54563. /**
  54564. * An optional canvas in case you wish to create it yourself and provide it here.
  54565. * If not provided, a new canvas will be created
  54566. */
  54567. canvasElement?: HTMLCanvasElement;
  54568. /**
  54569. * Options for this XR Layer output
  54570. */
  54571. canvasOptions?: XRWebGLLayerInit;
  54572. /**
  54573. * CSS styling for a newly created canvas (if not provided)
  54574. */
  54575. newCanvasCssStyle?: string;
  54576. /**
  54577. * Get the default values of the configuration object
  54578. * @param engine defines the engine to use (can be null)
  54579. * @returns default values of this configuration object
  54580. */
  54581. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  54582. }
  54583. /**
  54584. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  54585. */
  54586. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  54587. private _options;
  54588. private _canvas;
  54589. private _engine;
  54590. private _originalCanvasSize;
  54591. /**
  54592. * Rendering context of the canvas which can be used to display/mirror xr content
  54593. */
  54594. canvasContext: WebGLRenderingContext;
  54595. /**
  54596. * xr layer for the canvas
  54597. */
  54598. xrLayer: Nullable<XRWebGLLayer>;
  54599. /**
  54600. * Observers registered here will be triggered when the xr layer was initialized
  54601. */
  54602. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  54603. /**
  54604. * Initializes the canvas to be added/removed upon entering/exiting xr
  54605. * @param _xrSessionManager The XR Session manager
  54606. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  54607. */
  54608. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  54609. /**
  54610. * Disposes of the object
  54611. */
  54612. dispose(): void;
  54613. /**
  54614. * Initializes the xr layer for the session
  54615. * @param xrSession xr session
  54616. * @returns a promise that will resolve once the XR Layer has been created
  54617. */
  54618. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  54619. private _addCanvas;
  54620. private _removeCanvas;
  54621. private _setCanvasSize;
  54622. private _setManagedOutputCanvas;
  54623. }
  54624. }
  54625. declare module BABYLON {
  54626. /**
  54627. * Manages an XRSession to work with Babylon's engine
  54628. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  54629. */
  54630. export class WebXRSessionManager implements IDisposable {
  54631. /** The scene which the session should be created for */
  54632. scene: Scene;
  54633. private _referenceSpace;
  54634. private _rttProvider;
  54635. private _sessionEnded;
  54636. private _xrNavigator;
  54637. private baseLayer;
  54638. /**
  54639. * The base reference space from which the session started. good if you want to reset your
  54640. * reference space
  54641. */
  54642. baseReferenceSpace: XRReferenceSpace;
  54643. /**
  54644. * Current XR frame
  54645. */
  54646. currentFrame: Nullable<XRFrame>;
  54647. /** WebXR timestamp updated every frame */
  54648. currentTimestamp: number;
  54649. /**
  54650. * Used just in case of a failure to initialize an immersive session.
  54651. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  54652. */
  54653. defaultHeightCompensation: number;
  54654. /**
  54655. * Fires every time a new xrFrame arrives which can be used to update the camera
  54656. */
  54657. onXRFrameObservable: Observable<XRFrame>;
  54658. /**
  54659. * Fires when the reference space changed
  54660. */
  54661. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  54662. /**
  54663. * Fires when the xr session is ended either by the device or manually done
  54664. */
  54665. onXRSessionEnded: Observable<any>;
  54666. /**
  54667. * Fires when the xr session is ended either by the device or manually done
  54668. */
  54669. onXRSessionInit: Observable<XRSession>;
  54670. /**
  54671. * Underlying xr session
  54672. */
  54673. session: XRSession;
  54674. /**
  54675. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  54676. * or get the offset the player is currently at.
  54677. */
  54678. viewerReferenceSpace: XRReferenceSpace;
  54679. /**
  54680. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  54681. * @param scene The scene which the session should be created for
  54682. */
  54683. constructor(
  54684. /** The scene which the session should be created for */
  54685. scene: Scene);
  54686. /**
  54687. * The current reference space used in this session. This reference space can constantly change!
  54688. * It is mainly used to offset the camera's position.
  54689. */
  54690. get referenceSpace(): XRReferenceSpace;
  54691. /**
  54692. * Set a new reference space and triggers the observable
  54693. */
  54694. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  54695. /**
  54696. * Disposes of the session manager
  54697. */
  54698. dispose(): void;
  54699. /**
  54700. * Stops the xrSession and restores the render loop
  54701. * @returns Promise which resolves after it exits XR
  54702. */
  54703. exitXRAsync(): Promise<void>;
  54704. /**
  54705. * Gets the correct render target texture to be rendered this frame for this eye
  54706. * @param eye the eye for which to get the render target
  54707. * @returns the render target for the specified eye
  54708. */
  54709. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  54710. /**
  54711. * Creates a WebXRRenderTarget object for the XR session
  54712. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  54713. * @param options optional options to provide when creating a new render target
  54714. * @returns a WebXR render target to which the session can render
  54715. */
  54716. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  54717. /**
  54718. * Initializes the manager
  54719. * After initialization enterXR can be called to start an XR session
  54720. * @returns Promise which resolves after it is initialized
  54721. */
  54722. initializeAsync(): Promise<void>;
  54723. /**
  54724. * Initializes an xr session
  54725. * @param xrSessionMode mode to initialize
  54726. * @param xrSessionInit defines optional and required values to pass to the session builder
  54727. * @returns a promise which will resolve once the session has been initialized
  54728. */
  54729. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  54730. /**
  54731. * Checks if a session would be supported for the creation options specified
  54732. * @param sessionMode session mode to check if supported eg. immersive-vr
  54733. * @returns A Promise that resolves to true if supported and false if not
  54734. */
  54735. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  54736. /**
  54737. * Resets the reference space to the one started the session
  54738. */
  54739. resetReferenceSpace(): void;
  54740. /**
  54741. * Starts rendering to the xr layer
  54742. */
  54743. runXRRenderLoop(): void;
  54744. /**
  54745. * Sets the reference space on the xr session
  54746. * @param referenceSpaceType space to set
  54747. * @returns a promise that will resolve once the reference space has been set
  54748. */
  54749. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  54750. /**
  54751. * Updates the render state of the session
  54752. * @param state state to set
  54753. * @returns a promise that resolves once the render state has been updated
  54754. */
  54755. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  54756. /**
  54757. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  54758. * @param sessionMode defines the session to test
  54759. * @returns a promise with boolean as final value
  54760. */
  54761. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  54762. /**
  54763. * Returns true if Babylon.js is using the BabylonNative backend, otherwise false
  54764. */
  54765. get isNative(): boolean;
  54766. private _createRenderTargetTexture;
  54767. }
  54768. }
  54769. declare module BABYLON {
  54770. /**
  54771. * WebXR Camera which holds the views for the xrSession
  54772. * @see https://doc.babylonjs.com/how_to/webxr_camera
  54773. */
  54774. export class WebXRCamera extends FreeCamera {
  54775. private _xrSessionManager;
  54776. private _firstFrame;
  54777. private _referenceQuaternion;
  54778. private _referencedPosition;
  54779. private _xrInvPositionCache;
  54780. private _xrInvQuaternionCache;
  54781. private _trackingState;
  54782. /**
  54783. * Observable raised before camera teleportation
  54784. */
  54785. onBeforeCameraTeleport: Observable<Vector3>;
  54786. /**
  54787. * Observable raised after camera teleportation
  54788. */
  54789. onAfterCameraTeleport: Observable<Vector3>;
  54790. /**
  54791. * Notifies when the camera's tracking state has changed.
  54792. * Notice - will also be triggered when tracking has started (at the beginning of the session)
  54793. */
  54794. onTrackingStateChanged: Observable<WebXRTrackingState>;
  54795. /**
  54796. * Should position compensation execute on first frame.
  54797. * This is used when copying the position from a native (non XR) camera
  54798. */
  54799. compensateOnFirstFrame: boolean;
  54800. /**
  54801. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  54802. * @param name the name of the camera
  54803. * @param scene the scene to add the camera to
  54804. * @param _xrSessionManager a constructed xr session manager
  54805. */
  54806. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  54807. /**
  54808. * Get the current XR tracking state of the camera
  54809. */
  54810. get trackingState(): WebXRTrackingState;
  54811. private _setTrackingState;
  54812. /**
  54813. * Return the user's height, unrelated to the current ground.
  54814. * This will be the y position of this camera, when ground level is 0.
  54815. */
  54816. get realWorldHeight(): number;
  54817. /** @hidden */
  54818. _updateForDualEyeDebugging(): void;
  54819. /**
  54820. * Sets this camera's transformation based on a non-vr camera
  54821. * @param otherCamera the non-vr camera to copy the transformation from
  54822. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  54823. */
  54824. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  54825. /**
  54826. * Gets the current instance class name ("WebXRCamera").
  54827. * @returns the class name
  54828. */
  54829. getClassName(): string;
  54830. private _rotate180;
  54831. private _updateFromXRSession;
  54832. private _updateNumberOfRigCameras;
  54833. private _updateReferenceSpace;
  54834. private _updateReferenceSpaceOffset;
  54835. }
  54836. }
  54837. declare module BABYLON {
  54838. /**
  54839. * Defining the interface required for a (webxr) feature
  54840. */
  54841. export interface IWebXRFeature extends IDisposable {
  54842. /**
  54843. * Is this feature attached
  54844. */
  54845. attached: boolean;
  54846. /**
  54847. * Should auto-attach be disabled?
  54848. */
  54849. disableAutoAttach: boolean;
  54850. /**
  54851. * Attach the feature to the session
  54852. * Will usually be called by the features manager
  54853. *
  54854. * @param force should attachment be forced (even when already attached)
  54855. * @returns true if successful.
  54856. */
  54857. attach(force?: boolean): boolean;
  54858. /**
  54859. * Detach the feature from the session
  54860. * Will usually be called by the features manager
  54861. *
  54862. * @returns true if successful.
  54863. */
  54864. detach(): boolean;
  54865. /**
  54866. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  54867. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  54868. *
  54869. * @returns whether or not the feature is compatible in this environment
  54870. */
  54871. isCompatible(): boolean;
  54872. /**
  54873. * Was this feature disposed;
  54874. */
  54875. isDisposed: boolean;
  54876. /**
  54877. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  54878. */
  54879. xrNativeFeatureName?: string;
  54880. /**
  54881. * A list of (Babylon WebXR) features this feature depends on
  54882. */
  54883. dependsOn?: string[];
  54884. /**
  54885. * If this feature requires to extend the XRSessionInit object, this function will return the partial XR session init object
  54886. */
  54887. getXRSessionInitExtension?: () => Promise<Partial<XRSessionInit>>;
  54888. }
  54889. /**
  54890. * A list of the currently available features without referencing them
  54891. */
  54892. export class WebXRFeatureName {
  54893. /**
  54894. * The name of the anchor system feature
  54895. */
  54896. static readonly ANCHOR_SYSTEM: string;
  54897. /**
  54898. * The name of the background remover feature
  54899. */
  54900. static readonly BACKGROUND_REMOVER: string;
  54901. /**
  54902. * The name of the hit test feature
  54903. */
  54904. static readonly HIT_TEST: string;
  54905. /**
  54906. * The name of the mesh detection feature
  54907. */
  54908. static readonly MESH_DETECTION: string;
  54909. /**
  54910. * physics impostors for xr controllers feature
  54911. */
  54912. static readonly PHYSICS_CONTROLLERS: string;
  54913. /**
  54914. * The name of the plane detection feature
  54915. */
  54916. static readonly PLANE_DETECTION: string;
  54917. /**
  54918. * The name of the pointer selection feature
  54919. */
  54920. static readonly POINTER_SELECTION: string;
  54921. /**
  54922. * The name of the teleportation feature
  54923. */
  54924. static readonly TELEPORTATION: string;
  54925. /**
  54926. * The name of the feature points feature.
  54927. */
  54928. static readonly FEATURE_POINTS: string;
  54929. /**
  54930. * The name of the hand tracking feature.
  54931. */
  54932. static readonly HAND_TRACKING: string;
  54933. /**
  54934. * The name of the image tracking feature
  54935. */
  54936. static readonly IMAGE_TRACKING: string;
  54937. }
  54938. /**
  54939. * Defining the constructor of a feature. Used to register the modules.
  54940. */
  54941. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  54942. /**
  54943. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  54944. * It is mainly used in AR sessions.
  54945. *
  54946. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  54947. */
  54948. export class WebXRFeaturesManager implements IDisposable {
  54949. private _xrSessionManager;
  54950. private static readonly _AvailableFeatures;
  54951. private _features;
  54952. /**
  54953. * constructs a new features manages.
  54954. *
  54955. * @param _xrSessionManager an instance of WebXRSessionManager
  54956. */
  54957. constructor(_xrSessionManager: WebXRSessionManager);
  54958. /**
  54959. * Used to register a module. After calling this function a developer can use this feature in the scene.
  54960. * Mainly used internally.
  54961. *
  54962. * @param featureName the name of the feature to register
  54963. * @param constructorFunction the function used to construct the module
  54964. * @param version the (babylon) version of the module
  54965. * @param stable is that a stable version of this module
  54966. */
  54967. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  54968. /**
  54969. * Returns a constructor of a specific feature.
  54970. *
  54971. * @param featureName the name of the feature to construct
  54972. * @param version the version of the feature to load
  54973. * @param xrSessionManager the xrSessionManager. Used to construct the module
  54974. * @param options optional options provided to the module.
  54975. * @returns a function that, when called, will return a new instance of this feature
  54976. */
  54977. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  54978. /**
  54979. * Can be used to return the list of features currently registered
  54980. *
  54981. * @returns an Array of available features
  54982. */
  54983. static GetAvailableFeatures(): string[];
  54984. /**
  54985. * Gets the versions available for a specific feature
  54986. * @param featureName the name of the feature
  54987. * @returns an array with the available versions
  54988. */
  54989. static GetAvailableVersions(featureName: string): string[];
  54990. /**
  54991. * Return the latest unstable version of this feature
  54992. * @param featureName the name of the feature to search
  54993. * @returns the version number. if not found will return -1
  54994. */
  54995. static GetLatestVersionOfFeature(featureName: string): number;
  54996. /**
  54997. * Return the latest stable version of this feature
  54998. * @param featureName the name of the feature to search
  54999. * @returns the version number. if not found will return -1
  55000. */
  55001. static GetStableVersionOfFeature(featureName: string): number;
  55002. /**
  55003. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  55004. * Can be used during a session to start a feature
  55005. * @param featureName the name of feature to attach
  55006. */
  55007. attachFeature(featureName: string): void;
  55008. /**
  55009. * Can be used inside a session or when the session ends to detach a specific feature
  55010. * @param featureName the name of the feature to detach
  55011. */
  55012. detachFeature(featureName: string): void;
  55013. /**
  55014. * Used to disable an already-enabled feature
  55015. * The feature will be disposed and will be recreated once enabled.
  55016. * @param featureName the feature to disable
  55017. * @returns true if disable was successful
  55018. */
  55019. disableFeature(featureName: string | {
  55020. Name: string;
  55021. }): boolean;
  55022. /**
  55023. * dispose this features manager
  55024. */
  55025. dispose(): void;
  55026. /**
  55027. * 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.
  55028. * 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.
  55029. *
  55030. * @param featureName the name of the feature to load or the class of the feature
  55031. * @param version optional version to load. if not provided the latest version will be enabled
  55032. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  55033. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  55034. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  55035. * @returns a new constructed feature or throws an error if feature not found.
  55036. */
  55037. enableFeature(featureName: string | {
  55038. Name: string;
  55039. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  55040. /**
  55041. * get the implementation of an enabled feature.
  55042. * @param featureName the name of the feature to load
  55043. * @returns the feature class, if found
  55044. */
  55045. getEnabledFeature(featureName: string): IWebXRFeature;
  55046. /**
  55047. * Get the list of enabled features
  55048. * @returns an array of enabled features
  55049. */
  55050. getEnabledFeatures(): string[];
  55051. /**
  55052. * This function will extend the session creation configuration object with enabled features.
  55053. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  55054. * according to the defined "required" variable, provided during enableFeature call
  55055. * @param xrSessionInit the xr Session init object to extend
  55056. *
  55057. * @returns an extended XRSessionInit object
  55058. */
  55059. _extendXRSessionInitObject(xrSessionInit: XRSessionInit): Promise<XRSessionInit>;
  55060. }
  55061. }
  55062. declare module BABYLON {
  55063. /**
  55064. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  55065. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  55066. */
  55067. export class WebXRExperienceHelper implements IDisposable {
  55068. private scene;
  55069. private _nonVRCamera;
  55070. private _originalSceneAutoClear;
  55071. private _supported;
  55072. /**
  55073. * Camera used to render xr content
  55074. */
  55075. camera: WebXRCamera;
  55076. /** A features manager for this xr session */
  55077. featuresManager: WebXRFeaturesManager;
  55078. /**
  55079. * Observers registered here will be triggered after the camera's initial transformation is set
  55080. * This can be used to set a different ground level or an extra rotation.
  55081. *
  55082. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  55083. * to the position set after this observable is done executing.
  55084. */
  55085. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  55086. /**
  55087. * Fires when the state of the experience helper has changed
  55088. */
  55089. onStateChangedObservable: Observable<WebXRState>;
  55090. /** Session manager used to keep track of xr session */
  55091. sessionManager: WebXRSessionManager;
  55092. /**
  55093. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  55094. */
  55095. state: WebXRState;
  55096. /**
  55097. * Creates a WebXRExperienceHelper
  55098. * @param scene The scene the helper should be created in
  55099. */
  55100. private constructor();
  55101. /**
  55102. * Creates the experience helper
  55103. * @param scene the scene to attach the experience helper to
  55104. * @returns a promise for the experience helper
  55105. */
  55106. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  55107. /**
  55108. * Disposes of the experience helper
  55109. */
  55110. dispose(): void;
  55111. /**
  55112. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  55113. * @param sessionMode options for the XR session
  55114. * @param referenceSpaceType frame of reference of the XR session
  55115. * @param renderTarget the output canvas that will be used to enter XR mode
  55116. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  55117. * @returns promise that resolves after xr mode has entered
  55118. */
  55119. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  55120. /**
  55121. * Exits XR mode and returns the scene to its original state
  55122. * @returns promise that resolves after xr mode has exited
  55123. */
  55124. exitXRAsync(): Promise<void>;
  55125. private _nonXRToXRCamera;
  55126. private _setState;
  55127. }
  55128. }
  55129. declare module BABYLON {
  55130. /**
  55131. * X-Y values for axes in WebXR
  55132. */
  55133. export interface IWebXRMotionControllerAxesValue {
  55134. /**
  55135. * The value of the x axis
  55136. */
  55137. x: number;
  55138. /**
  55139. * The value of the y-axis
  55140. */
  55141. y: number;
  55142. }
  55143. /**
  55144. * changed / previous values for the values of this component
  55145. */
  55146. export interface IWebXRMotionControllerComponentChangesValues<T> {
  55147. /**
  55148. * current (this frame) value
  55149. */
  55150. current: T;
  55151. /**
  55152. * previous (last change) value
  55153. */
  55154. previous: T;
  55155. }
  55156. /**
  55157. * Represents changes in the component between current frame and last values recorded
  55158. */
  55159. export interface IWebXRMotionControllerComponentChanges {
  55160. /**
  55161. * will be populated with previous and current values if axes changed
  55162. */
  55163. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  55164. /**
  55165. * will be populated with previous and current values if pressed changed
  55166. */
  55167. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  55168. /**
  55169. * will be populated with previous and current values if touched changed
  55170. */
  55171. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  55172. /**
  55173. * will be populated with previous and current values if value changed
  55174. */
  55175. value?: IWebXRMotionControllerComponentChangesValues<number>;
  55176. }
  55177. /**
  55178. * This class represents a single component (for example button or thumbstick) of a motion controller
  55179. */
  55180. export class WebXRControllerComponent implements IDisposable {
  55181. /**
  55182. * the id of this component
  55183. */
  55184. id: string;
  55185. /**
  55186. * the type of the component
  55187. */
  55188. type: MotionControllerComponentType;
  55189. private _buttonIndex;
  55190. private _axesIndices;
  55191. private _axes;
  55192. private _changes;
  55193. private _currentValue;
  55194. private _hasChanges;
  55195. private _pressed;
  55196. private _touched;
  55197. /**
  55198. * button component type
  55199. */
  55200. static BUTTON_TYPE: MotionControllerComponentType;
  55201. /**
  55202. * squeeze component type
  55203. */
  55204. static SQUEEZE_TYPE: MotionControllerComponentType;
  55205. /**
  55206. * Thumbstick component type
  55207. */
  55208. static THUMBSTICK_TYPE: MotionControllerComponentType;
  55209. /**
  55210. * Touchpad component type
  55211. */
  55212. static TOUCHPAD_TYPE: MotionControllerComponentType;
  55213. /**
  55214. * trigger component type
  55215. */
  55216. static TRIGGER_TYPE: MotionControllerComponentType;
  55217. /**
  55218. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  55219. * the axes data changes
  55220. */
  55221. onAxisValueChangedObservable: Observable<{
  55222. x: number;
  55223. y: number;
  55224. }>;
  55225. /**
  55226. * Observers registered here will be triggered when the state of a button changes
  55227. * State change is either pressed / touched / value
  55228. */
  55229. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  55230. /**
  55231. * Creates a new component for a motion controller.
  55232. * It is created by the motion controller itself
  55233. *
  55234. * @param id the id of this component
  55235. * @param type the type of the component
  55236. * @param _buttonIndex index in the buttons array of the gamepad
  55237. * @param _axesIndices indices of the values in the axes array of the gamepad
  55238. */
  55239. constructor(
  55240. /**
  55241. * the id of this component
  55242. */
  55243. id: string,
  55244. /**
  55245. * the type of the component
  55246. */
  55247. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  55248. /**
  55249. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  55250. */
  55251. get axes(): IWebXRMotionControllerAxesValue;
  55252. /**
  55253. * Get the changes. Elements will be populated only if they changed with their previous and current value
  55254. */
  55255. get changes(): IWebXRMotionControllerComponentChanges;
  55256. /**
  55257. * Return whether or not the component changed the last frame
  55258. */
  55259. get hasChanges(): boolean;
  55260. /**
  55261. * is the button currently pressed
  55262. */
  55263. get pressed(): boolean;
  55264. /**
  55265. * is the button currently touched
  55266. */
  55267. get touched(): boolean;
  55268. /**
  55269. * Get the current value of this component
  55270. */
  55271. get value(): number;
  55272. /**
  55273. * Dispose this component
  55274. */
  55275. dispose(): void;
  55276. /**
  55277. * Are there axes correlating to this component
  55278. * @return true is axes data is available
  55279. */
  55280. isAxes(): boolean;
  55281. /**
  55282. * Is this component a button (hence - pressable)
  55283. * @returns true if can be pressed
  55284. */
  55285. isButton(): boolean;
  55286. /**
  55287. * update this component using the gamepad object it is in. Called on every frame
  55288. * @param nativeController the native gamepad controller object
  55289. */
  55290. update(nativeController: IMinimalMotionControllerObject): void;
  55291. }
  55292. }
  55293. declare module BABYLON {
  55294. /**
  55295. * Type used for the success callback of ImportMesh
  55296. */
  55297. export type SceneLoaderSuccessCallback = (meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[], transformNodes: TransformNode[], geometries: Geometry[], lights: Light[]) => void;
  55298. /**
  55299. * Interface used for the result of ImportMeshAsync
  55300. */
  55301. export interface ISceneLoaderAsyncResult {
  55302. /**
  55303. * The array of loaded meshes
  55304. */
  55305. readonly meshes: AbstractMesh[];
  55306. /**
  55307. * The array of loaded particle systems
  55308. */
  55309. readonly particleSystems: IParticleSystem[];
  55310. /**
  55311. * The array of loaded skeletons
  55312. */
  55313. readonly skeletons: Skeleton[];
  55314. /**
  55315. * The array of loaded animation groups
  55316. */
  55317. readonly animationGroups: AnimationGroup[];
  55318. /**
  55319. * The array of loaded transform nodes
  55320. */
  55321. readonly transformNodes: TransformNode[];
  55322. /**
  55323. * The array of loaded geometries
  55324. */
  55325. readonly geometries: Geometry[];
  55326. /**
  55327. * The array of loaded lights
  55328. */
  55329. readonly lights: Light[];
  55330. }
  55331. /**
  55332. * Interface used to represent data loading progression
  55333. */
  55334. export interface ISceneLoaderProgressEvent {
  55335. /**
  55336. * Defines if data length to load can be evaluated
  55337. */
  55338. readonly lengthComputable: boolean;
  55339. /**
  55340. * Defines the loaded data length
  55341. */
  55342. readonly loaded: number;
  55343. /**
  55344. * Defines the data length to load
  55345. */
  55346. readonly total: number;
  55347. }
  55348. /**
  55349. * Interface used by SceneLoader plugins to define supported file extensions
  55350. */
  55351. export interface ISceneLoaderPluginExtensions {
  55352. /**
  55353. * Defines the list of supported extensions
  55354. */
  55355. [extension: string]: {
  55356. isBinary: boolean;
  55357. };
  55358. }
  55359. /**
  55360. * Interface used by SceneLoader plugin factory
  55361. */
  55362. export interface ISceneLoaderPluginFactory {
  55363. /**
  55364. * Defines the name of the factory
  55365. */
  55366. name: string;
  55367. /**
  55368. * Function called to create a new plugin
  55369. * @return the new plugin
  55370. */
  55371. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  55372. /**
  55373. * The callback that returns true if the data can be directly loaded.
  55374. * @param data string containing the file data
  55375. * @returns if the data can be loaded directly
  55376. */
  55377. canDirectLoad?(data: string): boolean;
  55378. }
  55379. /**
  55380. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  55381. */
  55382. export interface ISceneLoaderPluginBase {
  55383. /**
  55384. * The friendly name of this plugin.
  55385. */
  55386. name: string;
  55387. /**
  55388. * The file extensions supported by this plugin.
  55389. */
  55390. extensions: string | ISceneLoaderPluginExtensions;
  55391. /**
  55392. * The callback called when loading from a url.
  55393. * @param scene scene loading this url
  55394. * @param url url to load
  55395. * @param onSuccess callback called when the file successfully loads
  55396. * @param onProgress callback called while file is loading (if the server supports this mode)
  55397. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  55398. * @param onError callback called when the file fails to load
  55399. * @returns a file request object
  55400. */
  55401. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  55402. /**
  55403. * The callback called when loading from a file object.
  55404. * @param scene scene loading this file
  55405. * @param file defines the file to load
  55406. * @param onSuccess defines the callback to call when data is loaded
  55407. * @param onProgress defines the callback to call during loading process
  55408. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  55409. * @param onError defines the callback to call when an error occurs
  55410. * @returns a file request object
  55411. */
  55412. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  55413. /**
  55414. * The callback that returns true if the data can be directly loaded.
  55415. * @param data string containing the file data
  55416. * @returns if the data can be loaded directly
  55417. */
  55418. canDirectLoad?(data: string): boolean;
  55419. /**
  55420. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  55421. * @param scene scene loading this data
  55422. * @param data string containing the data
  55423. * @returns data to pass to the plugin
  55424. */
  55425. directLoad?(scene: Scene, data: string): any;
  55426. /**
  55427. * The callback that allows custom handling of the root url based on the response url.
  55428. * @param rootUrl the original root url
  55429. * @param responseURL the response url if available
  55430. * @returns the new root url
  55431. */
  55432. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  55433. }
  55434. /**
  55435. * Interface used to define a SceneLoader plugin
  55436. */
  55437. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  55438. /**
  55439. * Import meshes into a scene.
  55440. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  55441. * @param scene The scene to import into
  55442. * @param data The data to import
  55443. * @param rootUrl The root url for scene and resources
  55444. * @param meshes The meshes array to import into
  55445. * @param particleSystems The particle systems array to import into
  55446. * @param skeletons The skeletons array to import into
  55447. * @param onError The callback when import fails
  55448. * @returns True if successful or false otherwise
  55449. */
  55450. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  55451. /**
  55452. * Load into a scene.
  55453. * @param scene The scene to load into
  55454. * @param data The data to import
  55455. * @param rootUrl The root url for scene and resources
  55456. * @param onError The callback when import fails
  55457. * @returns True if successful or false otherwise
  55458. */
  55459. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  55460. /**
  55461. * Load into an asset container.
  55462. * @param scene The scene to load into
  55463. * @param data The data to import
  55464. * @param rootUrl The root url for scene and resources
  55465. * @param onError The callback when import fails
  55466. * @returns The loaded asset container
  55467. */
  55468. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  55469. }
  55470. /**
  55471. * Interface used to define an async SceneLoader plugin
  55472. */
  55473. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  55474. /**
  55475. * Import meshes into a scene.
  55476. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  55477. * @param scene The scene to import into
  55478. * @param data The data to import
  55479. * @param rootUrl The root url for scene and resources
  55480. * @param onProgress The callback when the load progresses
  55481. * @param fileName Defines the name of the file to load
  55482. * @returns The loaded objects (e.g. meshes, particle systems, skeletons, animation groups, etc.)
  55483. */
  55484. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  55485. /**
  55486. * Load into a scene.
  55487. * @param scene The scene to load into
  55488. * @param data The data to import
  55489. * @param rootUrl The root url for scene and resources
  55490. * @param onProgress The callback when the load progresses
  55491. * @param fileName Defines the name of the file to load
  55492. * @returns Nothing
  55493. */
  55494. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  55495. /**
  55496. * Load into an asset container.
  55497. * @param scene The scene to load into
  55498. * @param data The data to import
  55499. * @param rootUrl The root url for scene and resources
  55500. * @param onProgress The callback when the load progresses
  55501. * @param fileName Defines the name of the file to load
  55502. * @returns The loaded asset container
  55503. */
  55504. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  55505. }
  55506. /**
  55507. * Mode that determines how to handle old animation groups before loading new ones.
  55508. */
  55509. export enum SceneLoaderAnimationGroupLoadingMode {
  55510. /**
  55511. * Reset all old animations to initial state then dispose them.
  55512. */
  55513. Clean = 0,
  55514. /**
  55515. * Stop all old animations.
  55516. */
  55517. Stop = 1,
  55518. /**
  55519. * Restart old animations from first frame.
  55520. */
  55521. Sync = 2,
  55522. /**
  55523. * Old animations remains untouched.
  55524. */
  55525. NoSync = 3
  55526. }
  55527. /**
  55528. * Defines a plugin registered by the SceneLoader
  55529. */
  55530. interface IRegisteredPlugin {
  55531. /**
  55532. * Defines the plugin to use
  55533. */
  55534. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  55535. /**
  55536. * Defines if the plugin supports binary data
  55537. */
  55538. isBinary: boolean;
  55539. }
  55540. /**
  55541. * Class used to load scene from various file formats using registered plugins
  55542. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  55543. */
  55544. export class SceneLoader {
  55545. /**
  55546. * No logging while loading
  55547. */
  55548. static readonly NO_LOGGING: number;
  55549. /**
  55550. * Minimal logging while loading
  55551. */
  55552. static readonly MINIMAL_LOGGING: number;
  55553. /**
  55554. * Summary logging while loading
  55555. */
  55556. static readonly SUMMARY_LOGGING: number;
  55557. /**
  55558. * Detailed logging while loading
  55559. */
  55560. static readonly DETAILED_LOGGING: number;
  55561. /**
  55562. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  55563. */
  55564. static get ForceFullSceneLoadingForIncremental(): boolean;
  55565. static set ForceFullSceneLoadingForIncremental(value: boolean);
  55566. /**
  55567. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  55568. */
  55569. static get ShowLoadingScreen(): boolean;
  55570. static set ShowLoadingScreen(value: boolean);
  55571. /**
  55572. * Defines the current logging level (while loading the scene)
  55573. * @ignorenaming
  55574. */
  55575. static get loggingLevel(): number;
  55576. static set loggingLevel(value: number);
  55577. /**
  55578. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  55579. */
  55580. static get CleanBoneMatrixWeights(): boolean;
  55581. static set CleanBoneMatrixWeights(value: boolean);
  55582. /**
  55583. * Event raised when a plugin is used to load a scene
  55584. */
  55585. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  55586. private static _registeredPlugins;
  55587. private static _showingLoadingScreen;
  55588. /**
  55589. * Gets the default plugin (used to load Babylon files)
  55590. * @returns the .babylon plugin
  55591. */
  55592. static GetDefaultPlugin(): IRegisteredPlugin;
  55593. private static _GetPluginForExtension;
  55594. private static _GetPluginForDirectLoad;
  55595. private static _GetPluginForFilename;
  55596. private static _GetDirectLoad;
  55597. private static _LoadData;
  55598. private static _GetFileInfo;
  55599. /**
  55600. * Gets a plugin that can load the given extension
  55601. * @param extension defines the extension to load
  55602. * @returns a plugin or null if none works
  55603. */
  55604. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  55605. /**
  55606. * Gets a boolean indicating that the given extension can be loaded
  55607. * @param extension defines the extension to load
  55608. * @returns true if the extension is supported
  55609. */
  55610. static IsPluginForExtensionAvailable(extension: string): boolean;
  55611. /**
  55612. * Adds a new plugin to the list of registered plugins
  55613. * @param plugin defines the plugin to add
  55614. */
  55615. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  55616. /**
  55617. * Import meshes into a scene
  55618. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  55619. * @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)
  55620. * @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)
  55621. * @param scene the instance of BABYLON.Scene to append to
  55622. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  55623. * @param onProgress a callback with a progress event for each file being loaded
  55624. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  55625. * @param pluginExtension the extension used to determine the plugin
  55626. * @returns The loaded plugin
  55627. */
  55628. 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>;
  55629. /**
  55630. * Import meshes into a scene
  55631. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  55632. * @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)
  55633. * @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)
  55634. * @param scene the instance of BABYLON.Scene to append to
  55635. * @param onProgress a callback with a progress event for each file being loaded
  55636. * @param pluginExtension the extension used to determine the plugin
  55637. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  55638. */
  55639. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<ISceneLoaderAsyncResult>;
  55640. /**
  55641. * Load a scene
  55642. * @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)
  55643. * @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)
  55644. * @param engine is the instance of BABYLON.Engine to use to create the scene
  55645. * @param onSuccess a callback with the scene when import succeeds
  55646. * @param onProgress a callback with a progress event for each file being loaded
  55647. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  55648. * @param pluginExtension the extension used to determine the plugin
  55649. * @returns The loaded plugin
  55650. */
  55651. 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>;
  55652. /**
  55653. * Load a scene
  55654. * @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)
  55655. * @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)
  55656. * @param engine is the instance of BABYLON.Engine to use to create the scene
  55657. * @param onProgress a callback with a progress event for each file being loaded
  55658. * @param pluginExtension the extension used to determine the plugin
  55659. * @returns The loaded scene
  55660. */
  55661. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  55662. /**
  55663. * Append a scene
  55664. * @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)
  55665. * @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)
  55666. * @param scene is the instance of BABYLON.Scene to append to
  55667. * @param onSuccess a callback with the scene when import succeeds
  55668. * @param onProgress a callback with a progress event for each file being loaded
  55669. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  55670. * @param pluginExtension the extension used to determine the plugin
  55671. * @returns The loaded plugin
  55672. */
  55673. 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>;
  55674. /**
  55675. * Append a scene
  55676. * @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)
  55677. * @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)
  55678. * @param scene is the instance of BABYLON.Scene to append to
  55679. * @param onProgress a callback with a progress event for each file being loaded
  55680. * @param pluginExtension the extension used to determine the plugin
  55681. * @returns The given scene
  55682. */
  55683. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  55684. /**
  55685. * Load a scene into an asset container
  55686. * @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)
  55687. * @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)
  55688. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  55689. * @param onSuccess a callback with the scene when import succeeds
  55690. * @param onProgress a callback with a progress event for each file being loaded
  55691. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  55692. * @param pluginExtension the extension used to determine the plugin
  55693. * @returns The loaded plugin
  55694. */
  55695. 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>;
  55696. /**
  55697. * Load a scene into an asset container
  55698. * @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)
  55699. * @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)
  55700. * @param scene is the instance of Scene to append to
  55701. * @param onProgress a callback with a progress event for each file being loaded
  55702. * @param pluginExtension the extension used to determine the plugin
  55703. * @returns The loaded asset container
  55704. */
  55705. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  55706. /**
  55707. * Import animations from a file into a scene
  55708. * @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)
  55709. * @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)
  55710. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  55711. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  55712. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  55713. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  55714. * @param onSuccess a callback with the scene when import succeeds
  55715. * @param onProgress a callback with a progress event for each file being loaded
  55716. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  55717. * @param pluginExtension the extension used to determine the plugin
  55718. */
  55719. 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;
  55720. /**
  55721. * Import animations from a file into a scene
  55722. * @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)
  55723. * @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)
  55724. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  55725. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  55726. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  55727. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  55728. * @param onSuccess a callback with the scene when import succeeds
  55729. * @param onProgress a callback with a progress event for each file being loaded
  55730. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  55731. * @param pluginExtension the extension used to determine the plugin
  55732. * @returns the updated scene with imported animations
  55733. */
  55734. 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>;
  55735. }
  55736. }
  55737. declare module BABYLON {
  55738. /**
  55739. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  55740. */
  55741. export type MotionControllerHandedness = "none" | "left" | "right";
  55742. /**
  55743. * The type of components available in motion controllers.
  55744. * This is not the name of the component.
  55745. */
  55746. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  55747. /**
  55748. * The state of a controller component
  55749. */
  55750. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  55751. /**
  55752. * The schema of motion controller layout.
  55753. * No object will be initialized using this interface
  55754. * This is used just to define the profile.
  55755. */
  55756. export interface IMotionControllerLayout {
  55757. /**
  55758. * Path to load the assets. Usually relative to the base path
  55759. */
  55760. assetPath: string;
  55761. /**
  55762. * Available components (unsorted)
  55763. */
  55764. components: {
  55765. /**
  55766. * A map of component Ids
  55767. */
  55768. [componentId: string]: {
  55769. /**
  55770. * The type of input the component outputs
  55771. */
  55772. type: MotionControllerComponentType;
  55773. /**
  55774. * The indices of this component in the gamepad object
  55775. */
  55776. gamepadIndices: {
  55777. /**
  55778. * Index of button
  55779. */
  55780. button?: number;
  55781. /**
  55782. * If available, index of x-axis
  55783. */
  55784. xAxis?: number;
  55785. /**
  55786. * If available, index of y-axis
  55787. */
  55788. yAxis?: number;
  55789. };
  55790. /**
  55791. * The mesh's root node name
  55792. */
  55793. rootNodeName: string;
  55794. /**
  55795. * Animation definitions for this model
  55796. */
  55797. visualResponses: {
  55798. [stateKey: string]: {
  55799. /**
  55800. * What property will be animated
  55801. */
  55802. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  55803. /**
  55804. * What states influence this visual response
  55805. */
  55806. states: MotionControllerComponentStateType[];
  55807. /**
  55808. * Type of animation - movement or visibility
  55809. */
  55810. valueNodeProperty: "transform" | "visibility";
  55811. /**
  55812. * Base node name to move. Its position will be calculated according to the min and max nodes
  55813. */
  55814. valueNodeName?: string;
  55815. /**
  55816. * Minimum movement node
  55817. */
  55818. minNodeName?: string;
  55819. /**
  55820. * Max movement node
  55821. */
  55822. maxNodeName?: string;
  55823. };
  55824. };
  55825. /**
  55826. * If touch enabled, what is the name of node to display user feedback
  55827. */
  55828. touchPointNodeName?: string;
  55829. };
  55830. };
  55831. /**
  55832. * Is it xr standard mapping or not
  55833. */
  55834. gamepadMapping: "" | "xr-standard";
  55835. /**
  55836. * Base root node of this entire model
  55837. */
  55838. rootNodeName: string;
  55839. /**
  55840. * Defines the main button component id
  55841. */
  55842. selectComponentId: string;
  55843. }
  55844. /**
  55845. * A definition for the layout map in the input profile
  55846. */
  55847. export interface IMotionControllerLayoutMap {
  55848. /**
  55849. * Layouts with handedness type as a key
  55850. */
  55851. [handedness: string]: IMotionControllerLayout;
  55852. }
  55853. /**
  55854. * The XR Input profile schema
  55855. * Profiles can be found here:
  55856. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  55857. */
  55858. export interface IMotionControllerProfile {
  55859. /**
  55860. * fallback profiles for this profileId
  55861. */
  55862. fallbackProfileIds: string[];
  55863. /**
  55864. * The layout map, with handedness as key
  55865. */
  55866. layouts: IMotionControllerLayoutMap;
  55867. /**
  55868. * The id of this profile
  55869. * correlates to the profile(s) in the xrInput.profiles array
  55870. */
  55871. profileId: string;
  55872. }
  55873. /**
  55874. * A helper-interface for the 3 meshes needed for controller button animation
  55875. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  55876. */
  55877. export interface IMotionControllerButtonMeshMap {
  55878. /**
  55879. * the mesh that defines the pressed value mesh position.
  55880. * This is used to find the max-position of this button
  55881. */
  55882. pressedMesh: AbstractMesh;
  55883. /**
  55884. * the mesh that defines the unpressed value mesh position.
  55885. * This is used to find the min (or initial) position of this button
  55886. */
  55887. unpressedMesh: AbstractMesh;
  55888. /**
  55889. * The mesh that will be changed when value changes
  55890. */
  55891. valueMesh: AbstractMesh;
  55892. }
  55893. /**
  55894. * A helper-interface for the 3 meshes needed for controller axis animation.
  55895. * This will be expanded when touchpad animations are fully supported
  55896. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  55897. */
  55898. export interface IMotionControllerMeshMap {
  55899. /**
  55900. * the mesh that defines the maximum value mesh position.
  55901. */
  55902. maxMesh?: AbstractMesh;
  55903. /**
  55904. * the mesh that defines the minimum value mesh position.
  55905. */
  55906. minMesh?: AbstractMesh;
  55907. /**
  55908. * The mesh that will be changed when axis value changes
  55909. */
  55910. valueMesh?: AbstractMesh;
  55911. }
  55912. /**
  55913. * The elements needed for change-detection of the gamepad objects in motion controllers
  55914. */
  55915. export interface IMinimalMotionControllerObject {
  55916. /**
  55917. * Available axes of this controller
  55918. */
  55919. axes: number[];
  55920. /**
  55921. * An array of available buttons
  55922. */
  55923. buttons: Array<{
  55924. /**
  55925. * Value of the button/trigger
  55926. */
  55927. value: number;
  55928. /**
  55929. * If the button/trigger is currently touched
  55930. */
  55931. touched: boolean;
  55932. /**
  55933. * If the button/trigger is currently pressed
  55934. */
  55935. pressed: boolean;
  55936. }>;
  55937. /**
  55938. * EXPERIMENTAL haptic support.
  55939. */
  55940. hapticActuators?: Array<{
  55941. pulse: (value: number, duration: number) => Promise<boolean>;
  55942. }>;
  55943. }
  55944. /**
  55945. * An Abstract Motion controller
  55946. * This class receives an xrInput and a profile layout and uses those to initialize the components
  55947. * Each component has an observable to check for changes in value and state
  55948. */
  55949. export abstract class WebXRAbstractMotionController implements IDisposable {
  55950. protected scene: Scene;
  55951. protected layout: IMotionControllerLayout;
  55952. /**
  55953. * The gamepad object correlating to this controller
  55954. */
  55955. gamepadObject: IMinimalMotionControllerObject;
  55956. /**
  55957. * handedness (left/right/none) of this controller
  55958. */
  55959. handedness: MotionControllerHandedness;
  55960. private _initComponent;
  55961. private _modelReady;
  55962. /**
  55963. * A map of components (WebXRControllerComponent) in this motion controller
  55964. * Components have a ComponentType and can also have both button and axis definitions
  55965. */
  55966. readonly components: {
  55967. [id: string]: WebXRControllerComponent;
  55968. };
  55969. /**
  55970. * Disable the model's animation. Can be set at any time.
  55971. */
  55972. disableAnimation: boolean;
  55973. /**
  55974. * Observers registered here will be triggered when the model of this controller is done loading
  55975. */
  55976. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  55977. /**
  55978. * The profile id of this motion controller
  55979. */
  55980. abstract profileId: string;
  55981. /**
  55982. * The root mesh of the model. It is null if the model was not yet initialized
  55983. */
  55984. rootMesh: Nullable<AbstractMesh>;
  55985. /**
  55986. * constructs a new abstract motion controller
  55987. * @param scene the scene to which the model of the controller will be added
  55988. * @param layout The profile layout to load
  55989. * @param gamepadObject The gamepad object correlating to this controller
  55990. * @param handedness handedness (left/right/none) of this controller
  55991. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  55992. */
  55993. constructor(scene: Scene, layout: IMotionControllerLayout,
  55994. /**
  55995. * The gamepad object correlating to this controller
  55996. */
  55997. gamepadObject: IMinimalMotionControllerObject,
  55998. /**
  55999. * handedness (left/right/none) of this controller
  56000. */
  56001. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  56002. /**
  56003. * Dispose this controller, the model mesh and all its components
  56004. */
  56005. dispose(): void;
  56006. /**
  56007. * Returns all components of specific type
  56008. * @param type the type to search for
  56009. * @return an array of components with this type
  56010. */
  56011. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  56012. /**
  56013. * get a component based an its component id as defined in layout.components
  56014. * @param id the id of the component
  56015. * @returns the component correlates to the id or undefined if not found
  56016. */
  56017. getComponent(id: string): WebXRControllerComponent;
  56018. /**
  56019. * Get the list of components available in this motion controller
  56020. * @returns an array of strings correlating to available components
  56021. */
  56022. getComponentIds(): string[];
  56023. /**
  56024. * Get the first component of specific type
  56025. * @param type type of component to find
  56026. * @return a controller component or null if not found
  56027. */
  56028. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  56029. /**
  56030. * Get the main (Select) component of this controller as defined in the layout
  56031. * @returns the main component of this controller
  56032. */
  56033. getMainComponent(): WebXRControllerComponent;
  56034. /**
  56035. * Loads the model correlating to this controller
  56036. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  56037. * @returns A promise fulfilled with the result of the model loading
  56038. */
  56039. loadModel(): Promise<boolean>;
  56040. /**
  56041. * Update this model using the current XRFrame
  56042. * @param xrFrame the current xr frame to use and update the model
  56043. */
  56044. updateFromXRFrame(xrFrame: XRFrame): void;
  56045. /**
  56046. * Backwards compatibility due to a deeply-integrated typo
  56047. */
  56048. get handness(): XREye;
  56049. /**
  56050. * Pulse (vibrate) this controller
  56051. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  56052. * Consecutive calls to this function will cancel the last pulse call
  56053. *
  56054. * @param value the strength of the pulse in 0.0...1.0 range
  56055. * @param duration Duration of the pulse in milliseconds
  56056. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  56057. * @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
  56058. */
  56059. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  56060. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  56061. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  56062. /**
  56063. * Moves the axis on the controller mesh based on its current state
  56064. * @param axis the index of the axis
  56065. * @param axisValue the value of the axis which determines the meshes new position
  56066. * @hidden
  56067. */
  56068. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  56069. /**
  56070. * Update the model itself with the current frame data
  56071. * @param xrFrame the frame to use for updating the model mesh
  56072. */
  56073. protected updateModel(xrFrame: XRFrame): void;
  56074. /**
  56075. * Get the filename and path for this controller's model
  56076. * @returns a map of filename and path
  56077. */
  56078. protected abstract _getFilenameAndPath(): {
  56079. filename: string;
  56080. path: string;
  56081. };
  56082. /**
  56083. * This function is called before the mesh is loaded. It checks for loading constraints.
  56084. * For example, this function can check if the GLB loader is available
  56085. * If this function returns false, the generic controller will be loaded instead
  56086. * @returns Is the client ready to load the mesh
  56087. */
  56088. protected abstract _getModelLoadingConstraints(): boolean;
  56089. /**
  56090. * This function will be called after the model was successfully loaded and can be used
  56091. * for mesh transformations before it is available for the user
  56092. * @param meshes the loaded meshes
  56093. */
  56094. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  56095. /**
  56096. * Set the root mesh for this controller. Important for the WebXR controller class
  56097. * @param meshes the loaded meshes
  56098. */
  56099. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  56100. /**
  56101. * A function executed each frame that updates the mesh (if needed)
  56102. * @param xrFrame the current xrFrame
  56103. */
  56104. protected abstract _updateModel(xrFrame: XRFrame): void;
  56105. private _getGenericFilenameAndPath;
  56106. private _getGenericParentMesh;
  56107. }
  56108. }
  56109. declare module BABYLON {
  56110. /**
  56111. * A generic trigger-only motion controller for WebXR
  56112. */
  56113. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  56114. /**
  56115. * Static version of the profile id of this controller
  56116. */
  56117. static ProfileId: string;
  56118. profileId: string;
  56119. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  56120. protected _getFilenameAndPath(): {
  56121. filename: string;
  56122. path: string;
  56123. };
  56124. protected _getModelLoadingConstraints(): boolean;
  56125. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  56126. protected _setRootMesh(meshes: AbstractMesh[]): void;
  56127. protected _updateModel(): void;
  56128. }
  56129. }
  56130. declare module BABYLON {
  56131. /**
  56132. * Class containing static functions to help procedurally build meshes
  56133. */
  56134. export class SphereBuilder {
  56135. /**
  56136. * Creates a sphere mesh
  56137. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  56138. * * 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`)
  56139. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  56140. * * 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
  56141. * * 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)
  56142. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56143. * * 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
  56144. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56145. * @param name defines the name of the mesh
  56146. * @param options defines the options used to create the mesh
  56147. * @param scene defines the hosting scene
  56148. * @returns the sphere mesh
  56149. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  56150. */
  56151. static CreateSphere(name: string, options: {
  56152. segments?: number;
  56153. diameter?: number;
  56154. diameterX?: number;
  56155. diameterY?: number;
  56156. diameterZ?: number;
  56157. arc?: number;
  56158. slice?: number;
  56159. sideOrientation?: number;
  56160. frontUVs?: Vector4;
  56161. backUVs?: Vector4;
  56162. updatable?: boolean;
  56163. }, scene?: Nullable<Scene>): Mesh;
  56164. }
  56165. }
  56166. declare module BABYLON {
  56167. /**
  56168. * A profiled motion controller has its profile loaded from an online repository.
  56169. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  56170. */
  56171. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  56172. private _repositoryUrl;
  56173. private _buttonMeshMapping;
  56174. private _touchDots;
  56175. /**
  56176. * The profile ID of this controller. Will be populated when the controller initializes.
  56177. */
  56178. profileId: string;
  56179. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  56180. dispose(): void;
  56181. protected _getFilenameAndPath(): {
  56182. filename: string;
  56183. path: string;
  56184. };
  56185. protected _getModelLoadingConstraints(): boolean;
  56186. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  56187. protected _setRootMesh(meshes: AbstractMesh[]): void;
  56188. protected _updateModel(_xrFrame: XRFrame): void;
  56189. }
  56190. }
  56191. declare module BABYLON {
  56192. /**
  56193. * A construction function type to create a new controller based on an xrInput object
  56194. */
  56195. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  56196. /**
  56197. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  56198. *
  56199. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  56200. * it should be replaced with auto-loaded controllers.
  56201. *
  56202. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  56203. */
  56204. export class WebXRMotionControllerManager {
  56205. private static _AvailableControllers;
  56206. private static _Fallbacks;
  56207. private static _ProfileLoadingPromises;
  56208. private static _ProfilesList;
  56209. /**
  56210. * The base URL of the online controller repository. Can be changed at any time.
  56211. */
  56212. static BaseRepositoryUrl: string;
  56213. /**
  56214. * Which repository gets priority - local or online
  56215. */
  56216. static PrioritizeOnlineRepository: boolean;
  56217. /**
  56218. * Use the online repository, or use only locally-defined controllers
  56219. */
  56220. static UseOnlineRepository: boolean;
  56221. /**
  56222. * Clear the cache used for profile loading and reload when requested again
  56223. */
  56224. static ClearProfilesCache(): void;
  56225. /**
  56226. * Register the default fallbacks.
  56227. * This function is called automatically when this file is imported.
  56228. */
  56229. static DefaultFallbacks(): void;
  56230. /**
  56231. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  56232. * @param profileId the profile to which a fallback needs to be found
  56233. * @return an array with corresponding fallback profiles
  56234. */
  56235. static FindFallbackWithProfileId(profileId: string): string[];
  56236. /**
  56237. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  56238. * The order of search:
  56239. *
  56240. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  56241. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  56242. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  56243. * 4) return the generic trigger controller if none were found
  56244. *
  56245. * @param xrInput the xrInput to which a new controller is initialized
  56246. * @param scene the scene to which the model will be added
  56247. * @param forceProfile force a certain profile for this controller
  56248. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  56249. */
  56250. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  56251. /**
  56252. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  56253. *
  56254. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  56255. *
  56256. * @param type the profile type to register
  56257. * @param constructFunction the function to be called when loading this profile
  56258. */
  56259. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  56260. /**
  56261. * Register a fallback to a specific profile.
  56262. * @param profileId the profileId that will receive the fallbacks
  56263. * @param fallbacks A list of fallback profiles
  56264. */
  56265. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  56266. /**
  56267. * Will update the list of profiles available in the repository
  56268. * @return a promise that resolves to a map of profiles available online
  56269. */
  56270. static UpdateProfilesList(): Promise<{
  56271. [profile: string]: string;
  56272. }>;
  56273. private static _LoadProfileFromRepository;
  56274. private static _LoadProfilesFromAvailableControllers;
  56275. }
  56276. }
  56277. declare module BABYLON {
  56278. /**
  56279. * Configuration options for the WebXR controller creation
  56280. */
  56281. export interface IWebXRControllerOptions {
  56282. /**
  56283. * Should the controller mesh be animated when a user interacts with it
  56284. * The pressed buttons / thumbstick and touchpad animations will be disabled
  56285. */
  56286. disableMotionControllerAnimation?: boolean;
  56287. /**
  56288. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  56289. */
  56290. doNotLoadControllerMesh?: boolean;
  56291. /**
  56292. * Force a specific controller type for this controller.
  56293. * This can be used when creating your own profile or when testing different controllers
  56294. */
  56295. forceControllerProfile?: string;
  56296. /**
  56297. * Defines a rendering group ID for meshes that will be loaded.
  56298. * This is for the default controllers only.
  56299. */
  56300. renderingGroupId?: number;
  56301. }
  56302. /**
  56303. * Represents an XR controller
  56304. */
  56305. export class WebXRInputSource {
  56306. private _scene;
  56307. /** The underlying input source for the controller */
  56308. inputSource: XRInputSource;
  56309. private _options;
  56310. private _tmpVector;
  56311. private _uniqueId;
  56312. private _disposed;
  56313. /**
  56314. * 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
  56315. */
  56316. grip?: AbstractMesh;
  56317. /**
  56318. * If available, this is the gamepad object related to this controller.
  56319. * Using this object it is possible to get click events and trackpad changes of the
  56320. * webxr controller that is currently being used.
  56321. */
  56322. motionController?: WebXRAbstractMotionController;
  56323. /**
  56324. * Event that fires when the controller is removed/disposed.
  56325. * The object provided as event data is this controller, after associated assets were disposed.
  56326. * uniqueId is still available.
  56327. */
  56328. onDisposeObservable: Observable<WebXRInputSource>;
  56329. /**
  56330. * Will be triggered when the mesh associated with the motion controller is done loading.
  56331. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  56332. * A shortened version of controller -> motion controller -> on mesh loaded.
  56333. */
  56334. onMeshLoadedObservable: Observable<AbstractMesh>;
  56335. /**
  56336. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  56337. */
  56338. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  56339. /**
  56340. * Pointer which can be used to select objects or attach a visible laser to
  56341. */
  56342. pointer: AbstractMesh;
  56343. /**
  56344. * Creates the input source object
  56345. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  56346. * @param _scene the scene which the controller should be associated to
  56347. * @param inputSource the underlying input source for the controller
  56348. * @param _options options for this controller creation
  56349. */
  56350. constructor(_scene: Scene,
  56351. /** The underlying input source for the controller */
  56352. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  56353. /**
  56354. * Get this controllers unique id
  56355. */
  56356. get uniqueId(): string;
  56357. /**
  56358. * Disposes of the object
  56359. */
  56360. dispose(): void;
  56361. /**
  56362. * Gets a world space ray coming from the pointer or grip
  56363. * @param result the resulting ray
  56364. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  56365. */
  56366. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  56367. /**
  56368. * Updates the controller pose based on the given XRFrame
  56369. * @param xrFrame xr frame to update the pose with
  56370. * @param referenceSpace reference space to use
  56371. */
  56372. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  56373. }
  56374. }
  56375. declare module BABYLON {
  56376. /**
  56377. * The schema for initialization options of the XR Input class
  56378. */
  56379. export interface IWebXRInputOptions {
  56380. /**
  56381. * If set to true no model will be automatically loaded
  56382. */
  56383. doNotLoadControllerMeshes?: boolean;
  56384. /**
  56385. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  56386. * If not found, the xr input profile data will be used.
  56387. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  56388. */
  56389. forceInputProfile?: string;
  56390. /**
  56391. * Do not send a request to the controller repository to load the profile.
  56392. *
  56393. * Instead, use the controllers available in babylon itself.
  56394. */
  56395. disableOnlineControllerRepository?: boolean;
  56396. /**
  56397. * A custom URL for the controllers repository
  56398. */
  56399. customControllersRepositoryURL?: string;
  56400. /**
  56401. * Should the controller model's components not move according to the user input
  56402. */
  56403. disableControllerAnimation?: boolean;
  56404. /**
  56405. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  56406. */
  56407. controllerOptions?: IWebXRControllerOptions;
  56408. }
  56409. /**
  56410. * XR input used to track XR inputs such as controllers/rays
  56411. */
  56412. export class WebXRInput implements IDisposable {
  56413. /**
  56414. * the xr session manager for this session
  56415. */
  56416. xrSessionManager: WebXRSessionManager;
  56417. /**
  56418. * the WebXR camera for this session. Mainly used for teleportation
  56419. */
  56420. xrCamera: WebXRCamera;
  56421. private readonly options;
  56422. /**
  56423. * XR controllers being tracked
  56424. */
  56425. controllers: Array<WebXRInputSource>;
  56426. private _frameObserver;
  56427. private _sessionEndedObserver;
  56428. private _sessionInitObserver;
  56429. /**
  56430. * Event when a controller has been connected/added
  56431. */
  56432. onControllerAddedObservable: Observable<WebXRInputSource>;
  56433. /**
  56434. * Event when a controller has been removed/disconnected
  56435. */
  56436. onControllerRemovedObservable: Observable<WebXRInputSource>;
  56437. /**
  56438. * Initializes the WebXRInput
  56439. * @param xrSessionManager the xr session manager for this session
  56440. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  56441. * @param options = initialization options for this xr input
  56442. */
  56443. constructor(
  56444. /**
  56445. * the xr session manager for this session
  56446. */
  56447. xrSessionManager: WebXRSessionManager,
  56448. /**
  56449. * the WebXR camera for this session. Mainly used for teleportation
  56450. */
  56451. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  56452. private _onInputSourcesChange;
  56453. private _addAndRemoveControllers;
  56454. /**
  56455. * Disposes of the object
  56456. */
  56457. dispose(): void;
  56458. }
  56459. }
  56460. declare module BABYLON {
  56461. /**
  56462. * This is the base class for all WebXR features.
  56463. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  56464. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  56465. */
  56466. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  56467. protected _xrSessionManager: WebXRSessionManager;
  56468. private _attached;
  56469. private _removeOnDetach;
  56470. /**
  56471. * Is this feature disposed?
  56472. */
  56473. isDisposed: boolean;
  56474. /**
  56475. * Should auto-attach be disabled?
  56476. */
  56477. disableAutoAttach: boolean;
  56478. /**
  56479. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  56480. */
  56481. xrNativeFeatureName: string;
  56482. /**
  56483. * Construct a new (abstract) WebXR feature
  56484. * @param _xrSessionManager the xr session manager for this feature
  56485. */
  56486. constructor(_xrSessionManager: WebXRSessionManager);
  56487. /**
  56488. * Is this feature attached
  56489. */
  56490. get attached(): boolean;
  56491. /**
  56492. * attach this feature
  56493. *
  56494. * @param force should attachment be forced (even when already attached)
  56495. * @returns true if successful, false is failed or already attached
  56496. */
  56497. attach(force?: boolean): boolean;
  56498. /**
  56499. * detach this feature.
  56500. *
  56501. * @returns true if successful, false if failed or already detached
  56502. */
  56503. detach(): boolean;
  56504. /**
  56505. * Dispose this feature and all of the resources attached
  56506. */
  56507. dispose(): void;
  56508. /**
  56509. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  56510. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  56511. *
  56512. * @returns whether or not the feature is compatible in this environment
  56513. */
  56514. isCompatible(): boolean;
  56515. /**
  56516. * This is used to register callbacks that will automatically be removed when detach is called.
  56517. * @param observable the observable to which the observer will be attached
  56518. * @param callback the callback to register
  56519. */
  56520. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  56521. /**
  56522. * Code in this function will be executed on each xrFrame received from the browser.
  56523. * This function will not execute after the feature is detached.
  56524. * @param _xrFrame the current frame
  56525. */
  56526. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  56527. }
  56528. }
  56529. declare module BABYLON {
  56530. /**
  56531. * Renders a layer on top of an existing scene
  56532. */
  56533. export class UtilityLayerRenderer implements IDisposable {
  56534. /** the original scene that will be rendered on top of */
  56535. originalScene: Scene;
  56536. private _pointerCaptures;
  56537. private _lastPointerEvents;
  56538. private static _DefaultUtilityLayer;
  56539. private static _DefaultKeepDepthUtilityLayer;
  56540. private _sharedGizmoLight;
  56541. private _renderCamera;
  56542. /**
  56543. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  56544. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  56545. * @returns the camera that is used when rendering the utility layer
  56546. */
  56547. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  56548. /**
  56549. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  56550. * @param cam the camera that should be used when rendering the utility layer
  56551. */
  56552. setRenderCamera(cam: Nullable<Camera>): void;
  56553. /**
  56554. * @hidden
  56555. * Light which used by gizmos to get light shading
  56556. */
  56557. _getSharedGizmoLight(): HemisphericLight;
  56558. /**
  56559. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  56560. */
  56561. pickUtilitySceneFirst: boolean;
  56562. /**
  56563. * 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)
  56564. */
  56565. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  56566. /**
  56567. * 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)
  56568. */
  56569. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  56570. /**
  56571. * The scene that is rendered on top of the original scene
  56572. */
  56573. utilityLayerScene: Scene;
  56574. /**
  56575. * If the utility layer should automatically be rendered on top of existing scene
  56576. */
  56577. shouldRender: boolean;
  56578. /**
  56579. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  56580. */
  56581. onlyCheckPointerDownEvents: boolean;
  56582. /**
  56583. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  56584. */
  56585. processAllEvents: boolean;
  56586. /**
  56587. * Observable raised when the pointer move from the utility layer scene to the main scene
  56588. */
  56589. onPointerOutObservable: Observable<number>;
  56590. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  56591. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  56592. private _afterRenderObserver;
  56593. private _sceneDisposeObserver;
  56594. private _originalPointerObserver;
  56595. /**
  56596. * Instantiates a UtilityLayerRenderer
  56597. * @param originalScene the original scene that will be rendered on top of
  56598. * @param handleEvents boolean indicating if the utility layer should handle events
  56599. */
  56600. constructor(
  56601. /** the original scene that will be rendered on top of */
  56602. originalScene: Scene, handleEvents?: boolean);
  56603. private _notifyObservers;
  56604. /**
  56605. * Renders the utility layers scene on top of the original scene
  56606. */
  56607. render(): void;
  56608. /**
  56609. * Disposes of the renderer
  56610. */
  56611. dispose(): void;
  56612. private _updateCamera;
  56613. }
  56614. }
  56615. declare module BABYLON {
  56616. /**
  56617. * Options interface for the pointer selection module
  56618. */
  56619. export interface IWebXRControllerPointerSelectionOptions {
  56620. /**
  56621. * if provided, this scene will be used to render meshes.
  56622. */
  56623. customUtilityLayerScene?: Scene;
  56624. /**
  56625. * 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)
  56626. * If not disabled, the last picked point will be used to execute a pointer up event
  56627. * If disabled, pointer up event will be triggered right after the pointer down event.
  56628. * Used in screen and gaze target ray mode only
  56629. */
  56630. disablePointerUpOnTouchOut: boolean;
  56631. /**
  56632. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  56633. */
  56634. forceGazeMode: boolean;
  56635. /**
  56636. * 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
  56637. * to start a new countdown to the pointer down event.
  56638. * Defaults to 1.
  56639. */
  56640. gazeModePointerMovedFactor?: number;
  56641. /**
  56642. * Different button type to use instead of the main component
  56643. */
  56644. overrideButtonId?: string;
  56645. /**
  56646. * use this rendering group id for the meshes (optional)
  56647. */
  56648. renderingGroupId?: number;
  56649. /**
  56650. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  56651. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  56652. * 3000 means 3 seconds between pointing at something and selecting it
  56653. */
  56654. timeToSelect?: number;
  56655. /**
  56656. * Should meshes created here be added to a utility layer or the main scene
  56657. */
  56658. useUtilityLayer?: boolean;
  56659. /**
  56660. * Optional WebXR camera to be used for gaze selection
  56661. */
  56662. gazeCamera?: WebXRCamera;
  56663. /**
  56664. * the xr input to use with this pointer selection
  56665. */
  56666. xrInput: WebXRInput;
  56667. /**
  56668. * Should the scene pointerX and pointerY update be disabled
  56669. * This is required for fullscreen AR GUI, but might slow down other experiences.
  56670. * Disable in VR, if not needed.
  56671. * The first rig camera (left eye) will be used to calculate the projection
  56672. */
  56673. disableScenePointerVectorUpdate: boolean;
  56674. /**
  56675. * Enable pointer selection on all controllers instead of switching between them
  56676. */
  56677. enablePointerSelectionOnAllControllers?: boolean;
  56678. /**
  56679. * The preferred hand to give the pointer selection to. This will be prioritized when the controller initialize.
  56680. * If switch is enabled, it will still allow the user to switch between the different controllers
  56681. */
  56682. preferredHandedness?: XRHandedness;
  56683. /**
  56684. * Disable switching the pointer selection from one controller to the other.
  56685. * 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
  56686. */
  56687. disableSwitchOnClick?: boolean;
  56688. /**
  56689. * The maximum distance of the pointer selection feature. Defaults to 100.
  56690. */
  56691. maxPointerDistance?: number;
  56692. }
  56693. /**
  56694. * A module that will enable pointer selection for motion controllers of XR Input Sources
  56695. */
  56696. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  56697. private readonly _options;
  56698. private static _idCounter;
  56699. private _attachController;
  56700. private _controllers;
  56701. private _scene;
  56702. private _tmpVectorForPickCompare;
  56703. private _attachedController;
  56704. /**
  56705. * The module's name
  56706. */
  56707. static readonly Name: string;
  56708. /**
  56709. * The (Babylon) version of this module.
  56710. * This is an integer representing the implementation version.
  56711. * This number does not correspond to the WebXR specs version
  56712. */
  56713. static readonly Version: number;
  56714. /**
  56715. * Disable lighting on the laser pointer (so it will always be visible)
  56716. */
  56717. disablePointerLighting: boolean;
  56718. /**
  56719. * Disable lighting on the selection mesh (so it will always be visible)
  56720. */
  56721. disableSelectionMeshLighting: boolean;
  56722. /**
  56723. * Should the laser pointer be displayed
  56724. */
  56725. displayLaserPointer: boolean;
  56726. /**
  56727. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  56728. */
  56729. displaySelectionMesh: boolean;
  56730. /**
  56731. * This color will be set to the laser pointer when selection is triggered
  56732. */
  56733. laserPointerPickedColor: Color3;
  56734. /**
  56735. * Default color of the laser pointer
  56736. */
  56737. laserPointerDefaultColor: Color3;
  56738. /**
  56739. * default color of the selection ring
  56740. */
  56741. selectionMeshDefaultColor: Color3;
  56742. /**
  56743. * This color will be applied to the selection ring when selection is triggered
  56744. */
  56745. selectionMeshPickedColor: Color3;
  56746. /**
  56747. * Optional filter to be used for ray selection. This predicate shares behavior with
  56748. * scene.pointerMovePredicate which takes priority if it is also assigned.
  56749. */
  56750. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  56751. /**
  56752. * constructs a new background remover module
  56753. * @param _xrSessionManager the session manager for this module
  56754. * @param _options read-only options to be used in this module
  56755. */
  56756. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  56757. /**
  56758. * attach this feature
  56759. * Will usually be called by the features manager
  56760. *
  56761. * @returns true if successful.
  56762. */
  56763. attach(): boolean;
  56764. /**
  56765. * detach this feature.
  56766. * Will usually be called by the features manager
  56767. *
  56768. * @returns true if successful.
  56769. */
  56770. detach(): boolean;
  56771. /**
  56772. * Will get the mesh under a specific pointer.
  56773. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  56774. * @param controllerId the controllerId to check
  56775. * @returns The mesh under pointer or null if no mesh is under the pointer
  56776. */
  56777. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  56778. /**
  56779. * Get the xr controller that correlates to the pointer id in the pointer event
  56780. *
  56781. * @param id the pointer id to search for
  56782. * @returns the controller that correlates to this id or null if not found
  56783. */
  56784. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  56785. private _identityMatrix;
  56786. private _screenCoordinatesRef;
  56787. private _viewportRef;
  56788. protected _onXRFrame(_xrFrame: XRFrame): void;
  56789. private _attachGazeMode;
  56790. private _attachScreenRayMode;
  56791. private _attachTrackedPointerRayMode;
  56792. private _convertNormalToDirectionOfRay;
  56793. private _detachController;
  56794. private _generateNewMeshPair;
  56795. private _pickingMoved;
  56796. private _updatePointerDistance;
  56797. /** @hidden */
  56798. get lasterPointerDefaultColor(): Color3;
  56799. }
  56800. }
  56801. declare module BABYLON {
  56802. /**
  56803. * Button which can be used to enter a different mode of XR
  56804. */
  56805. export class WebXREnterExitUIButton {
  56806. /** button element */
  56807. element: HTMLElement;
  56808. /** XR initialization options for the button */
  56809. sessionMode: XRSessionMode;
  56810. /** Reference space type */
  56811. referenceSpaceType: XRReferenceSpaceType;
  56812. /**
  56813. * Creates a WebXREnterExitUIButton
  56814. * @param element button element
  56815. * @param sessionMode XR initialization session mode
  56816. * @param referenceSpaceType the type of reference space to be used
  56817. */
  56818. constructor(
  56819. /** button element */
  56820. element: HTMLElement,
  56821. /** XR initialization options for the button */
  56822. sessionMode: XRSessionMode,
  56823. /** Reference space type */
  56824. referenceSpaceType: XRReferenceSpaceType);
  56825. /**
  56826. * Extendable function which can be used to update the button's visuals when the state changes
  56827. * @param activeButton the current active button in the UI
  56828. */
  56829. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  56830. }
  56831. /**
  56832. * Options to create the webXR UI
  56833. */
  56834. export class WebXREnterExitUIOptions {
  56835. /**
  56836. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  56837. */
  56838. customButtons?: Array<WebXREnterExitUIButton>;
  56839. /**
  56840. * A reference space type to use when creating the default button.
  56841. * Default is local-floor
  56842. */
  56843. referenceSpaceType?: XRReferenceSpaceType;
  56844. /**
  56845. * Context to enter xr with
  56846. */
  56847. renderTarget?: Nullable<WebXRRenderTarget>;
  56848. /**
  56849. * A session mode to use when creating the default button.
  56850. * Default is immersive-vr
  56851. */
  56852. sessionMode?: XRSessionMode;
  56853. /**
  56854. * A list of optional features to init the session with
  56855. */
  56856. optionalFeatures?: string[];
  56857. /**
  56858. * A list of optional features to init the session with
  56859. */
  56860. requiredFeatures?: string[];
  56861. /**
  56862. * If defined, this function will be executed if the UI encounters an error when entering XR
  56863. */
  56864. onError?: (error: any) => void;
  56865. }
  56866. /**
  56867. * UI to allow the user to enter/exit XR mode
  56868. */
  56869. export class WebXREnterExitUI implements IDisposable {
  56870. private scene;
  56871. /** version of the options passed to this UI */
  56872. options: WebXREnterExitUIOptions;
  56873. private _activeButton;
  56874. private _buttons;
  56875. /**
  56876. * The HTML Div Element to which buttons are added.
  56877. */
  56878. readonly overlay: HTMLDivElement;
  56879. /**
  56880. * Fired every time the active button is changed.
  56881. *
  56882. * When xr is entered via a button that launches xr that button will be the callback parameter
  56883. *
  56884. * When exiting xr the callback parameter will be null)
  56885. */
  56886. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  56887. /**
  56888. *
  56889. * @param scene babylon scene object to use
  56890. * @param options (read-only) version of the options passed to this UI
  56891. */
  56892. private constructor();
  56893. /**
  56894. * Creates UI to allow the user to enter/exit XR mode
  56895. * @param scene the scene to add the ui to
  56896. * @param helper the xr experience helper to enter/exit xr with
  56897. * @param options options to configure the UI
  56898. * @returns the created ui
  56899. */
  56900. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  56901. /**
  56902. * Disposes of the XR UI component
  56903. */
  56904. dispose(): void;
  56905. private _updateButtons;
  56906. }
  56907. }
  56908. declare module BABYLON {
  56909. /**
  56910. * Class containing static functions to help procedurally build meshes
  56911. */
  56912. export class LinesBuilder {
  56913. /**
  56914. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  56915. * * 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
  56916. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  56917. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  56918. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  56919. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  56920. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  56921. * * 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
  56922. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  56923. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56924. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  56925. * @param name defines the name of the new line system
  56926. * @param options defines the options used to create the line system
  56927. * @param scene defines the hosting scene
  56928. * @returns a new line system mesh
  56929. */
  56930. static CreateLineSystem(name: string, options: {
  56931. lines: Vector3[][];
  56932. updatable?: boolean;
  56933. instance?: Nullable<LinesMesh>;
  56934. colors?: Nullable<Color4[][]>;
  56935. useVertexAlpha?: boolean;
  56936. }, scene: Nullable<Scene>): LinesMesh;
  56937. /**
  56938. * Creates a line mesh
  56939. * 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
  56940. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  56941. * * The parameter `points` is an array successive Vector3
  56942. * * 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
  56943. * * The optional parameter `colors` is an array of successive Color4, one per line point
  56944. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  56945. * * When updating an instance, remember that only point positions can change, not the number of points
  56946. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56947. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  56948. * @param name defines the name of the new line system
  56949. * @param options defines the options used to create the line system
  56950. * @param scene defines the hosting scene
  56951. * @returns a new line mesh
  56952. */
  56953. static CreateLines(name: string, options: {
  56954. points: Vector3[];
  56955. updatable?: boolean;
  56956. instance?: Nullable<LinesMesh>;
  56957. colors?: Color4[];
  56958. useVertexAlpha?: boolean;
  56959. }, scene?: Nullable<Scene>): LinesMesh;
  56960. /**
  56961. * Creates a dashed line mesh
  56962. * * 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
  56963. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  56964. * * The parameter `points` is an array successive Vector3
  56965. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  56966. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  56967. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  56968. * * 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
  56969. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  56970. * * When updating an instance, remember that only point positions can change, not the number of points
  56971. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56972. * @param name defines the name of the mesh
  56973. * @param options defines the options used to create the mesh
  56974. * @param scene defines the hosting scene
  56975. * @returns the dashed line mesh
  56976. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  56977. */
  56978. static CreateDashedLines(name: string, options: {
  56979. points: Vector3[];
  56980. dashSize?: number;
  56981. gapSize?: number;
  56982. dashNb?: number;
  56983. updatable?: boolean;
  56984. instance?: LinesMesh;
  56985. useVertexAlpha?: boolean;
  56986. }, scene?: Nullable<Scene>): LinesMesh;
  56987. }
  56988. }
  56989. declare module BABYLON {
  56990. /**
  56991. * Construction options for a timer
  56992. */
  56993. export interface ITimerOptions<T> {
  56994. /**
  56995. * Time-to-end
  56996. */
  56997. timeout: number;
  56998. /**
  56999. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  57000. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  57001. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  57002. */
  57003. contextObservable: Observable<T>;
  57004. /**
  57005. * Optional parameters when adding an observer to the observable
  57006. */
  57007. observableParameters?: {
  57008. mask?: number;
  57009. insertFirst?: boolean;
  57010. scope?: any;
  57011. };
  57012. /**
  57013. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  57014. */
  57015. breakCondition?: (data?: ITimerData<T>) => boolean;
  57016. /**
  57017. * Will be triggered when the time condition has met
  57018. */
  57019. onEnded?: (data: ITimerData<any>) => void;
  57020. /**
  57021. * Will be triggered when the break condition has met (prematurely ended)
  57022. */
  57023. onAborted?: (data: ITimerData<any>) => void;
  57024. /**
  57025. * Optional function to execute on each tick (or count)
  57026. */
  57027. onTick?: (data: ITimerData<any>) => void;
  57028. }
  57029. /**
  57030. * An interface defining the data sent by the timer
  57031. */
  57032. export interface ITimerData<T> {
  57033. /**
  57034. * When did it start
  57035. */
  57036. startTime: number;
  57037. /**
  57038. * Time now
  57039. */
  57040. currentTime: number;
  57041. /**
  57042. * Time passed since started
  57043. */
  57044. deltaTime: number;
  57045. /**
  57046. * How much is completed, in [0.0...1.0].
  57047. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  57048. */
  57049. completeRate: number;
  57050. /**
  57051. * What the registered observable sent in the last count
  57052. */
  57053. payload: T;
  57054. }
  57055. /**
  57056. * The current state of the timer
  57057. */
  57058. export enum TimerState {
  57059. /**
  57060. * Timer initialized, not yet started
  57061. */
  57062. INIT = 0,
  57063. /**
  57064. * Timer started and counting
  57065. */
  57066. STARTED = 1,
  57067. /**
  57068. * Timer ended (whether aborted or time reached)
  57069. */
  57070. ENDED = 2
  57071. }
  57072. /**
  57073. * A simple version of the timer. Will take options and start the timer immediately after calling it
  57074. *
  57075. * @param options options with which to initialize this timer
  57076. */
  57077. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  57078. /**
  57079. * An advanced implementation of a timer class
  57080. */
  57081. export class AdvancedTimer<T = any> implements IDisposable {
  57082. /**
  57083. * Will notify each time the timer calculates the remaining time
  57084. */
  57085. onEachCountObservable: Observable<ITimerData<T>>;
  57086. /**
  57087. * Will trigger when the timer was aborted due to the break condition
  57088. */
  57089. onTimerAbortedObservable: Observable<ITimerData<T>>;
  57090. /**
  57091. * Will trigger when the timer ended successfully
  57092. */
  57093. onTimerEndedObservable: Observable<ITimerData<T>>;
  57094. /**
  57095. * Will trigger when the timer state has changed
  57096. */
  57097. onStateChangedObservable: Observable<TimerState>;
  57098. private _observer;
  57099. private _contextObservable;
  57100. private _observableParameters;
  57101. private _startTime;
  57102. private _timer;
  57103. private _state;
  57104. private _breakCondition;
  57105. private _timeToEnd;
  57106. private _breakOnNextTick;
  57107. /**
  57108. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  57109. * @param options construction options for this advanced timer
  57110. */
  57111. constructor(options: ITimerOptions<T>);
  57112. /**
  57113. * set a breaking condition for this timer. Default is to never break during count
  57114. * @param predicate the new break condition. Returns true to break, false otherwise
  57115. */
  57116. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  57117. /**
  57118. * Reset ALL associated observables in this advanced timer
  57119. */
  57120. clearObservables(): void;
  57121. /**
  57122. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  57123. *
  57124. * @param timeToEnd how much time to measure until timer ended
  57125. */
  57126. start(timeToEnd?: number): void;
  57127. /**
  57128. * Will force a stop on the next tick.
  57129. */
  57130. stop(): void;
  57131. /**
  57132. * Dispose this timer, clearing all resources
  57133. */
  57134. dispose(): void;
  57135. private _setState;
  57136. private _tick;
  57137. private _stop;
  57138. }
  57139. }
  57140. declare module BABYLON {
  57141. /**
  57142. * The options container for the teleportation module
  57143. */
  57144. export interface IWebXRTeleportationOptions {
  57145. /**
  57146. * if provided, this scene will be used to render meshes.
  57147. */
  57148. customUtilityLayerScene?: Scene;
  57149. /**
  57150. * Values to configure the default target mesh
  57151. */
  57152. defaultTargetMeshOptions?: {
  57153. /**
  57154. * Fill color of the teleportation area
  57155. */
  57156. teleportationFillColor?: string;
  57157. /**
  57158. * Border color for the teleportation area
  57159. */
  57160. teleportationBorderColor?: string;
  57161. /**
  57162. * Disable the mesh's animation sequence
  57163. */
  57164. disableAnimation?: boolean;
  57165. /**
  57166. * Disable lighting on the material or the ring and arrow
  57167. */
  57168. disableLighting?: boolean;
  57169. /**
  57170. * Override the default material of the torus and arrow
  57171. */
  57172. torusArrowMaterial?: Material;
  57173. };
  57174. /**
  57175. * A list of meshes to use as floor meshes.
  57176. * Meshes can be added and removed after initializing the feature using the
  57177. * addFloorMesh and removeFloorMesh functions
  57178. * If empty, rotation will still work
  57179. */
  57180. floorMeshes?: AbstractMesh[];
  57181. /**
  57182. * use this rendering group id for the meshes (optional)
  57183. */
  57184. renderingGroupId?: number;
  57185. /**
  57186. * Should teleportation move only to snap points
  57187. */
  57188. snapPointsOnly?: boolean;
  57189. /**
  57190. * An array of points to which the teleportation will snap to.
  57191. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  57192. */
  57193. snapPositions?: Vector3[];
  57194. /**
  57195. * How close should the teleportation ray be in order to snap to position.
  57196. * Default to 0.8 units (meters)
  57197. */
  57198. snapToPositionRadius?: number;
  57199. /**
  57200. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  57201. * If you want to support rotation, make sure your mesh has a direction indicator.
  57202. *
  57203. * When left untouched, the default mesh will be initialized.
  57204. */
  57205. teleportationTargetMesh?: AbstractMesh;
  57206. /**
  57207. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  57208. */
  57209. timeToTeleport?: number;
  57210. /**
  57211. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  57212. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  57213. */
  57214. useMainComponentOnly?: boolean;
  57215. /**
  57216. * Should meshes created here be added to a utility layer or the main scene
  57217. */
  57218. useUtilityLayer?: boolean;
  57219. /**
  57220. * Babylon XR Input class for controller
  57221. */
  57222. xrInput: WebXRInput;
  57223. /**
  57224. * Meshes that the teleportation ray cannot go through
  57225. */
  57226. pickBlockerMeshes?: AbstractMesh[];
  57227. /**
  57228. * Should teleport work only on a specific hand?
  57229. */
  57230. forceHandedness?: XRHandedness;
  57231. /**
  57232. * If provided, this function will be used to generate the ray mesh instead of the lines mesh being used per default
  57233. */
  57234. generateRayPathMesh?: (points: Vector3[]) => AbstractMesh;
  57235. }
  57236. /**
  57237. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  57238. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  57239. * the input of the attached controllers.
  57240. */
  57241. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  57242. private _options;
  57243. private _controllers;
  57244. private _currentTeleportationControllerId;
  57245. private _floorMeshes;
  57246. private _quadraticBezierCurve;
  57247. private _selectionFeature;
  57248. private _snapToPositions;
  57249. private _snappedToPoint;
  57250. private _teleportationRingMaterial?;
  57251. private _tmpRay;
  57252. private _tmpVector;
  57253. private _tmpQuaternion;
  57254. /**
  57255. * The module's name
  57256. */
  57257. static readonly Name: string;
  57258. /**
  57259. * The (Babylon) version of this module.
  57260. * This is an integer representing the implementation version.
  57261. * This number does not correspond to the webxr specs version
  57262. */
  57263. static readonly Version: number;
  57264. /**
  57265. * Is movement backwards enabled
  57266. */
  57267. backwardsMovementEnabled: boolean;
  57268. /**
  57269. * Distance to travel when moving backwards
  57270. */
  57271. backwardsTeleportationDistance: number;
  57272. /**
  57273. * The distance from the user to the inspection point in the direction of the controller
  57274. * A higher number will allow the user to move further
  57275. * defaults to 5 (meters, in xr units)
  57276. */
  57277. parabolicCheckRadius: number;
  57278. /**
  57279. * Should the module support parabolic ray on top of direct ray
  57280. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  57281. * Very helpful when moving between floors / different heights
  57282. */
  57283. parabolicRayEnabled: boolean;
  57284. /**
  57285. * The second type of ray - straight line.
  57286. * Should it be enabled or should the parabolic line be the only one.
  57287. */
  57288. straightRayEnabled: boolean;
  57289. /**
  57290. * How much rotation should be applied when rotating right and left
  57291. */
  57292. rotationAngle: number;
  57293. private _rotationEnabled;
  57294. /**
  57295. * Is rotation enabled when moving forward?
  57296. * Disabling this feature will prevent the user from deciding the direction when teleporting
  57297. */
  57298. get rotationEnabled(): boolean;
  57299. /**
  57300. * Sets whether rotation is enabled or not
  57301. * @param enabled is rotation enabled when teleportation is shown
  57302. */
  57303. set rotationEnabled(enabled: boolean);
  57304. /**
  57305. * Exposes the currently set teleportation target mesh.
  57306. */
  57307. get teleportationTargetMesh(): Nullable<AbstractMesh>;
  57308. /**
  57309. * constructs a new anchor system
  57310. * @param _xrSessionManager an instance of WebXRSessionManager
  57311. * @param _options configuration object for this feature
  57312. */
  57313. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  57314. /**
  57315. * Get the snapPointsOnly flag
  57316. */
  57317. get snapPointsOnly(): boolean;
  57318. /**
  57319. * Sets the snapPointsOnly flag
  57320. * @param snapToPoints should teleportation be exclusively to snap points
  57321. */
  57322. set snapPointsOnly(snapToPoints: boolean);
  57323. /**
  57324. * Add a new mesh to the floor meshes array
  57325. * @param mesh the mesh to use as floor mesh
  57326. */
  57327. addFloorMesh(mesh: AbstractMesh): void;
  57328. /**
  57329. * Add a new snap-to point to fix teleportation to this position
  57330. * @param newSnapPoint The new Snap-To point
  57331. */
  57332. addSnapPoint(newSnapPoint: Vector3): void;
  57333. attach(): boolean;
  57334. detach(): boolean;
  57335. dispose(): void;
  57336. /**
  57337. * Remove a mesh from the floor meshes array
  57338. * @param mesh the mesh to remove
  57339. */
  57340. removeFloorMesh(mesh: AbstractMesh): void;
  57341. /**
  57342. * Remove a mesh from the floor meshes array using its name
  57343. * @param name the mesh name to remove
  57344. */
  57345. removeFloorMeshByName(name: string): void;
  57346. /**
  57347. * 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
  57348. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  57349. * @returns was the point found and removed or not
  57350. */
  57351. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  57352. /**
  57353. * This function sets a selection feature that will be disabled when
  57354. * the forward ray is shown and will be reattached when hidden.
  57355. * This is used to remove the selection rays when moving.
  57356. * @param selectionFeature the feature to disable when forward movement is enabled
  57357. */
  57358. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  57359. protected _onXRFrame(_xrFrame: XRFrame): void;
  57360. private _attachController;
  57361. private _createDefaultTargetMesh;
  57362. private _detachController;
  57363. private _findClosestSnapPointWithRadius;
  57364. private _setTargetMeshPosition;
  57365. private _setTargetMeshVisibility;
  57366. private _showParabolicPath;
  57367. private _teleportForward;
  57368. }
  57369. }
  57370. declare module BABYLON {
  57371. /**
  57372. * Options for the default xr helper
  57373. */
  57374. export class WebXRDefaultExperienceOptions {
  57375. /**
  57376. * Enable or disable default UI to enter XR
  57377. */
  57378. disableDefaultUI?: boolean;
  57379. /**
  57380. * Should pointer selection not initialize.
  57381. * Note that disabling pointer selection also disables teleportation.
  57382. * Defaults to false.
  57383. */
  57384. disablePointerSelection?: boolean;
  57385. /**
  57386. * Should teleportation not initialize. Defaults to false.
  57387. */
  57388. disableTeleportation?: boolean;
  57389. /**
  57390. * Floor meshes that will be used for teleport
  57391. */
  57392. floorMeshes?: Array<AbstractMesh>;
  57393. /**
  57394. * If set to true, the first frame will not be used to reset position
  57395. * The first frame is mainly used when copying transformation from the old camera
  57396. * Mainly used in AR
  57397. */
  57398. ignoreNativeCameraTransformation?: boolean;
  57399. /**
  57400. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  57401. */
  57402. inputOptions?: IWebXRInputOptions;
  57403. /**
  57404. * optional configuration for the output canvas
  57405. */
  57406. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  57407. /**
  57408. * optional UI options. This can be used among other to change session mode and reference space type
  57409. */
  57410. uiOptions?: WebXREnterExitUIOptions;
  57411. /**
  57412. * When loading teleportation and pointer select, use stable versions instead of latest.
  57413. */
  57414. useStablePlugins?: boolean;
  57415. /**
  57416. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  57417. */
  57418. renderingGroupId?: number;
  57419. /**
  57420. * A list of optional features to init the session with
  57421. * If set to true, all features we support will be added
  57422. */
  57423. optionalFeatures?: boolean | string[];
  57424. }
  57425. /**
  57426. * Default experience which provides a similar setup to the previous webVRExperience
  57427. */
  57428. export class WebXRDefaultExperience {
  57429. /**
  57430. * Base experience
  57431. */
  57432. baseExperience: WebXRExperienceHelper;
  57433. /**
  57434. * Enables ui for entering/exiting xr
  57435. */
  57436. enterExitUI: WebXREnterExitUI;
  57437. /**
  57438. * Input experience extension
  57439. */
  57440. input: WebXRInput;
  57441. /**
  57442. * Enables laser pointer and selection
  57443. */
  57444. pointerSelection: WebXRControllerPointerSelection;
  57445. /**
  57446. * Default target xr should render to
  57447. */
  57448. renderTarget: WebXRRenderTarget;
  57449. /**
  57450. * Enables teleportation
  57451. */
  57452. teleportation: WebXRMotionControllerTeleportation;
  57453. private constructor();
  57454. /**
  57455. * Creates the default xr experience
  57456. * @param scene scene
  57457. * @param options options for basic configuration
  57458. * @returns resulting WebXRDefaultExperience
  57459. */
  57460. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  57461. /**
  57462. * Disposes of the experience helper
  57463. */
  57464. dispose(): void;
  57465. }
  57466. }
  57467. declare module BABYLON {
  57468. /**
  57469. * Options to modify the vr teleportation behavior.
  57470. */
  57471. export interface VRTeleportationOptions {
  57472. /**
  57473. * The name of the mesh which should be used as the teleportation floor. (default: null)
  57474. */
  57475. floorMeshName?: string;
  57476. /**
  57477. * A list of meshes to be used as the teleportation floor. (default: empty)
  57478. */
  57479. floorMeshes?: Mesh[];
  57480. /**
  57481. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  57482. */
  57483. teleportationMode?: number;
  57484. /**
  57485. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  57486. */
  57487. teleportationTime?: number;
  57488. /**
  57489. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  57490. */
  57491. teleportationSpeed?: number;
  57492. /**
  57493. * The easing function used in the animation or null for Linear. (default CircleEase)
  57494. */
  57495. easingFunction?: EasingFunction;
  57496. }
  57497. /**
  57498. * Options to modify the vr experience helper's behavior.
  57499. */
  57500. export interface VRExperienceHelperOptions extends WebVROptions {
  57501. /**
  57502. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  57503. */
  57504. createDeviceOrientationCamera?: boolean;
  57505. /**
  57506. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  57507. */
  57508. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  57509. /**
  57510. * Uses the main button on the controller to toggle the laser casted. (default: true)
  57511. */
  57512. laserToggle?: boolean;
  57513. /**
  57514. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  57515. */
  57516. floorMeshes?: Mesh[];
  57517. /**
  57518. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  57519. */
  57520. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  57521. /**
  57522. * Defines if WebXR should be used instead of WebVR (if available)
  57523. */
  57524. useXR?: boolean;
  57525. }
  57526. /**
  57527. * Event containing information after VR has been entered
  57528. */
  57529. export class OnAfterEnteringVRObservableEvent {
  57530. /**
  57531. * If entering vr was successful
  57532. */
  57533. success: boolean;
  57534. }
  57535. /**
  57536. * Helps to quickly add VR support to an existing scene.
  57537. * See https://doc.babylonjs.com/how_to/webvr_helper
  57538. */
  57539. export class VRExperienceHelper {
  57540. /** Options to modify the vr experience helper's behavior. */
  57541. webVROptions: VRExperienceHelperOptions;
  57542. private _scene;
  57543. private _position;
  57544. private _btnVR;
  57545. private _btnVRDisplayed;
  57546. private _webVRsupported;
  57547. private _webVRready;
  57548. private _webVRrequesting;
  57549. private _webVRpresenting;
  57550. private _hasEnteredVR;
  57551. private _fullscreenVRpresenting;
  57552. private _inputElement;
  57553. private _webVRCamera;
  57554. private _vrDeviceOrientationCamera;
  57555. private _deviceOrientationCamera;
  57556. private _existingCamera;
  57557. private _onKeyDown;
  57558. private _onVrDisplayPresentChange;
  57559. private _onVRDisplayChanged;
  57560. private _onVRRequestPresentStart;
  57561. private _onVRRequestPresentComplete;
  57562. /**
  57563. * 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)
  57564. */
  57565. enableGazeEvenWhenNoPointerLock: boolean;
  57566. /**
  57567. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  57568. */
  57569. exitVROnDoubleTap: boolean;
  57570. /**
  57571. * Observable raised right before entering VR.
  57572. */
  57573. onEnteringVRObservable: Observable<VRExperienceHelper>;
  57574. /**
  57575. * Observable raised when entering VR has completed.
  57576. */
  57577. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  57578. /**
  57579. * Observable raised when exiting VR.
  57580. */
  57581. onExitingVRObservable: Observable<VRExperienceHelper>;
  57582. /**
  57583. * Observable raised when controller mesh is loaded.
  57584. */
  57585. onControllerMeshLoadedObservable: Observable<WebVRController>;
  57586. /** Return this.onEnteringVRObservable
  57587. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  57588. */
  57589. get onEnteringVR(): Observable<VRExperienceHelper>;
  57590. /** Return this.onExitingVRObservable
  57591. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  57592. */
  57593. get onExitingVR(): Observable<VRExperienceHelper>;
  57594. /** Return this.onControllerMeshLoadedObservable
  57595. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  57596. */
  57597. get onControllerMeshLoaded(): Observable<WebVRController>;
  57598. private _rayLength;
  57599. private _useCustomVRButton;
  57600. private _teleportationRequested;
  57601. private _teleportActive;
  57602. private _floorMeshName;
  57603. private _floorMeshesCollection;
  57604. private _teleportationMode;
  57605. private _teleportationTime;
  57606. private _teleportationSpeed;
  57607. private _teleportationEasing;
  57608. private _rotationAllowed;
  57609. private _teleportBackwardsVector;
  57610. private _teleportationTarget;
  57611. private _isDefaultTeleportationTarget;
  57612. private _postProcessMove;
  57613. private _teleportationFillColor;
  57614. private _teleportationBorderColor;
  57615. private _rotationAngle;
  57616. private _haloCenter;
  57617. private _cameraGazer;
  57618. private _padSensibilityUp;
  57619. private _padSensibilityDown;
  57620. private _leftController;
  57621. private _rightController;
  57622. private _gazeColor;
  57623. private _laserColor;
  57624. private _pickedLaserColor;
  57625. private _pickedGazeColor;
  57626. /**
  57627. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  57628. */
  57629. onNewMeshSelected: Observable<AbstractMesh>;
  57630. /**
  57631. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  57632. * This observable will provide the mesh and the controller used to select the mesh
  57633. */
  57634. onMeshSelectedWithController: Observable<{
  57635. mesh: AbstractMesh;
  57636. controller: WebVRController;
  57637. }>;
  57638. /**
  57639. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  57640. */
  57641. onNewMeshPicked: Observable<PickingInfo>;
  57642. private _circleEase;
  57643. /**
  57644. * Observable raised before camera teleportation
  57645. */
  57646. onBeforeCameraTeleport: Observable<Vector3>;
  57647. /**
  57648. * Observable raised after camera teleportation
  57649. */
  57650. onAfterCameraTeleport: Observable<Vector3>;
  57651. /**
  57652. * Observable raised when current selected mesh gets unselected
  57653. */
  57654. onSelectedMeshUnselected: Observable<AbstractMesh>;
  57655. private _raySelectionPredicate;
  57656. /**
  57657. * To be optionally changed by user to define custom ray selection
  57658. */
  57659. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  57660. /**
  57661. * To be optionally changed by user to define custom selection logic (after ray selection)
  57662. */
  57663. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  57664. /**
  57665. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  57666. */
  57667. teleportationEnabled: boolean;
  57668. private _defaultHeight;
  57669. private _teleportationInitialized;
  57670. private _interactionsEnabled;
  57671. private _interactionsRequested;
  57672. private _displayGaze;
  57673. private _displayLaserPointer;
  57674. /**
  57675. * The mesh used to display where the user is going to teleport.
  57676. */
  57677. get teleportationTarget(): Mesh;
  57678. /**
  57679. * Sets the mesh to be used to display where the user is going to teleport.
  57680. */
  57681. set teleportationTarget(value: Mesh);
  57682. /**
  57683. * 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
  57684. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  57685. * See https://doc.babylonjs.com/resources/baking_transformations
  57686. */
  57687. get gazeTrackerMesh(): Mesh;
  57688. set gazeTrackerMesh(value: Mesh);
  57689. /**
  57690. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  57691. */
  57692. updateGazeTrackerScale: boolean;
  57693. /**
  57694. * If the gaze trackers color should be updated when selecting meshes
  57695. */
  57696. updateGazeTrackerColor: boolean;
  57697. /**
  57698. * If the controller laser color should be updated when selecting meshes
  57699. */
  57700. updateControllerLaserColor: boolean;
  57701. /**
  57702. * The gaze tracking mesh corresponding to the left controller
  57703. */
  57704. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  57705. /**
  57706. * The gaze tracking mesh corresponding to the right controller
  57707. */
  57708. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  57709. /**
  57710. * If the ray of the gaze should be displayed.
  57711. */
  57712. get displayGaze(): boolean;
  57713. /**
  57714. * Sets if the ray of the gaze should be displayed.
  57715. */
  57716. set displayGaze(value: boolean);
  57717. /**
  57718. * If the ray of the LaserPointer should be displayed.
  57719. */
  57720. get displayLaserPointer(): boolean;
  57721. /**
  57722. * Sets if the ray of the LaserPointer should be displayed.
  57723. */
  57724. set displayLaserPointer(value: boolean);
  57725. /**
  57726. * The deviceOrientationCamera used as the camera when not in VR.
  57727. */
  57728. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  57729. /**
  57730. * Based on the current WebVR support, returns the current VR camera used.
  57731. */
  57732. get currentVRCamera(): Nullable<Camera>;
  57733. /**
  57734. * The webVRCamera which is used when in VR.
  57735. */
  57736. get webVRCamera(): WebVRFreeCamera;
  57737. /**
  57738. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  57739. */
  57740. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  57741. /**
  57742. * The html button that is used to trigger entering into VR.
  57743. */
  57744. get vrButton(): Nullable<HTMLButtonElement>;
  57745. private get _teleportationRequestInitiated();
  57746. /**
  57747. * Defines whether or not Pointer lock should be requested when switching to
  57748. * full screen.
  57749. */
  57750. requestPointerLockOnFullScreen: boolean;
  57751. /**
  57752. * If asking to force XR, this will be populated with the default xr experience
  57753. */
  57754. xr: WebXRDefaultExperience;
  57755. /**
  57756. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  57757. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  57758. */
  57759. xrTestDone: boolean;
  57760. /**
  57761. * Instantiates a VRExperienceHelper.
  57762. * Helps to quickly add VR support to an existing scene.
  57763. * @param scene The scene the VRExperienceHelper belongs to.
  57764. * @param webVROptions Options to modify the vr experience helper's behavior.
  57765. */
  57766. constructor(scene: Scene,
  57767. /** Options to modify the vr experience helper's behavior. */
  57768. webVROptions?: VRExperienceHelperOptions);
  57769. private completeVRInit;
  57770. private _onDefaultMeshLoaded;
  57771. private _onResize;
  57772. private _onFullscreenChange;
  57773. /**
  57774. * Gets a value indicating if we are currently in VR mode.
  57775. */
  57776. get isInVRMode(): boolean;
  57777. private onVrDisplayPresentChange;
  57778. private onVRDisplayChanged;
  57779. private moveButtonToBottomRight;
  57780. private displayVRButton;
  57781. private updateButtonVisibility;
  57782. private _cachedAngularSensibility;
  57783. /**
  57784. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  57785. * Otherwise, will use the fullscreen API.
  57786. */
  57787. enterVR(): void;
  57788. /**
  57789. * Attempt to exit VR, or fullscreen.
  57790. */
  57791. exitVR(): void;
  57792. /**
  57793. * The position of the vr experience helper.
  57794. */
  57795. get position(): Vector3;
  57796. /**
  57797. * Sets the position of the vr experience helper.
  57798. */
  57799. set position(value: Vector3);
  57800. /**
  57801. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  57802. */
  57803. enableInteractions(): void;
  57804. private get _noControllerIsActive();
  57805. private beforeRender;
  57806. private _isTeleportationFloor;
  57807. /**
  57808. * Adds a floor mesh to be used for teleportation.
  57809. * @param floorMesh the mesh to be used for teleportation.
  57810. */
  57811. addFloorMesh(floorMesh: Mesh): void;
  57812. /**
  57813. * Removes a floor mesh from being used for teleportation.
  57814. * @param floorMesh the mesh to be removed.
  57815. */
  57816. removeFloorMesh(floorMesh: Mesh): void;
  57817. /**
  57818. * Enables interactions and teleportation using the VR controllers and gaze.
  57819. * @param vrTeleportationOptions options to modify teleportation behavior.
  57820. */
  57821. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  57822. private _onNewGamepadConnected;
  57823. private _tryEnableInteractionOnController;
  57824. private _onNewGamepadDisconnected;
  57825. private _enableInteractionOnController;
  57826. private _checkTeleportWithRay;
  57827. private _checkRotate;
  57828. private _checkTeleportBackwards;
  57829. private _enableTeleportationOnController;
  57830. private _createTeleportationCircles;
  57831. private _displayTeleportationTarget;
  57832. private _hideTeleportationTarget;
  57833. private _rotateCamera;
  57834. private _moveTeleportationSelectorTo;
  57835. private _workingVector;
  57836. private _workingQuaternion;
  57837. private _workingMatrix;
  57838. /**
  57839. * Time Constant Teleportation Mode
  57840. */
  57841. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  57842. /**
  57843. * Speed Constant Teleportation Mode
  57844. */
  57845. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  57846. /**
  57847. * Teleports the users feet to the desired location
  57848. * @param location The location where the user's feet should be placed
  57849. */
  57850. teleportCamera(location: Vector3): void;
  57851. private _convertNormalToDirectionOfRay;
  57852. private _castRayAndSelectObject;
  57853. private _notifySelectedMeshUnselected;
  57854. /**
  57855. * Permanently set new colors for the laser pointer
  57856. * @param color the new laser color
  57857. * @param pickedColor the new laser color when picked mesh detected
  57858. */
  57859. setLaserColor(color: Color3, pickedColor?: Color3): void;
  57860. /**
  57861. * Set lighting enabled / disabled on the laser pointer of both controllers
  57862. * @param enabled should the lighting be enabled on the laser pointer
  57863. */
  57864. setLaserLightingState(enabled?: boolean): void;
  57865. /**
  57866. * Permanently set new colors for the gaze pointer
  57867. * @param color the new gaze color
  57868. * @param pickedColor the new gaze color when picked mesh detected
  57869. */
  57870. setGazeColor(color: Color3, pickedColor?: Color3): void;
  57871. /**
  57872. * Sets the color of the laser ray from the vr controllers.
  57873. * @param color new color for the ray.
  57874. */
  57875. changeLaserColor(color: Color3): void;
  57876. /**
  57877. * Sets the color of the ray from the vr headsets gaze.
  57878. * @param color new color for the ray.
  57879. */
  57880. changeGazeColor(color: Color3): void;
  57881. /**
  57882. * Exits VR and disposes of the vr experience helper
  57883. */
  57884. dispose(): void;
  57885. /**
  57886. * Gets the name of the VRExperienceHelper class
  57887. * @returns "VRExperienceHelper"
  57888. */
  57889. getClassName(): string;
  57890. }
  57891. }
  57892. declare module BABYLON {
  57893. /**
  57894. * Contains an array of blocks representing the octree
  57895. */
  57896. export interface IOctreeContainer<T> {
  57897. /**
  57898. * Blocks within the octree
  57899. */
  57900. blocks: Array<OctreeBlock<T>>;
  57901. }
  57902. /**
  57903. * Class used to store a cell in an octree
  57904. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  57905. */
  57906. export class OctreeBlock<T> {
  57907. /**
  57908. * Gets the content of the current block
  57909. */
  57910. entries: T[];
  57911. /**
  57912. * Gets the list of block children
  57913. */
  57914. blocks: Array<OctreeBlock<T>>;
  57915. private _depth;
  57916. private _maxDepth;
  57917. private _capacity;
  57918. private _minPoint;
  57919. private _maxPoint;
  57920. private _boundingVectors;
  57921. private _creationFunc;
  57922. /**
  57923. * Creates a new block
  57924. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  57925. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  57926. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  57927. * @param depth defines the current depth of this block in the octree
  57928. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  57929. * @param creationFunc defines a callback to call when an element is added to the block
  57930. */
  57931. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  57932. /**
  57933. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  57934. */
  57935. get capacity(): number;
  57936. /**
  57937. * Gets the minimum vector (in world space) of the block's bounding box
  57938. */
  57939. get minPoint(): Vector3;
  57940. /**
  57941. * Gets the maximum vector (in world space) of the block's bounding box
  57942. */
  57943. get maxPoint(): Vector3;
  57944. /**
  57945. * Add a new element to this block
  57946. * @param entry defines the element to add
  57947. */
  57948. addEntry(entry: T): void;
  57949. /**
  57950. * Remove an element from this block
  57951. * @param entry defines the element to remove
  57952. */
  57953. removeEntry(entry: T): void;
  57954. /**
  57955. * Add an array of elements to this block
  57956. * @param entries defines the array of elements to add
  57957. */
  57958. addEntries(entries: T[]): void;
  57959. /**
  57960. * Test if the current block intersects the frustum planes and if yes, then add its content to the selection array
  57961. * @param frustumPlanes defines the frustum planes to test
  57962. * @param selection defines the array to store current content if selection is positive
  57963. * @param allowDuplicate defines if the selection array can contains duplicated entries
  57964. */
  57965. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  57966. /**
  57967. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  57968. * @param sphereCenter defines the bounding sphere center
  57969. * @param sphereRadius defines the bounding sphere radius
  57970. * @param selection defines the array to store current content if selection is positive
  57971. * @param allowDuplicate defines if the selection array can contains duplicated entries
  57972. */
  57973. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  57974. /**
  57975. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  57976. * @param ray defines the ray to test with
  57977. * @param selection defines the array to store current content if selection is positive
  57978. */
  57979. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  57980. /**
  57981. * Subdivide the content into child blocks (this block will then be empty)
  57982. */
  57983. createInnerBlocks(): void;
  57984. /**
  57985. * @hidden
  57986. */
  57987. 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;
  57988. }
  57989. }
  57990. declare module BABYLON {
  57991. /**
  57992. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  57993. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  57994. */
  57995. export class Octree<T> {
  57996. /** 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.) */
  57997. maxDepth: number;
  57998. /**
  57999. * Blocks within the octree containing objects
  58000. */
  58001. blocks: Array<OctreeBlock<T>>;
  58002. /**
  58003. * Content stored in the octree
  58004. */
  58005. dynamicContent: T[];
  58006. private _maxBlockCapacity;
  58007. private _selectionContent;
  58008. private _creationFunc;
  58009. /**
  58010. * Creates a octree
  58011. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  58012. * @param creationFunc function to be used to instantiate the octree
  58013. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  58014. * @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.)
  58015. */
  58016. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  58017. /** 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.) */
  58018. maxDepth?: number);
  58019. /**
  58020. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  58021. * @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);
  58022. * @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);
  58023. * @param entries meshes to be added to the octree blocks
  58024. */
  58025. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  58026. /**
  58027. * Adds a mesh to the octree
  58028. * @param entry Mesh to add to the octree
  58029. */
  58030. addMesh(entry: T): void;
  58031. /**
  58032. * Remove an element from the octree
  58033. * @param entry defines the element to remove
  58034. */
  58035. removeMesh(entry: T): void;
  58036. /**
  58037. * Selects an array of meshes within the frustum
  58038. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  58039. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  58040. * @returns array of meshes within the frustum
  58041. */
  58042. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  58043. /**
  58044. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  58045. * @param sphereCenter defines the bounding sphere center
  58046. * @param sphereRadius defines the bounding sphere radius
  58047. * @param allowDuplicate defines if the selection array can contains duplicated entries
  58048. * @returns an array of objects that intersect the sphere
  58049. */
  58050. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  58051. /**
  58052. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  58053. * @param ray defines the ray to test with
  58054. * @returns array of intersected objects
  58055. */
  58056. intersectsRay(ray: Ray): SmartArray<T>;
  58057. /**
  58058. * Adds a mesh into the octree block if it intersects the block
  58059. */
  58060. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  58061. /**
  58062. * Adds a submesh into the octree block if it intersects the block
  58063. */
  58064. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  58065. }
  58066. }
  58067. declare module BABYLON {
  58068. interface Scene {
  58069. /**
  58070. * @hidden
  58071. * Backing Filed
  58072. */
  58073. _selectionOctree: Octree<AbstractMesh>;
  58074. /**
  58075. * Gets the octree used to boost mesh selection (picking)
  58076. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  58077. */
  58078. selectionOctree: Octree<AbstractMesh>;
  58079. /**
  58080. * Creates or updates the octree used to boost selection (picking)
  58081. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  58082. * @param maxCapacity defines the maximum capacity per leaf
  58083. * @param maxDepth defines the maximum depth of the octree
  58084. * @returns an octree of AbstractMesh
  58085. */
  58086. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  58087. }
  58088. interface AbstractMesh {
  58089. /**
  58090. * @hidden
  58091. * Backing Field
  58092. */
  58093. _submeshesOctree: Octree<SubMesh>;
  58094. /**
  58095. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  58096. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  58097. * @param maxCapacity defines the maximum size of each block (64 by default)
  58098. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  58099. * @returns the new octree
  58100. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  58101. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  58102. */
  58103. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  58104. }
  58105. /**
  58106. * Defines the octree scene component responsible to manage any octrees
  58107. * in a given scene.
  58108. */
  58109. export class OctreeSceneComponent {
  58110. /**
  58111. * The component name help to identify the component in the list of scene components.
  58112. */
  58113. readonly name: string;
  58114. /**
  58115. * The scene the component belongs to.
  58116. */
  58117. scene: Scene;
  58118. /**
  58119. * Indicates if the meshes have been checked to make sure they are isEnabled()
  58120. */
  58121. readonly checksIsEnabled: boolean;
  58122. /**
  58123. * Creates a new instance of the component for the given scene
  58124. * @param scene Defines the scene to register the component in
  58125. */
  58126. constructor(scene: Scene);
  58127. /**
  58128. * Registers the component in a given scene
  58129. */
  58130. register(): void;
  58131. /**
  58132. * Return the list of active meshes
  58133. * @returns the list of active meshes
  58134. */
  58135. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  58136. /**
  58137. * Return the list of active sub meshes
  58138. * @param mesh The mesh to get the candidates sub meshes from
  58139. * @returns the list of active sub meshes
  58140. */
  58141. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  58142. private _tempRay;
  58143. /**
  58144. * Return the list of sub meshes intersecting with a given local ray
  58145. * @param mesh defines the mesh to find the submesh for
  58146. * @param localRay defines the ray in local space
  58147. * @returns the list of intersecting sub meshes
  58148. */
  58149. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  58150. /**
  58151. * Return the list of sub meshes colliding with a collider
  58152. * @param mesh defines the mesh to find the submesh for
  58153. * @param collider defines the collider to evaluate the collision against
  58154. * @returns the list of colliding sub meshes
  58155. */
  58156. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  58157. /**
  58158. * Rebuilds the elements related to this component in case of
  58159. * context lost for instance.
  58160. */
  58161. rebuild(): void;
  58162. /**
  58163. * Disposes the component and the associated resources.
  58164. */
  58165. dispose(): void;
  58166. }
  58167. }
  58168. declare module BABYLON {
  58169. /**
  58170. * Cache built by each axis. Used for managing state between all elements of gizmo for enhanced UI
  58171. */
  58172. export interface GizmoAxisCache {
  58173. /** Mesh used to render the Gizmo */
  58174. gizmoMeshes: Mesh[];
  58175. /** Mesh used to detect user interaction with Gizmo */
  58176. colliderMeshes: Mesh[];
  58177. /** Material used to indicate color of gizmo mesh */
  58178. material: StandardMaterial;
  58179. /** Material used to indicate hover state of the Gizmo */
  58180. hoverMaterial: StandardMaterial;
  58181. /** Material used to indicate disabled state of the Gizmo */
  58182. disableMaterial: StandardMaterial;
  58183. /** Used to indicate Active state of the Gizmo */
  58184. active: boolean;
  58185. }
  58186. /**
  58187. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  58188. */
  58189. export class Gizmo implements IDisposable {
  58190. /** The utility layer the gizmo will be added to */
  58191. gizmoLayer: UtilityLayerRenderer;
  58192. /**
  58193. * The root mesh of the gizmo
  58194. */
  58195. _rootMesh: Mesh;
  58196. private _attachedMesh;
  58197. private _attachedNode;
  58198. /**
  58199. * Ratio for the scale of the gizmo (Default: 1)
  58200. */
  58201. protected _scaleRatio: number;
  58202. /**
  58203. * boolean updated by pointermove when a gizmo mesh is hovered
  58204. */
  58205. protected _isHovered: boolean;
  58206. /**
  58207. * Ratio for the scale of the gizmo (Default: 1)
  58208. */
  58209. set scaleRatio(value: number);
  58210. get scaleRatio(): number;
  58211. /**
  58212. * True when the mouse pointer is hovered a gizmo mesh
  58213. */
  58214. get isHovered(): boolean;
  58215. /**
  58216. * If a custom mesh has been set (Default: false)
  58217. */
  58218. protected _customMeshSet: boolean;
  58219. /**
  58220. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  58221. * * When set, interactions will be enabled
  58222. */
  58223. get attachedMesh(): Nullable<AbstractMesh>;
  58224. set attachedMesh(value: Nullable<AbstractMesh>);
  58225. /**
  58226. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  58227. * * When set, interactions will be enabled
  58228. */
  58229. get attachedNode(): Nullable<Node>;
  58230. set attachedNode(value: Nullable<Node>);
  58231. /**
  58232. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  58233. * @param mesh The mesh to replace the default mesh of the gizmo
  58234. */
  58235. setCustomMesh(mesh: Mesh): void;
  58236. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  58237. /**
  58238. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  58239. */
  58240. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  58241. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  58242. /**
  58243. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  58244. */
  58245. updateGizmoPositionToMatchAttachedMesh: boolean;
  58246. /**
  58247. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  58248. */
  58249. updateScale: boolean;
  58250. protected _interactionsEnabled: boolean;
  58251. protected _attachedNodeChanged(value: Nullable<Node>): void;
  58252. private _beforeRenderObserver;
  58253. private _tempQuaternion;
  58254. private _tempVector;
  58255. private _tempVector2;
  58256. private _tempMatrix1;
  58257. private _tempMatrix2;
  58258. private _rightHandtoLeftHandMatrix;
  58259. /**
  58260. * Creates a gizmo
  58261. * @param gizmoLayer The utility layer the gizmo will be added to
  58262. */
  58263. constructor(
  58264. /** The utility layer the gizmo will be added to */
  58265. gizmoLayer?: UtilityLayerRenderer);
  58266. /**
  58267. * Updates the gizmo to match the attached mesh's position/rotation
  58268. */
  58269. protected _update(): void;
  58270. /**
  58271. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  58272. * @param value Node, TransformNode or mesh
  58273. */
  58274. protected _matrixChanged(): void;
  58275. /**
  58276. * Subscribes to pointer up, down, and hover events. Used for responsive gizmos.
  58277. * @param gizmoLayer The utility layer the gizmo will be added to
  58278. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  58279. * @returns {Observer<PointerInfo>} pointerObserver
  58280. */
  58281. static GizmoAxisPointerObserver(gizmoLayer: UtilityLayerRenderer, gizmoAxisCache: Map<Mesh, GizmoAxisCache>): Observer<PointerInfo>;
  58282. /**
  58283. * Disposes of the gizmo
  58284. */
  58285. dispose(): void;
  58286. }
  58287. }
  58288. declare module BABYLON {
  58289. /**
  58290. * Single plane drag gizmo
  58291. */
  58292. export class PlaneDragGizmo extends Gizmo {
  58293. /**
  58294. * Drag behavior responsible for the gizmos dragging interactions
  58295. */
  58296. dragBehavior: PointerDragBehavior;
  58297. private _pointerObserver;
  58298. /**
  58299. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  58300. */
  58301. snapDistance: number;
  58302. /**
  58303. * Event that fires each time the gizmo snaps to a new location.
  58304. * * snapDistance is the the change in distance
  58305. */
  58306. onSnapObservable: Observable<{
  58307. snapDistance: number;
  58308. }>;
  58309. private _gizmoMesh;
  58310. private _coloredMaterial;
  58311. private _hoverMaterial;
  58312. private _disableMaterial;
  58313. private _isEnabled;
  58314. private _parent;
  58315. private _dragging;
  58316. /** @hidden */
  58317. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  58318. /**
  58319. * Creates a PlaneDragGizmo
  58320. * @param gizmoLayer The utility layer the gizmo will be added to
  58321. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  58322. * @param color The color of the gizmo
  58323. */
  58324. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  58325. protected _attachedNodeChanged(value: Nullable<Node>): void;
  58326. /**
  58327. * If the gizmo is enabled
  58328. */
  58329. set isEnabled(value: boolean);
  58330. get isEnabled(): boolean;
  58331. /**
  58332. * Disposes of the gizmo
  58333. */
  58334. dispose(): void;
  58335. }
  58336. }
  58337. declare module BABYLON {
  58338. /**
  58339. * Single plane rotation gizmo
  58340. */
  58341. export class PlaneRotationGizmo extends Gizmo {
  58342. /**
  58343. * Drag behavior responsible for the gizmos dragging interactions
  58344. */
  58345. dragBehavior: PointerDragBehavior;
  58346. private _pointerObserver;
  58347. /**
  58348. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  58349. */
  58350. snapDistance: number;
  58351. /**
  58352. * Event that fires each time the gizmo snaps to a new location.
  58353. * * snapDistance is the the change in distance
  58354. */
  58355. onSnapObservable: Observable<{
  58356. snapDistance: number;
  58357. }>;
  58358. private _isEnabled;
  58359. private _parent;
  58360. private _coloredMaterial;
  58361. private _hoverMaterial;
  58362. private _disableMaterial;
  58363. private _gizmoMesh;
  58364. private _rotationCircle;
  58365. private _dragging;
  58366. private static _CircleConstants;
  58367. /**
  58368. * Creates a PlaneRotationGizmo
  58369. * @param gizmoLayer The utility layer the gizmo will be added to
  58370. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  58371. * @param color The color of the gizmo
  58372. * @param tessellation Amount of tessellation to be used when creating rotation circles
  58373. * @param useEulerRotation Use and update Euler angle instead of quaternion
  58374. * @param thickness display gizmo axis thickness
  58375. */
  58376. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  58377. /** Create Geometry for Gizmo */
  58378. private _createGizmoMesh;
  58379. protected _attachedNodeChanged(value: Nullable<Node>): void;
  58380. private setupRotationCircle;
  58381. private updateRotationPath;
  58382. private updateRotationCircle;
  58383. /**
  58384. * If the gizmo is enabled
  58385. */
  58386. set isEnabled(value: boolean);
  58387. get isEnabled(): boolean;
  58388. /**
  58389. * Disposes of the gizmo
  58390. */
  58391. dispose(): void;
  58392. }
  58393. }
  58394. declare module BABYLON {
  58395. /**
  58396. * Gizmo that enables rotating a mesh along 3 axis
  58397. */
  58398. export class RotationGizmo extends Gizmo {
  58399. /**
  58400. * Internal gizmo used for interactions on the x axis
  58401. */
  58402. xGizmo: PlaneRotationGizmo;
  58403. /**
  58404. * Internal gizmo used for interactions on the y axis
  58405. */
  58406. yGizmo: PlaneRotationGizmo;
  58407. /**
  58408. * Internal gizmo used for interactions on the z axis
  58409. */
  58410. zGizmo: PlaneRotationGizmo;
  58411. /** Fires an event when any of it's sub gizmos are dragged */
  58412. onDragStartObservable: Observable<unknown>;
  58413. /** Fires an event when any of it's sub gizmos are released from dragging */
  58414. onDragEndObservable: Observable<unknown>;
  58415. private _meshAttached;
  58416. private _nodeAttached;
  58417. private _observables;
  58418. /** Node Caching for quick lookup */
  58419. private _gizmoAxisCache;
  58420. get attachedMesh(): Nullable<AbstractMesh>;
  58421. set attachedMesh(mesh: Nullable<AbstractMesh>);
  58422. get attachedNode(): Nullable<Node>;
  58423. set attachedNode(node: Nullable<Node>);
  58424. protected _checkBillboardTransform(): void;
  58425. /**
  58426. * True when the mouse pointer is hovering a gizmo mesh
  58427. */
  58428. get isHovered(): boolean;
  58429. /**
  58430. * Creates a RotationGizmo
  58431. * @param gizmoLayer The utility layer the gizmo will be added to
  58432. * @param tessellation Amount of tessellation to be used when creating rotation circles
  58433. * @param useEulerRotation Use and update Euler angle instead of quaternion
  58434. * @param thickness display gizmo axis thickness
  58435. */
  58436. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number, gizmoManager?: GizmoManager);
  58437. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  58438. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  58439. /**
  58440. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  58441. */
  58442. set snapDistance(value: number);
  58443. get snapDistance(): number;
  58444. /**
  58445. * Ratio for the scale of the gizmo (Default: 1)
  58446. */
  58447. set scaleRatio(value: number);
  58448. get scaleRatio(): number;
  58449. /**
  58450. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  58451. * @param mesh Axis gizmo mesh
  58452. * @param cache Gizmo axis definition used for reactive gizmo UI
  58453. */
  58454. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  58455. /**
  58456. * Disposes of the gizmo
  58457. */
  58458. dispose(): void;
  58459. /**
  58460. * CustomMeshes are not supported by this gizmo
  58461. * @param mesh The mesh to replace the default mesh of the gizmo
  58462. */
  58463. setCustomMesh(mesh: Mesh): void;
  58464. }
  58465. }
  58466. declare module BABYLON {
  58467. /**
  58468. * Class containing static functions to help procedurally build meshes
  58469. */
  58470. export class PolyhedronBuilder {
  58471. /**
  58472. * Creates a polyhedron mesh
  58473. * * 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
  58474. * * The parameter `size` (positive float, default 1) sets the polygon size
  58475. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  58476. * * 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`
  58477. * * 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
  58478. * * 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)`)
  58479. * * 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
  58480. * * 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
  58481. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58482. * * 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
  58483. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58484. * @param name defines the name of the mesh
  58485. * @param options defines the options used to create the mesh
  58486. * @param scene defines the hosting scene
  58487. * @returns the polyhedron mesh
  58488. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  58489. */
  58490. static CreatePolyhedron(name: string, options: {
  58491. type?: number;
  58492. size?: number;
  58493. sizeX?: number;
  58494. sizeY?: number;
  58495. sizeZ?: number;
  58496. custom?: any;
  58497. faceUV?: Vector4[];
  58498. faceColors?: Color4[];
  58499. flat?: boolean;
  58500. updatable?: boolean;
  58501. sideOrientation?: number;
  58502. frontUVs?: Vector4;
  58503. backUVs?: Vector4;
  58504. }, scene?: Nullable<Scene>): Mesh;
  58505. }
  58506. }
  58507. declare module BABYLON {
  58508. /**
  58509. * Class containing static functions to help procedurally build meshes
  58510. */
  58511. export class BoxBuilder {
  58512. /**
  58513. * Creates a box mesh
  58514. * * The parameter `size` sets the size (float) of each box side (default 1)
  58515. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  58516. * * 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)
  58517. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58518. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58519. * * 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
  58520. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58521. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  58522. * @param name defines the name of the mesh
  58523. * @param options defines the options used to create the mesh
  58524. * @param scene defines the hosting scene
  58525. * @returns the box mesh
  58526. */
  58527. static CreateBox(name: string, options: {
  58528. size?: number;
  58529. width?: number;
  58530. height?: number;
  58531. depth?: number;
  58532. faceUV?: Vector4[];
  58533. faceColors?: Color4[];
  58534. sideOrientation?: number;
  58535. frontUVs?: Vector4;
  58536. backUVs?: Vector4;
  58537. wrap?: boolean;
  58538. topBaseAt?: number;
  58539. bottomBaseAt?: number;
  58540. updatable?: boolean;
  58541. }, scene?: Nullable<Scene>): Mesh;
  58542. }
  58543. }
  58544. declare module BABYLON {
  58545. /**
  58546. * Single axis scale gizmo
  58547. */
  58548. export class AxisScaleGizmo extends Gizmo {
  58549. /**
  58550. * Drag behavior responsible for the gizmos dragging interactions
  58551. */
  58552. dragBehavior: PointerDragBehavior;
  58553. private _pointerObserver;
  58554. /**
  58555. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  58556. */
  58557. snapDistance: number;
  58558. /**
  58559. * Event that fires each time the gizmo snaps to a new location.
  58560. * * snapDistance is the the change in distance
  58561. */
  58562. onSnapObservable: Observable<{
  58563. snapDistance: number;
  58564. }>;
  58565. /**
  58566. * If the scaling operation should be done on all axis (default: false)
  58567. */
  58568. uniformScaling: boolean;
  58569. /**
  58570. * Custom sensitivity value for the drag strength
  58571. */
  58572. sensitivity: number;
  58573. private _isEnabled;
  58574. private _parent;
  58575. private _gizmoMesh;
  58576. private _coloredMaterial;
  58577. private _hoverMaterial;
  58578. private _disableMaterial;
  58579. private _dragging;
  58580. private _tmpVector;
  58581. private _tmpMatrix;
  58582. private _tmpMatrix2;
  58583. /**
  58584. * Creates an AxisScaleGizmo
  58585. * @param gizmoLayer The utility layer the gizmo will be added to
  58586. * @param dragAxis The axis which the gizmo will be able to scale on
  58587. * @param color The color of the gizmo
  58588. * @param thickness display gizmo axis thickness
  58589. */
  58590. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  58591. /** Create Geometry for Gizmo */
  58592. private _createGizmoMesh;
  58593. protected _attachedNodeChanged(value: Nullable<Node>): void;
  58594. /**
  58595. * If the gizmo is enabled
  58596. */
  58597. set isEnabled(value: boolean);
  58598. get isEnabled(): boolean;
  58599. /**
  58600. * Disposes of the gizmo
  58601. */
  58602. dispose(): void;
  58603. /**
  58604. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  58605. * @param mesh The mesh to replace the default mesh of the gizmo
  58606. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  58607. */
  58608. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  58609. }
  58610. }
  58611. declare module BABYLON {
  58612. /**
  58613. * Gizmo that enables scaling a mesh along 3 axis
  58614. */
  58615. export class ScaleGizmo extends Gizmo {
  58616. /**
  58617. * Internal gizmo used for interactions on the x axis
  58618. */
  58619. xGizmo: AxisScaleGizmo;
  58620. /**
  58621. * Internal gizmo used for interactions on the y axis
  58622. */
  58623. yGizmo: AxisScaleGizmo;
  58624. /**
  58625. * Internal gizmo used for interactions on the z axis
  58626. */
  58627. zGizmo: AxisScaleGizmo;
  58628. /**
  58629. * Internal gizmo used to scale all axis equally
  58630. */
  58631. uniformScaleGizmo: AxisScaleGizmo;
  58632. private _meshAttached;
  58633. private _nodeAttached;
  58634. private _snapDistance;
  58635. private _uniformScalingMesh;
  58636. private _octahedron;
  58637. private _sensitivity;
  58638. private _coloredMaterial;
  58639. private _hoverMaterial;
  58640. private _disableMaterial;
  58641. private _observables;
  58642. /** Node Caching for quick lookup */
  58643. private _gizmoAxisCache;
  58644. /** Fires an event when any of it's sub gizmos are dragged */
  58645. onDragStartObservable: Observable<unknown>;
  58646. /** Fires an event when any of it's sub gizmos are released from dragging */
  58647. onDragEndObservable: Observable<unknown>;
  58648. get attachedMesh(): Nullable<AbstractMesh>;
  58649. set attachedMesh(mesh: Nullable<AbstractMesh>);
  58650. get attachedNode(): Nullable<Node>;
  58651. set attachedNode(node: Nullable<Node>);
  58652. /**
  58653. * True when the mouse pointer is hovering a gizmo mesh
  58654. */
  58655. get isHovered(): boolean;
  58656. /**
  58657. * Creates a ScaleGizmo
  58658. * @param gizmoLayer The utility layer the gizmo will be added to
  58659. * @param thickness display gizmo axis thickness
  58660. */
  58661. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  58662. /** Create Geometry for Gizmo */
  58663. private _createUniformScaleMesh;
  58664. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  58665. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  58666. /**
  58667. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  58668. */
  58669. set snapDistance(value: number);
  58670. get snapDistance(): number;
  58671. /**
  58672. * Ratio for the scale of the gizmo (Default: 1)
  58673. */
  58674. set scaleRatio(value: number);
  58675. get scaleRatio(): number;
  58676. /**
  58677. * Sensitivity factor for dragging (Default: 1)
  58678. */
  58679. set sensitivity(value: number);
  58680. get sensitivity(): number;
  58681. /**
  58682. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  58683. * @param mesh Axis gizmo mesh
  58684. * @param cache Gizmo axis definition used for reactive gizmo UI
  58685. */
  58686. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  58687. /**
  58688. * Disposes of the gizmo
  58689. */
  58690. dispose(): void;
  58691. }
  58692. }
  58693. declare module BABYLON {
  58694. /**
  58695. * Bounding box gizmo
  58696. */
  58697. export class BoundingBoxGizmo extends Gizmo {
  58698. private _lineBoundingBox;
  58699. private _rotateSpheresParent;
  58700. private _scaleBoxesParent;
  58701. private _boundingDimensions;
  58702. private _renderObserver;
  58703. private _pointerObserver;
  58704. private _scaleDragSpeed;
  58705. private _tmpQuaternion;
  58706. private _tmpVector;
  58707. private _tmpRotationMatrix;
  58708. /**
  58709. * 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)
  58710. */
  58711. ignoreChildren: boolean;
  58712. /**
  58713. * 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)
  58714. */
  58715. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  58716. /**
  58717. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  58718. */
  58719. rotationSphereSize: number;
  58720. /**
  58721. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  58722. */
  58723. scaleBoxSize: number;
  58724. /**
  58725. * 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)
  58726. * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true
  58727. */
  58728. fixedDragMeshScreenSize: boolean;
  58729. /**
  58730. * If set, the rotation spheres and scale boxes will increase in size based on the size of the bounding box
  58731. * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true
  58732. */
  58733. fixedDragMeshBoundsSize: boolean;
  58734. /**
  58735. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  58736. */
  58737. fixedDragMeshScreenSizeDistanceFactor: number;
  58738. /**
  58739. * Fired when a rotation sphere or scale box is dragged
  58740. */
  58741. onDragStartObservable: Observable<{}>;
  58742. /**
  58743. * Fired when a scale box is dragged
  58744. */
  58745. onScaleBoxDragObservable: Observable<{}>;
  58746. /**
  58747. * Fired when a scale box drag is ended
  58748. */
  58749. onScaleBoxDragEndObservable: Observable<{}>;
  58750. /**
  58751. * Fired when a rotation sphere is dragged
  58752. */
  58753. onRotationSphereDragObservable: Observable<{}>;
  58754. /**
  58755. * Fired when a rotation sphere drag is ended
  58756. */
  58757. onRotationSphereDragEndObservable: Observable<{}>;
  58758. /**
  58759. * 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)
  58760. */
  58761. scalePivot: Nullable<Vector3>;
  58762. /**
  58763. * Mesh used as a pivot to rotate the attached node
  58764. */
  58765. private _anchorMesh;
  58766. private _existingMeshScale;
  58767. private _dragMesh;
  58768. private pointerDragBehavior;
  58769. private coloredMaterial;
  58770. private hoverColoredMaterial;
  58771. /**
  58772. * Sets the color of the bounding box gizmo
  58773. * @param color the color to set
  58774. */
  58775. setColor(color: Color3): void;
  58776. /**
  58777. * Creates an BoundingBoxGizmo
  58778. * @param gizmoLayer The utility layer the gizmo will be added to
  58779. * @param color The color of the gizmo
  58780. */
  58781. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  58782. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  58783. private _selectNode;
  58784. /**
  58785. * Updates the bounding box information for the Gizmo
  58786. */
  58787. updateBoundingBox(): void;
  58788. private _updateRotationSpheres;
  58789. private _updateScaleBoxes;
  58790. /**
  58791. * Enables rotation on the specified axis and disables rotation on the others
  58792. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  58793. */
  58794. setEnabledRotationAxis(axis: string): void;
  58795. /**
  58796. * Enables/disables scaling
  58797. * @param enable if scaling should be enabled
  58798. * @param homogeneousScaling defines if scaling should only be homogeneous
  58799. */
  58800. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  58801. private _updateDummy;
  58802. /**
  58803. * Enables a pointer drag behavior on the bounding box of the gizmo
  58804. */
  58805. enableDragBehavior(): void;
  58806. /**
  58807. * Disposes of the gizmo
  58808. */
  58809. dispose(): void;
  58810. /**
  58811. * 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)
  58812. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  58813. * @returns the bounding box mesh with the passed in mesh as a child
  58814. */
  58815. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  58816. /**
  58817. * CustomMeshes are not supported by this gizmo
  58818. * @param mesh The mesh to replace the default mesh of the gizmo
  58819. */
  58820. setCustomMesh(mesh: Mesh): void;
  58821. }
  58822. }
  58823. declare module BABYLON {
  58824. /**
  58825. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  58826. */
  58827. export class GizmoManager implements IDisposable {
  58828. private scene;
  58829. /**
  58830. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  58831. */
  58832. gizmos: {
  58833. positionGizmo: Nullable<PositionGizmo>;
  58834. rotationGizmo: Nullable<RotationGizmo>;
  58835. scaleGizmo: Nullable<ScaleGizmo>;
  58836. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  58837. };
  58838. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  58839. clearGizmoOnEmptyPointerEvent: boolean;
  58840. /** Fires an event when the manager is attached to a mesh */
  58841. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  58842. /** Fires an event when the manager is attached to a node */
  58843. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  58844. private _gizmosEnabled;
  58845. private _pointerObservers;
  58846. private _attachedMesh;
  58847. private _attachedNode;
  58848. private _boundingBoxColor;
  58849. private _defaultUtilityLayer;
  58850. private _defaultKeepDepthUtilityLayer;
  58851. private _thickness;
  58852. /** Node Caching for quick lookup */
  58853. private _gizmoAxisCache;
  58854. /**
  58855. * When bounding box gizmo is enabled, this can be used to track drag/end events
  58856. */
  58857. boundingBoxDragBehavior: SixDofDragBehavior;
  58858. /**
  58859. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  58860. */
  58861. attachableMeshes: Nullable<Array<AbstractMesh>>;
  58862. /**
  58863. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  58864. */
  58865. attachableNodes: Nullable<Array<Node>>;
  58866. /**
  58867. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  58868. */
  58869. usePointerToAttachGizmos: boolean;
  58870. /**
  58871. * Utility layer that the bounding box gizmo belongs to
  58872. */
  58873. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  58874. /**
  58875. * Utility layer that all gizmos besides bounding box belong to
  58876. */
  58877. get utilityLayer(): UtilityLayerRenderer;
  58878. /**
  58879. * True when the mouse pointer is hovering a gizmo mesh
  58880. */
  58881. get isHovered(): boolean;
  58882. /**
  58883. * Instantiates a gizmo manager
  58884. * @param scene the scene to overlay the gizmos on top of
  58885. * @param thickness display gizmo axis thickness
  58886. * @param utilityLayer the layer where gizmos are rendered
  58887. * @param keepDepthUtilityLayer the layer where occluded gizmos are rendered
  58888. */
  58889. constructor(scene: Scene, thickness?: number, utilityLayer?: UtilityLayerRenderer, keepDepthUtilityLayer?: UtilityLayerRenderer);
  58890. /**
  58891. * Subscribes to pointer down events, for attaching and detaching mesh
  58892. * @param scene The scene layer the observer will be added to
  58893. */
  58894. private _attachToMeshPointerObserver;
  58895. /**
  58896. * Attaches a set of gizmos to the specified mesh
  58897. * @param mesh The mesh the gizmo's should be attached to
  58898. */
  58899. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  58900. /**
  58901. * Attaches a set of gizmos to the specified node
  58902. * @param node The node the gizmo's should be attached to
  58903. */
  58904. attachToNode(node: Nullable<Node>): void;
  58905. /**
  58906. * If the position gizmo is enabled
  58907. */
  58908. set positionGizmoEnabled(value: boolean);
  58909. get positionGizmoEnabled(): boolean;
  58910. /**
  58911. * If the rotation gizmo is enabled
  58912. */
  58913. set rotationGizmoEnabled(value: boolean);
  58914. get rotationGizmoEnabled(): boolean;
  58915. /**
  58916. * If the scale gizmo is enabled
  58917. */
  58918. set scaleGizmoEnabled(value: boolean);
  58919. get scaleGizmoEnabled(): boolean;
  58920. /**
  58921. * If the boundingBox gizmo is enabled
  58922. */
  58923. set boundingBoxGizmoEnabled(value: boolean);
  58924. get boundingBoxGizmoEnabled(): boolean;
  58925. /**
  58926. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  58927. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  58928. */
  58929. addToAxisCache(gizmoAxisCache: Map<Mesh, GizmoAxisCache>): void;
  58930. /**
  58931. * Disposes of the gizmo manager
  58932. */
  58933. dispose(): void;
  58934. }
  58935. }
  58936. declare module BABYLON {
  58937. /**
  58938. * Gizmo that enables dragging a mesh along 3 axis
  58939. */
  58940. export class PositionGizmo extends Gizmo {
  58941. /**
  58942. * Internal gizmo used for interactions on the x axis
  58943. */
  58944. xGizmo: AxisDragGizmo;
  58945. /**
  58946. * Internal gizmo used for interactions on the y axis
  58947. */
  58948. yGizmo: AxisDragGizmo;
  58949. /**
  58950. * Internal gizmo used for interactions on the z axis
  58951. */
  58952. zGizmo: AxisDragGizmo;
  58953. /**
  58954. * Internal gizmo used for interactions on the yz plane
  58955. */
  58956. xPlaneGizmo: PlaneDragGizmo;
  58957. /**
  58958. * Internal gizmo used for interactions on the xz plane
  58959. */
  58960. yPlaneGizmo: PlaneDragGizmo;
  58961. /**
  58962. * Internal gizmo used for interactions on the xy plane
  58963. */
  58964. zPlaneGizmo: PlaneDragGizmo;
  58965. /**
  58966. * private variables
  58967. */
  58968. private _meshAttached;
  58969. private _nodeAttached;
  58970. private _snapDistance;
  58971. private _observables;
  58972. /** Node Caching for quick lookup */
  58973. private _gizmoAxisCache;
  58974. /** Fires an event when any of it's sub gizmos are dragged */
  58975. onDragStartObservable: Observable<unknown>;
  58976. /** Fires an event when any of it's sub gizmos are released from dragging */
  58977. onDragEndObservable: Observable<unknown>;
  58978. /**
  58979. * If set to true, planar drag is enabled
  58980. */
  58981. private _planarGizmoEnabled;
  58982. get attachedMesh(): Nullable<AbstractMesh>;
  58983. set attachedMesh(mesh: Nullable<AbstractMesh>);
  58984. get attachedNode(): Nullable<Node>;
  58985. set attachedNode(node: Nullable<Node>);
  58986. /**
  58987. * True when the mouse pointer is hovering a gizmo mesh
  58988. */
  58989. get isHovered(): boolean;
  58990. /**
  58991. * Creates a PositionGizmo
  58992. * @param gizmoLayer The utility layer the gizmo will be added to
  58993. @param thickness display gizmo axis thickness
  58994. */
  58995. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  58996. /**
  58997. * If the planar drag gizmo is enabled
  58998. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  58999. */
  59000. set planarGizmoEnabled(value: boolean);
  59001. get planarGizmoEnabled(): boolean;
  59002. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  59003. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  59004. /**
  59005. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  59006. */
  59007. set snapDistance(value: number);
  59008. get snapDistance(): number;
  59009. /**
  59010. * Ratio for the scale of the gizmo (Default: 1)
  59011. */
  59012. set scaleRatio(value: number);
  59013. get scaleRatio(): number;
  59014. /**
  59015. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  59016. * @param mesh Axis gizmo mesh
  59017. * @param cache Gizmo axis definition used for reactive gizmo UI
  59018. */
  59019. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  59020. /**
  59021. * Disposes of the gizmo
  59022. */
  59023. dispose(): void;
  59024. /**
  59025. * CustomMeshes are not supported by this gizmo
  59026. * @param mesh The mesh to replace the default mesh of the gizmo
  59027. */
  59028. setCustomMesh(mesh: Mesh): void;
  59029. }
  59030. }
  59031. declare module BABYLON {
  59032. /**
  59033. * Single axis drag gizmo
  59034. */
  59035. export class AxisDragGizmo extends Gizmo {
  59036. /**
  59037. * Drag behavior responsible for the gizmos dragging interactions
  59038. */
  59039. dragBehavior: PointerDragBehavior;
  59040. private _pointerObserver;
  59041. /**
  59042. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  59043. */
  59044. snapDistance: number;
  59045. /**
  59046. * Event that fires each time the gizmo snaps to a new location.
  59047. * * snapDistance is the the change in distance
  59048. */
  59049. onSnapObservable: Observable<{
  59050. snapDistance: number;
  59051. }>;
  59052. private _isEnabled;
  59053. private _parent;
  59054. private _gizmoMesh;
  59055. private _coloredMaterial;
  59056. private _hoverMaterial;
  59057. private _disableMaterial;
  59058. private _dragging;
  59059. /** @hidden */
  59060. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number, isCollider?: boolean): TransformNode;
  59061. /** @hidden */
  59062. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  59063. /**
  59064. * Creates an AxisDragGizmo
  59065. * @param gizmoLayer The utility layer the gizmo will be added to
  59066. * @param dragAxis The axis which the gizmo will be able to drag on
  59067. * @param color The color of the gizmo
  59068. * @param thickness display gizmo axis thickness
  59069. */
  59070. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  59071. protected _attachedNodeChanged(value: Nullable<Node>): void;
  59072. /**
  59073. * If the gizmo is enabled
  59074. */
  59075. set isEnabled(value: boolean);
  59076. get isEnabled(): boolean;
  59077. /**
  59078. * Disposes of the gizmo
  59079. */
  59080. dispose(): void;
  59081. }
  59082. }
  59083. declare module BABYLON.Debug {
  59084. /**
  59085. * The Axes viewer will show 3 axes in a specific point in space
  59086. */
  59087. export class AxesViewer {
  59088. private _xAxis;
  59089. private _yAxis;
  59090. private _zAxis;
  59091. private _scaleLinesFactor;
  59092. private _instanced;
  59093. /**
  59094. * Gets the hosting scene
  59095. */
  59096. scene: Nullable<Scene>;
  59097. /**
  59098. * Gets or sets a number used to scale line length
  59099. */
  59100. scaleLines: number;
  59101. /** Gets the node hierarchy used to render x-axis */
  59102. get xAxis(): TransformNode;
  59103. /** Gets the node hierarchy used to render y-axis */
  59104. get yAxis(): TransformNode;
  59105. /** Gets the node hierarchy used to render z-axis */
  59106. get zAxis(): TransformNode;
  59107. /**
  59108. * Creates a new AxesViewer
  59109. * @param scene defines the hosting scene
  59110. * @param scaleLines defines a number used to scale line length (1 by default)
  59111. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  59112. * @param xAxis defines the node hierarchy used to render the x-axis
  59113. * @param yAxis defines the node hierarchy used to render the y-axis
  59114. * @param zAxis defines the node hierarchy used to render the z-axis
  59115. */
  59116. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  59117. /**
  59118. * Force the viewer to update
  59119. * @param position defines the position of the viewer
  59120. * @param xaxis defines the x axis of the viewer
  59121. * @param yaxis defines the y axis of the viewer
  59122. * @param zaxis defines the z axis of the viewer
  59123. */
  59124. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  59125. /**
  59126. * Creates an instance of this axes viewer.
  59127. * @returns a new axes viewer with instanced meshes
  59128. */
  59129. createInstance(): AxesViewer;
  59130. /** Releases resources */
  59131. dispose(): void;
  59132. private static _SetRenderingGroupId;
  59133. }
  59134. }
  59135. declare module BABYLON.Debug {
  59136. /**
  59137. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  59138. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  59139. */
  59140. export class BoneAxesViewer extends AxesViewer {
  59141. /**
  59142. * Gets or sets the target mesh where to display the axes viewer
  59143. */
  59144. mesh: Nullable<Mesh>;
  59145. /**
  59146. * Gets or sets the target bone where to display the axes viewer
  59147. */
  59148. bone: Nullable<Bone>;
  59149. /** Gets current position */
  59150. pos: Vector3;
  59151. /** Gets direction of X axis */
  59152. xaxis: Vector3;
  59153. /** Gets direction of Y axis */
  59154. yaxis: Vector3;
  59155. /** Gets direction of Z axis */
  59156. zaxis: Vector3;
  59157. /**
  59158. * Creates a new BoneAxesViewer
  59159. * @param scene defines the hosting scene
  59160. * @param bone defines the target bone
  59161. * @param mesh defines the target mesh
  59162. * @param scaleLines defines a scaling factor for line length (1 by default)
  59163. */
  59164. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  59165. /**
  59166. * Force the viewer to update
  59167. */
  59168. update(): void;
  59169. /** Releases resources */
  59170. dispose(): void;
  59171. }
  59172. }
  59173. declare module BABYLON {
  59174. /**
  59175. * Interface used to define scene explorer extensibility option
  59176. */
  59177. export interface IExplorerExtensibilityOption {
  59178. /**
  59179. * Define the option label
  59180. */
  59181. label: string;
  59182. /**
  59183. * Defines the action to execute on click
  59184. */
  59185. action: (entity: any) => void;
  59186. }
  59187. /**
  59188. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  59189. */
  59190. export interface IExplorerExtensibilityGroup {
  59191. /**
  59192. * Defines a predicate to test if a given type mut be extended
  59193. */
  59194. predicate: (entity: any) => boolean;
  59195. /**
  59196. * Gets the list of options added to a type
  59197. */
  59198. entries: IExplorerExtensibilityOption[];
  59199. }
  59200. /**
  59201. * Interface used to define the options to use to create the Inspector
  59202. */
  59203. export interface IInspectorOptions {
  59204. /**
  59205. * Display in overlay mode (default: false)
  59206. */
  59207. overlay?: boolean;
  59208. /**
  59209. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  59210. */
  59211. globalRoot?: HTMLElement;
  59212. /**
  59213. * Display the Scene explorer
  59214. */
  59215. showExplorer?: boolean;
  59216. /**
  59217. * Display the property inspector
  59218. */
  59219. showInspector?: boolean;
  59220. /**
  59221. * Display in embed mode (both panes on the right)
  59222. */
  59223. embedMode?: boolean;
  59224. /**
  59225. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  59226. */
  59227. handleResize?: boolean;
  59228. /**
  59229. * Allow the panes to popup (default: true)
  59230. */
  59231. enablePopup?: boolean;
  59232. /**
  59233. * Allow the panes to be closed by users (default: true)
  59234. */
  59235. enableClose?: boolean;
  59236. /**
  59237. * Optional list of extensibility entries
  59238. */
  59239. explorerExtensibility?: IExplorerExtensibilityGroup[];
  59240. /**
  59241. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  59242. */
  59243. inspectorURL?: string;
  59244. /**
  59245. * Optional initial tab (default to DebugLayerTab.Properties)
  59246. */
  59247. initialTab?: DebugLayerTab;
  59248. }
  59249. interface Scene {
  59250. /**
  59251. * @hidden
  59252. * Backing field
  59253. */
  59254. _debugLayer: DebugLayer;
  59255. /**
  59256. * Gets the debug layer (aka Inspector) associated with the scene
  59257. * @see https://doc.babylonjs.com/features/playground_debuglayer
  59258. */
  59259. debugLayer: DebugLayer;
  59260. }
  59261. /**
  59262. * Enum of inspector action tab
  59263. */
  59264. export enum DebugLayerTab {
  59265. /**
  59266. * Properties tag (default)
  59267. */
  59268. Properties = 0,
  59269. /**
  59270. * Debug tab
  59271. */
  59272. Debug = 1,
  59273. /**
  59274. * Statistics tab
  59275. */
  59276. Statistics = 2,
  59277. /**
  59278. * Tools tab
  59279. */
  59280. Tools = 3,
  59281. /**
  59282. * Settings tab
  59283. */
  59284. Settings = 4
  59285. }
  59286. /**
  59287. * The debug layer (aka Inspector) is the go to tool in order to better understand
  59288. * what is happening in your scene
  59289. * @see https://doc.babylonjs.com/features/playground_debuglayer
  59290. */
  59291. export class DebugLayer {
  59292. /**
  59293. * Define the url to get the inspector script from.
  59294. * By default it uses the babylonjs CDN.
  59295. * @ignoreNaming
  59296. */
  59297. static InspectorURL: string;
  59298. private _scene;
  59299. private BJSINSPECTOR;
  59300. private _onPropertyChangedObservable?;
  59301. /**
  59302. * Observable triggered when a property is changed through the inspector.
  59303. */
  59304. get onPropertyChangedObservable(): any;
  59305. /**
  59306. * Instantiates a new debug layer.
  59307. * The debug layer (aka Inspector) is the go to tool in order to better understand
  59308. * what is happening in your scene
  59309. * @see https://doc.babylonjs.com/features/playground_debuglayer
  59310. * @param scene Defines the scene to inspect
  59311. */
  59312. constructor(scene: Scene);
  59313. /** Creates the inspector window. */
  59314. private _createInspector;
  59315. /**
  59316. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  59317. * @param entity defines the entity to select
  59318. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  59319. */
  59320. select(entity: any, lineContainerTitles?: string | string[]): void;
  59321. /** Get the inspector from bundle or global */
  59322. private _getGlobalInspector;
  59323. /**
  59324. * Get if the inspector is visible or not.
  59325. * @returns true if visible otherwise, false
  59326. */
  59327. isVisible(): boolean;
  59328. /**
  59329. * Hide the inspector and close its window.
  59330. */
  59331. hide(): void;
  59332. /**
  59333. * Update the scene in the inspector
  59334. */
  59335. setAsActiveScene(): void;
  59336. /**
  59337. * Launch the debugLayer.
  59338. * @param config Define the configuration of the inspector
  59339. * @return a promise fulfilled when the debug layer is visible
  59340. */
  59341. show(config?: IInspectorOptions): Promise<DebugLayer>;
  59342. }
  59343. }
  59344. declare module BABYLON.Debug {
  59345. /**
  59346. * Used to show the physics impostor around the specific mesh
  59347. */
  59348. export class PhysicsViewer {
  59349. /** @hidden */
  59350. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  59351. /** @hidden */
  59352. protected _meshes: Array<Nullable<AbstractMesh>>;
  59353. /** @hidden */
  59354. protected _scene: Nullable<Scene>;
  59355. /** @hidden */
  59356. protected _numMeshes: number;
  59357. /** @hidden */
  59358. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  59359. private _renderFunction;
  59360. private _utilityLayer;
  59361. private _debugBoxMesh;
  59362. private _debugSphereMesh;
  59363. private _debugCylinderMesh;
  59364. private _debugMaterial;
  59365. private _debugMeshMeshes;
  59366. /**
  59367. * Creates a new PhysicsViewer
  59368. * @param scene defines the hosting scene
  59369. */
  59370. constructor(scene: Scene);
  59371. /** @hidden */
  59372. protected _updateDebugMeshes(): void;
  59373. /**
  59374. * Renders a specified physic impostor
  59375. * @param impostor defines the impostor to render
  59376. * @param targetMesh defines the mesh represented by the impostor
  59377. * @returns the new debug mesh used to render the impostor
  59378. */
  59379. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  59380. /**
  59381. * Hides a specified physic impostor
  59382. * @param impostor defines the impostor to hide
  59383. */
  59384. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  59385. private _getDebugMaterial;
  59386. private _getDebugBoxMesh;
  59387. private _getDebugSphereMesh;
  59388. private _getDebugCylinderMesh;
  59389. private _getDebugMeshMesh;
  59390. private _getDebugMesh;
  59391. /** Releases all resources */
  59392. dispose(): void;
  59393. }
  59394. }
  59395. declare module BABYLON {
  59396. /**
  59397. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  59398. * in order to better appreciate the issue one might have.
  59399. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  59400. */
  59401. export class RayHelper {
  59402. /**
  59403. * Defines the ray we are currently tryin to visualize.
  59404. */
  59405. ray: Nullable<Ray>;
  59406. private _renderPoints;
  59407. private _renderLine;
  59408. private _renderFunction;
  59409. private _scene;
  59410. private _onAfterRenderObserver;
  59411. private _onAfterStepObserver;
  59412. private _attachedToMesh;
  59413. private _meshSpaceDirection;
  59414. private _meshSpaceOrigin;
  59415. /**
  59416. * Helper function to create a colored helper in a scene in one line.
  59417. * @param ray Defines the ray we are currently tryin to visualize
  59418. * @param scene Defines the scene the ray is used in
  59419. * @param color Defines the color we want to see the ray in
  59420. * @returns The newly created ray helper.
  59421. */
  59422. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  59423. /**
  59424. * Instantiate a new ray helper.
  59425. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  59426. * in order to better appreciate the issue one might have.
  59427. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  59428. * @param ray Defines the ray we are currently tryin to visualize
  59429. */
  59430. constructor(ray: Ray);
  59431. /**
  59432. * Shows the ray we are willing to debug.
  59433. * @param scene Defines the scene the ray needs to be rendered in
  59434. * @param color Defines the color the ray needs to be rendered in
  59435. */
  59436. show(scene: Scene, color?: Color3): void;
  59437. /**
  59438. * Hides the ray we are debugging.
  59439. */
  59440. hide(): void;
  59441. private _render;
  59442. /**
  59443. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  59444. * @param mesh Defines the mesh we want the helper attached to
  59445. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  59446. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  59447. * @param length Defines the length of the ray
  59448. */
  59449. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  59450. /**
  59451. * Detach the ray helper from the mesh it has previously been attached to.
  59452. */
  59453. detachFromMesh(): void;
  59454. private _updateToMesh;
  59455. /**
  59456. * Dispose the helper and release its associated resources.
  59457. */
  59458. dispose(): void;
  59459. }
  59460. }
  59461. declare module BABYLON {
  59462. /**
  59463. * Defines the options associated with the creation of a SkeletonViewer.
  59464. */
  59465. export interface ISkeletonViewerOptions {
  59466. /** Should the system pause animations before building the Viewer? */
  59467. pauseAnimations: boolean;
  59468. /** Should the system return the skeleton to rest before building? */
  59469. returnToRest: boolean;
  59470. /** public Display Mode of the Viewer */
  59471. displayMode: number;
  59472. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  59473. displayOptions: ISkeletonViewerDisplayOptions;
  59474. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  59475. computeBonesUsingShaders: boolean;
  59476. /** Flag ignore non weighted bones */
  59477. useAllBones: boolean;
  59478. }
  59479. /**
  59480. * Defines how to display the various bone meshes for the viewer.
  59481. */
  59482. export interface ISkeletonViewerDisplayOptions {
  59483. /** How far down to start tapering the bone spurs */
  59484. midStep?: number;
  59485. /** How big is the midStep? */
  59486. midStepFactor?: number;
  59487. /** Base for the Sphere Size */
  59488. sphereBaseSize?: number;
  59489. /** The ratio of the sphere to the longest bone in units */
  59490. sphereScaleUnit?: number;
  59491. /** Ratio for the Sphere Size */
  59492. sphereFactor?: number;
  59493. /** Whether a spur should attach its far end to the child bone position */
  59494. spurFollowsChild?: boolean;
  59495. /** Whether to show local axes or not */
  59496. showLocalAxes?: boolean;
  59497. /** Length of each local axis */
  59498. localAxesSize?: number;
  59499. }
  59500. /**
  59501. * Defines the constructor options for the BoneWeight Shader.
  59502. */
  59503. export interface IBoneWeightShaderOptions {
  59504. /** Skeleton to Map */
  59505. skeleton: Skeleton;
  59506. /** Colors for Uninfluenced bones */
  59507. colorBase?: Color3;
  59508. /** Colors for 0.0-0.25 Weight bones */
  59509. colorZero?: Color3;
  59510. /** Color for 0.25-0.5 Weight Influence */
  59511. colorQuarter?: Color3;
  59512. /** Color for 0.5-0.75 Weight Influence */
  59513. colorHalf?: Color3;
  59514. /** Color for 0.75-1 Weight Influence */
  59515. colorFull?: Color3;
  59516. /** Color for Zero Weight Influence */
  59517. targetBoneIndex?: number;
  59518. }
  59519. /**
  59520. * Simple structure of the gradient steps for the Color Map.
  59521. */
  59522. export interface ISkeletonMapShaderColorMapKnot {
  59523. /** Color of the Knot */
  59524. color: Color3;
  59525. /** Location of the Knot */
  59526. location: number;
  59527. }
  59528. /**
  59529. * Defines the constructor options for the SkeletonMap Shader.
  59530. */
  59531. export interface ISkeletonMapShaderOptions {
  59532. /** Skeleton to Map */
  59533. skeleton: Skeleton;
  59534. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  59535. colorMap?: ISkeletonMapShaderColorMapKnot[];
  59536. }
  59537. }
  59538. declare module BABYLON {
  59539. /**
  59540. * Class containing static functions to help procedurally build meshes
  59541. */
  59542. export class RibbonBuilder {
  59543. /**
  59544. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59545. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  59546. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  59547. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  59548. * * 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
  59549. * * 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
  59550. * * 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
  59551. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59552. * * 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
  59553. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59554. * * 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
  59555. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  59556. * * 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
  59557. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  59558. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59559. * @param name defines the name of the mesh
  59560. * @param options defines the options used to create the mesh
  59561. * @param scene defines the hosting scene
  59562. * @returns the ribbon mesh
  59563. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  59564. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59565. */
  59566. static CreateRibbon(name: string, options: {
  59567. pathArray: Vector3[][];
  59568. closeArray?: boolean;
  59569. closePath?: boolean;
  59570. offset?: number;
  59571. updatable?: boolean;
  59572. sideOrientation?: number;
  59573. frontUVs?: Vector4;
  59574. backUVs?: Vector4;
  59575. instance?: Mesh;
  59576. invertUV?: boolean;
  59577. uvs?: Vector2[];
  59578. colors?: Color4[];
  59579. }, scene?: Nullable<Scene>): Mesh;
  59580. }
  59581. }
  59582. declare module BABYLON {
  59583. /**
  59584. * Class containing static functions to help procedurally build meshes
  59585. */
  59586. export class ShapeBuilder {
  59587. /**
  59588. * 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.
  59589. * * 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.
  59590. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59591. * * 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.
  59592. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  59593. * * 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
  59594. * * 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
  59595. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  59596. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59597. * * 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
  59598. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  59599. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59600. * @param name defines the name of the mesh
  59601. * @param options defines the options used to create the mesh
  59602. * @param scene defines the hosting scene
  59603. * @returns the extruded shape mesh
  59604. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59605. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59606. */
  59607. static ExtrudeShape(name: string, options: {
  59608. shape: Vector3[];
  59609. path: Vector3[];
  59610. scale?: number;
  59611. rotation?: number;
  59612. cap?: number;
  59613. updatable?: boolean;
  59614. sideOrientation?: number;
  59615. frontUVs?: Vector4;
  59616. backUVs?: Vector4;
  59617. instance?: Mesh;
  59618. invertUV?: boolean;
  59619. }, scene?: Nullable<Scene>): Mesh;
  59620. /**
  59621. * Creates an custom extruded shape mesh.
  59622. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  59623. * * 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.
  59624. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59625. * * 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
  59626. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  59627. * * 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
  59628. * * It must returns a float value that will be the scale value applied to the shape on each path point
  59629. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  59630. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  59631. * * 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
  59632. * * 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
  59633. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  59634. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59635. * * 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
  59636. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59637. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59638. * @param name defines the name of the mesh
  59639. * @param options defines the options used to create the mesh
  59640. * @param scene defines the hosting scene
  59641. * @returns the custom extruded shape mesh
  59642. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  59643. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59644. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59645. */
  59646. static ExtrudeShapeCustom(name: string, options: {
  59647. shape: Vector3[];
  59648. path: Vector3[];
  59649. scaleFunction?: any;
  59650. rotationFunction?: any;
  59651. ribbonCloseArray?: boolean;
  59652. ribbonClosePath?: boolean;
  59653. cap?: number;
  59654. updatable?: boolean;
  59655. sideOrientation?: number;
  59656. frontUVs?: Vector4;
  59657. backUVs?: Vector4;
  59658. instance?: Mesh;
  59659. invertUV?: boolean;
  59660. }, scene?: Nullable<Scene>): Mesh;
  59661. private static _ExtrudeShapeGeneric;
  59662. }
  59663. }
  59664. declare module BABYLON.Debug {
  59665. /**
  59666. * Class used to render a debug view of a given skeleton
  59667. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  59668. */
  59669. export class SkeletonViewer {
  59670. /** defines the skeleton to render */
  59671. skeleton: Skeleton;
  59672. /** defines the mesh attached to the skeleton */
  59673. mesh: AbstractMesh;
  59674. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  59675. autoUpdateBonesMatrices: boolean;
  59676. /** defines the rendering group id to use with the viewer */
  59677. renderingGroupId: number;
  59678. /** is the options for the viewer */
  59679. options: Partial<ISkeletonViewerOptions>;
  59680. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  59681. static readonly DISPLAY_LINES: number;
  59682. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  59683. static readonly DISPLAY_SPHERES: number;
  59684. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  59685. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  59686. /** public static method to create a BoneWeight Shader
  59687. * @param options The constructor options
  59688. * @param scene The scene that the shader is scoped to
  59689. * @returns The created ShaderMaterial
  59690. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  59691. */
  59692. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  59693. /** public static method to create a BoneWeight Shader
  59694. * @param options The constructor options
  59695. * @param scene The scene that the shader is scoped to
  59696. * @returns The created ShaderMaterial
  59697. */
  59698. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  59699. /** private static method to create a BoneWeight Shader
  59700. * @param size The size of the buffer to create (usually the bone count)
  59701. * @param colorMap The gradient data to generate
  59702. * @param scene The scene that the shader is scoped to
  59703. * @returns an Array of floats from the color gradient values
  59704. */
  59705. private static _CreateBoneMapColorBuffer;
  59706. /** If SkeletonViewer scene scope. */
  59707. private _scene;
  59708. /** Gets or sets the color used to render the skeleton */
  59709. color: Color3;
  59710. /** Array of the points of the skeleton fo the line view. */
  59711. private _debugLines;
  59712. /** The SkeletonViewers Mesh. */
  59713. private _debugMesh;
  59714. /** The local axes Meshes. */
  59715. private _localAxes;
  59716. /** If SkeletonViewer is enabled. */
  59717. private _isEnabled;
  59718. /** If SkeletonViewer is ready. */
  59719. private _ready;
  59720. /** SkeletonViewer render observable. */
  59721. private _obs;
  59722. /** The Utility Layer to render the gizmos in. */
  59723. private _utilityLayer;
  59724. private _boneIndices;
  59725. /** Gets the Scene. */
  59726. get scene(): Scene;
  59727. /** Gets the utilityLayer. */
  59728. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  59729. /** Checks Ready Status. */
  59730. get isReady(): Boolean;
  59731. /** Sets Ready Status. */
  59732. set ready(value: boolean);
  59733. /** Gets the debugMesh */
  59734. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  59735. /** Sets the debugMesh */
  59736. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  59737. /** Gets the displayMode */
  59738. get displayMode(): number;
  59739. /** Sets the displayMode */
  59740. set displayMode(value: number);
  59741. /**
  59742. * Creates a new SkeletonViewer
  59743. * @param skeleton defines the skeleton to render
  59744. * @param mesh defines the mesh attached to the skeleton
  59745. * @param scene defines the hosting scene
  59746. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  59747. * @param renderingGroupId defines the rendering group id to use with the viewer
  59748. * @param options All of the extra constructor options for the SkeletonViewer
  59749. */
  59750. constructor(
  59751. /** defines the skeleton to render */
  59752. skeleton: Skeleton,
  59753. /** defines the mesh attached to the skeleton */
  59754. mesh: AbstractMesh,
  59755. /** The Scene scope*/
  59756. scene: Scene,
  59757. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  59758. autoUpdateBonesMatrices?: boolean,
  59759. /** defines the rendering group id to use with the viewer */
  59760. renderingGroupId?: number,
  59761. /** is the options for the viewer */
  59762. options?: Partial<ISkeletonViewerOptions>);
  59763. /** The Dynamic bindings for the update functions */
  59764. private _bindObs;
  59765. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  59766. update(): void;
  59767. /** Gets or sets a boolean indicating if the viewer is enabled */
  59768. set isEnabled(value: boolean);
  59769. get isEnabled(): boolean;
  59770. private _getBonePosition;
  59771. private _getLinesForBonesWithLength;
  59772. private _getLinesForBonesNoLength;
  59773. /** function to revert the mesh and scene back to the initial state. */
  59774. private _revert;
  59775. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  59776. private _getAbsoluteBindPoseToRef;
  59777. /** function to build and bind sphere joint points and spur bone representations. */
  59778. private _buildSpheresAndSpurs;
  59779. private _buildLocalAxes;
  59780. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  59781. private _displayLinesUpdate;
  59782. /** Changes the displayMode of the skeleton viewer
  59783. * @param mode The displayMode numerical value
  59784. */
  59785. changeDisplayMode(mode: number): void;
  59786. /** Sets a display option of the skeleton viewer
  59787. *
  59788. * | Option | Type | Default | Description |
  59789. * | ---------------- | ------- | ------- | ----------- |
  59790. * | 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`. |
  59791. * | 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`. |
  59792. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  59793. * | 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`. |
  59794. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  59795. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  59796. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  59797. *
  59798. * @param option String of the option name
  59799. * @param value The numerical option value
  59800. */
  59801. changeDisplayOptions(option: string, value: number): void;
  59802. /** Release associated resources */
  59803. dispose(): void;
  59804. }
  59805. }
  59806. declare module BABYLON {
  59807. /**
  59808. * Type to handle enforcement of inputs
  59809. */
  59810. 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;
  59811. }
  59812. declare module BABYLON {
  59813. /**
  59814. * Class that handles all input for a specific device
  59815. */
  59816. export class DeviceSource<T extends DeviceType> {
  59817. /** Type of device */
  59818. readonly deviceType: DeviceType;
  59819. /** "Slot" or index that device is referenced in */
  59820. readonly deviceSlot: number;
  59821. /**
  59822. * Observable to handle device input changes per device
  59823. */
  59824. readonly onInputChangedObservable: Observable<{
  59825. inputIndex: DeviceInput<T>;
  59826. previousState: Nullable<number>;
  59827. currentState: Nullable<number>;
  59828. }>;
  59829. private readonly _deviceInputSystem;
  59830. /**
  59831. * Default Constructor
  59832. * @param deviceInputSystem Reference to DeviceInputSystem
  59833. * @param deviceType Type of device
  59834. * @param deviceSlot "Slot" or index that device is referenced in
  59835. */
  59836. constructor(deviceInputSystem: DeviceInputSystem,
  59837. /** Type of device */
  59838. deviceType: DeviceType,
  59839. /** "Slot" or index that device is referenced in */
  59840. deviceSlot?: number);
  59841. /**
  59842. * Get input for specific input
  59843. * @param inputIndex index of specific input on device
  59844. * @returns Input value from DeviceInputSystem
  59845. */
  59846. getInput(inputIndex: DeviceInput<T>): number;
  59847. }
  59848. /**
  59849. * Class to keep track of devices
  59850. */
  59851. export class DeviceSourceManager implements IDisposable {
  59852. /**
  59853. * Observable to be triggered when after a device is connected, any new observers added will be triggered against already connected devices
  59854. */
  59855. readonly onDeviceConnectedObservable: Observable<DeviceSource<DeviceType>>;
  59856. /**
  59857. * Observable to be triggered when after a device is disconnected
  59858. */
  59859. readonly onDeviceDisconnectedObservable: Observable<DeviceSource<DeviceType>>;
  59860. private readonly _devices;
  59861. private readonly _firstDevice;
  59862. private readonly _deviceInputSystem;
  59863. /**
  59864. * Default Constructor
  59865. * @param engine engine to pull input element from
  59866. */
  59867. constructor(engine: Engine);
  59868. /**
  59869. * Gets a DeviceSource, given a type and slot
  59870. * @param deviceType Enum specifying device type
  59871. * @param deviceSlot "Slot" or index that device is referenced in
  59872. * @returns DeviceSource object
  59873. */
  59874. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  59875. /**
  59876. * Gets an array of DeviceSource objects for a given device type
  59877. * @param deviceType Enum specifying device type
  59878. * @returns Array of DeviceSource objects
  59879. */
  59880. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  59881. /**
  59882. * Returns a read-only list of all available devices
  59883. * @returns Read-only array with active devices
  59884. */
  59885. getDevices(): ReadonlyArray<DeviceSource<DeviceType>>;
  59886. /**
  59887. * Dispose of DeviceInputSystem and other parts
  59888. */
  59889. dispose(): void;
  59890. /**
  59891. * Function to add device name to device list
  59892. * @param deviceType Enum specifying device type
  59893. * @param deviceSlot "Slot" or index that device is referenced in
  59894. */
  59895. private _addDevice;
  59896. /**
  59897. * Function to remove device name to device list
  59898. * @param deviceType Enum specifying device type
  59899. * @param deviceSlot "Slot" or index that device is referenced in
  59900. */
  59901. private _removeDevice;
  59902. /**
  59903. * Updates array storing first connected device of each type
  59904. * @param type Type of Device
  59905. */
  59906. private _updateFirstDevices;
  59907. }
  59908. }
  59909. declare module BABYLON {
  59910. /**
  59911. * Options to create the null engine
  59912. */
  59913. export class NullEngineOptions {
  59914. /**
  59915. * Render width (Default: 512)
  59916. */
  59917. renderWidth: number;
  59918. /**
  59919. * Render height (Default: 256)
  59920. */
  59921. renderHeight: number;
  59922. /**
  59923. * Texture size (Default: 512)
  59924. */
  59925. textureSize: number;
  59926. /**
  59927. * If delta time between frames should be constant
  59928. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  59929. */
  59930. deterministicLockstep: boolean;
  59931. /**
  59932. * Maximum about of steps between frames (Default: 4)
  59933. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  59934. */
  59935. lockstepMaxSteps: number;
  59936. /**
  59937. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  59938. */
  59939. useHighPrecisionMatrix?: boolean;
  59940. }
  59941. /**
  59942. * The null engine class provides support for headless version of babylon.js.
  59943. * This can be used in server side scenario or for testing purposes
  59944. */
  59945. export class NullEngine extends Engine {
  59946. private _options;
  59947. /**
  59948. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  59949. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  59950. * @returns true if engine is in deterministic lock step mode
  59951. */
  59952. isDeterministicLockStep(): boolean;
  59953. /**
  59954. * Gets the max steps when engine is running in deterministic lock step
  59955. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  59956. * @returns the max steps
  59957. */
  59958. getLockstepMaxSteps(): number;
  59959. /**
  59960. * Gets the current hardware scaling level.
  59961. * By default the hardware scaling level is computed from the window device ratio.
  59962. * 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.
  59963. * @returns a number indicating the current hardware scaling level
  59964. */
  59965. getHardwareScalingLevel(): number;
  59966. constructor(options?: NullEngineOptions);
  59967. /**
  59968. * Creates a vertex buffer
  59969. * @param vertices the data for the vertex buffer
  59970. * @returns the new WebGL static buffer
  59971. */
  59972. createVertexBuffer(vertices: FloatArray): DataBuffer;
  59973. /**
  59974. * Creates a new index buffer
  59975. * @param indices defines the content of the index buffer
  59976. * @param updatable defines if the index buffer must be updatable
  59977. * @returns a new webGL buffer
  59978. */
  59979. createIndexBuffer(indices: IndicesArray): DataBuffer;
  59980. /**
  59981. * Clear the current render buffer or the current render target (if any is set up)
  59982. * @param color defines the color to use
  59983. * @param backBuffer defines if the back buffer must be cleared
  59984. * @param depth defines if the depth buffer must be cleared
  59985. * @param stencil defines if the stencil buffer must be cleared
  59986. */
  59987. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  59988. /**
  59989. * Gets the current render width
  59990. * @param useScreen defines if screen size must be used (or the current render target if any)
  59991. * @returns a number defining the current render width
  59992. */
  59993. getRenderWidth(useScreen?: boolean): number;
  59994. /**
  59995. * Gets the current render height
  59996. * @param useScreen defines if screen size must be used (or the current render target if any)
  59997. * @returns a number defining the current render height
  59998. */
  59999. getRenderHeight(useScreen?: boolean): number;
  60000. /**
  60001. * Set the WebGL's viewport
  60002. * @param viewport defines the viewport element to be used
  60003. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  60004. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  60005. */
  60006. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  60007. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  60008. /**
  60009. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  60010. * @param pipelineContext defines the pipeline context to use
  60011. * @param uniformsNames defines the list of uniform names
  60012. * @returns an array of webGL uniform locations
  60013. */
  60014. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  60015. /**
  60016. * Gets the lsit of active attributes for a given webGL program
  60017. * @param pipelineContext defines the pipeline context to use
  60018. * @param attributesNames defines the list of attribute names to get
  60019. * @returns an array of indices indicating the offset of each attribute
  60020. */
  60021. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  60022. /**
  60023. * Binds an effect to the webGL context
  60024. * @param effect defines the effect to bind
  60025. */
  60026. bindSamplers(effect: Effect): void;
  60027. /**
  60028. * Activates an effect, making it the current one (ie. the one used for rendering)
  60029. * @param effect defines the effect to activate
  60030. */
  60031. enableEffect(effect: Effect): void;
  60032. /**
  60033. * Set various states to the webGL context
  60034. * @param culling defines backface culling state
  60035. * @param zOffset defines the value to apply to zOffset (0 by default)
  60036. * @param force defines if states must be applied even if cache is up to date
  60037. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  60038. */
  60039. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  60040. /**
  60041. * Set the value of an uniform to an array of int32
  60042. * @param uniform defines the webGL uniform location where to store the value
  60043. * @param array defines the array of int32 to store
  60044. * @returns true if value was set
  60045. */
  60046. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  60047. /**
  60048. * Set the value of an uniform to an array of int32 (stored as vec2)
  60049. * @param uniform defines the webGL uniform location where to store the value
  60050. * @param array defines the array of int32 to store
  60051. * @returns true if value was set
  60052. */
  60053. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  60054. /**
  60055. * Set the value of an uniform to an array of int32 (stored as vec3)
  60056. * @param uniform defines the webGL uniform location where to store the value
  60057. * @param array defines the array of int32 to store
  60058. * @returns true if value was set
  60059. */
  60060. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  60061. /**
  60062. * Set the value of an uniform to an array of int32 (stored as vec4)
  60063. * @param uniform defines the webGL uniform location where to store the value
  60064. * @param array defines the array of int32 to store
  60065. * @returns true if value was set
  60066. */
  60067. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  60068. /**
  60069. * Set the value of an uniform to an array of float32
  60070. * @param uniform defines the webGL uniform location where to store the value
  60071. * @param array defines the array of float32 to store
  60072. * @returns true if value was set
  60073. */
  60074. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  60075. /**
  60076. * Set the value of an uniform to an array of float32 (stored as vec2)
  60077. * @param uniform defines the webGL uniform location where to store the value
  60078. * @param array defines the array of float32 to store
  60079. * @returns true if value was set
  60080. */
  60081. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  60082. /**
  60083. * Set the value of an uniform to an array of float32 (stored as vec3)
  60084. * @param uniform defines the webGL uniform location where to store the value
  60085. * @param array defines the array of float32 to store
  60086. * @returns true if value was set
  60087. */
  60088. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  60089. /**
  60090. * Set the value of an uniform to an array of float32 (stored as vec4)
  60091. * @param uniform defines the webGL uniform location where to store the value
  60092. * @param array defines the array of float32 to store
  60093. * @returns true if value was set
  60094. */
  60095. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  60096. /**
  60097. * Set the value of an uniform to an array of number
  60098. * @param uniform defines the webGL uniform location where to store the value
  60099. * @param array defines the array of number to store
  60100. * @returns true if value was set
  60101. */
  60102. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  60103. /**
  60104. * Set the value of an uniform to an array of number (stored as vec2)
  60105. * @param uniform defines the webGL uniform location where to store the value
  60106. * @param array defines the array of number to store
  60107. * @returns true if value was set
  60108. */
  60109. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  60110. /**
  60111. * Set the value of an uniform to an array of number (stored as vec3)
  60112. * @param uniform defines the webGL uniform location where to store the value
  60113. * @param array defines the array of number to store
  60114. * @returns true if value was set
  60115. */
  60116. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  60117. /**
  60118. * Set the value of an uniform to an array of number (stored as vec4)
  60119. * @param uniform defines the webGL uniform location where to store the value
  60120. * @param array defines the array of number to store
  60121. * @returns true if value was set
  60122. */
  60123. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  60124. /**
  60125. * Set the value of an uniform to an array of float32 (stored as matrices)
  60126. * @param uniform defines the webGL uniform location where to store the value
  60127. * @param matrices defines the array of float32 to store
  60128. * @returns true if value was set
  60129. */
  60130. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  60131. /**
  60132. * Set the value of an uniform to a matrix (3x3)
  60133. * @param uniform defines the webGL uniform location where to store the value
  60134. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  60135. * @returns true if value was set
  60136. */
  60137. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  60138. /**
  60139. * Set the value of an uniform to a matrix (2x2)
  60140. * @param uniform defines the webGL uniform location where to store the value
  60141. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  60142. * @returns true if value was set
  60143. */
  60144. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  60145. /**
  60146. * Set the value of an uniform to a number (float)
  60147. * @param uniform defines the webGL uniform location where to store the value
  60148. * @param value defines the float number to store
  60149. * @returns true if value was set
  60150. */
  60151. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  60152. /**
  60153. * Set the value of an uniform to a vec2
  60154. * @param uniform defines the webGL uniform location where to store the value
  60155. * @param x defines the 1st component of the value
  60156. * @param y defines the 2nd component of the value
  60157. * @returns true if value was set
  60158. */
  60159. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  60160. /**
  60161. * Set the value of an uniform to a vec3
  60162. * @param uniform defines the webGL uniform location where to store the value
  60163. * @param x defines the 1st component of the value
  60164. * @param y defines the 2nd component of the value
  60165. * @param z defines the 3rd component of the value
  60166. * @returns true if value was set
  60167. */
  60168. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  60169. /**
  60170. * Set the value of an uniform to a boolean
  60171. * @param uniform defines the webGL uniform location where to store the value
  60172. * @param bool defines the boolean to store
  60173. * @returns true if value was set
  60174. */
  60175. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  60176. /**
  60177. * Set the value of an uniform to a vec4
  60178. * @param uniform defines the webGL uniform location where to store the value
  60179. * @param x defines the 1st component of the value
  60180. * @param y defines the 2nd component of the value
  60181. * @param z defines the 3rd component of the value
  60182. * @param w defines the 4th component of the value
  60183. * @returns true if value was set
  60184. */
  60185. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  60186. /**
  60187. * Sets the current alpha mode
  60188. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  60189. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  60190. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  60191. */
  60192. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  60193. /**
  60194. * Bind webGl buffers directly to the webGL context
  60195. * @param vertexBuffers defines the vertex buffer to bind
  60196. * @param indexBuffer defines the index buffer to bind
  60197. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  60198. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  60199. * @param effect defines the effect associated with the vertex buffer
  60200. */
  60201. bindBuffers(vertexBuffers: {
  60202. [key: string]: VertexBuffer;
  60203. }, indexBuffer: DataBuffer, effect: Effect): void;
  60204. /**
  60205. * Force the entire cache to be cleared
  60206. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  60207. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  60208. */
  60209. wipeCaches(bruteForce?: boolean): void;
  60210. /**
  60211. * Send a draw order
  60212. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  60213. * @param indexStart defines the starting index
  60214. * @param indexCount defines the number of index to draw
  60215. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  60216. */
  60217. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  60218. /**
  60219. * Draw a list of indexed primitives
  60220. * @param fillMode defines the primitive to use
  60221. * @param indexStart defines the starting index
  60222. * @param indexCount defines the number of index to draw
  60223. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  60224. */
  60225. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  60226. /**
  60227. * Draw a list of unindexed primitives
  60228. * @param fillMode defines the primitive to use
  60229. * @param verticesStart defines the index of first vertex to draw
  60230. * @param verticesCount defines the count of vertices to draw
  60231. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  60232. */
  60233. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  60234. /** @hidden */
  60235. protected _createTexture(): WebGLTexture;
  60236. /** @hidden */
  60237. _releaseTexture(texture: InternalTexture): void;
  60238. /**
  60239. * Usually called from Texture.ts.
  60240. * Passed information to create a WebGLTexture
  60241. * @param urlArg defines a value which contains one of the following:
  60242. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  60243. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  60244. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  60245. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  60246. * @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)
  60247. * @param scene needed for loading to the correct scene
  60248. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  60249. * @param onLoad optional callback to be called upon successful completion
  60250. * @param onError optional callback to be called upon failure
  60251. * @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
  60252. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  60253. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  60254. * @param forcedExtension defines the extension to use to pick the right loader
  60255. * @param mimeType defines an optional mime type
  60256. * @returns a InternalTexture for assignment back into BABYLON.Texture
  60257. */
  60258. 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;
  60259. /**
  60260. * Creates a new render target texture
  60261. * @param size defines the size of the texture
  60262. * @param options defines the options used to create the texture
  60263. * @returns a new render target texture stored in an InternalTexture
  60264. */
  60265. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  60266. /**
  60267. * Update the sampling mode of a given texture
  60268. * @param samplingMode defines the required sampling mode
  60269. * @param texture defines the texture to update
  60270. */
  60271. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  60272. /**
  60273. * Binds the frame buffer to the specified texture.
  60274. * @param texture The texture to render to or null for the default canvas
  60275. * @param faceIndex The face of the texture to render to in case of cube texture
  60276. * @param requiredWidth The width of the target to render to
  60277. * @param requiredHeight The height of the target to render to
  60278. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  60279. * @param lodLevel defines le lod level to bind to the frame buffer
  60280. */
  60281. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  60282. /**
  60283. * Unbind the current render target texture from the webGL context
  60284. * @param texture defines the render target texture to unbind
  60285. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  60286. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  60287. */
  60288. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  60289. /**
  60290. * Creates a dynamic vertex buffer
  60291. * @param vertices the data for the dynamic vertex buffer
  60292. * @returns the new WebGL dynamic buffer
  60293. */
  60294. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  60295. /**
  60296. * Update the content of a dynamic texture
  60297. * @param texture defines the texture to update
  60298. * @param canvas defines the canvas containing the source
  60299. * @param invertY defines if data must be stored with Y axis inverted
  60300. * @param premulAlpha defines if alpha is stored as premultiplied
  60301. * @param format defines the format of the data
  60302. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  60303. */
  60304. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  60305. /**
  60306. * Gets a boolean indicating if all created effects are ready
  60307. * @returns true if all effects are ready
  60308. */
  60309. areAllEffectsReady(): boolean;
  60310. /**
  60311. * @hidden
  60312. * Get the current error code of the webGL context
  60313. * @returns the error code
  60314. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  60315. */
  60316. getError(): number;
  60317. /** @hidden */
  60318. _getUnpackAlignement(): number;
  60319. /** @hidden */
  60320. _unpackFlipY(value: boolean): void;
  60321. /**
  60322. * Update a dynamic index buffer
  60323. * @param indexBuffer defines the target index buffer
  60324. * @param indices defines the data to update
  60325. * @param offset defines the offset in the target index buffer where update should start
  60326. */
  60327. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  60328. /**
  60329. * Updates a dynamic vertex buffer.
  60330. * @param vertexBuffer the vertex buffer to update
  60331. * @param vertices the data used to update the vertex buffer
  60332. * @param byteOffset the byte offset of the data (optional)
  60333. * @param byteLength the byte length of the data (optional)
  60334. */
  60335. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  60336. /** @hidden */
  60337. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  60338. /** @hidden */
  60339. _bindTexture(channel: number, texture: InternalTexture): void;
  60340. protected _deleteBuffer(buffer: WebGLBuffer): void;
  60341. /**
  60342. * 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
  60343. */
  60344. releaseEffects(): void;
  60345. displayLoadingUI(): void;
  60346. hideLoadingUI(): void;
  60347. /** @hidden */
  60348. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  60349. /** @hidden */
  60350. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  60351. /** @hidden */
  60352. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  60353. /** @hidden */
  60354. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  60355. }
  60356. }
  60357. declare module BABYLON {
  60358. /** @hidden */
  60359. export class _OcclusionDataStorage {
  60360. /** @hidden */
  60361. occlusionInternalRetryCounter: number;
  60362. /** @hidden */
  60363. isOcclusionQueryInProgress: boolean;
  60364. /** @hidden */
  60365. isOccluded: boolean;
  60366. /** @hidden */
  60367. occlusionRetryCount: number;
  60368. /** @hidden */
  60369. occlusionType: number;
  60370. /** @hidden */
  60371. occlusionQueryAlgorithmType: number;
  60372. }
  60373. interface Engine {
  60374. /**
  60375. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  60376. * @return the new query
  60377. */
  60378. createQuery(): WebGLQuery;
  60379. /**
  60380. * Delete and release a webGL query
  60381. * @param query defines the query to delete
  60382. * @return the current engine
  60383. */
  60384. deleteQuery(query: WebGLQuery): Engine;
  60385. /**
  60386. * Check if a given query has resolved and got its value
  60387. * @param query defines the query to check
  60388. * @returns true if the query got its value
  60389. */
  60390. isQueryResultAvailable(query: WebGLQuery): boolean;
  60391. /**
  60392. * Gets the value of a given query
  60393. * @param query defines the query to check
  60394. * @returns the value of the query
  60395. */
  60396. getQueryResult(query: WebGLQuery): number;
  60397. /**
  60398. * Initiates an occlusion query
  60399. * @param algorithmType defines the algorithm to use
  60400. * @param query defines the query to use
  60401. * @returns the current engine
  60402. * @see https://doc.babylonjs.com/features/occlusionquery
  60403. */
  60404. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  60405. /**
  60406. * Ends an occlusion query
  60407. * @see https://doc.babylonjs.com/features/occlusionquery
  60408. * @param algorithmType defines the algorithm to use
  60409. * @returns the current engine
  60410. */
  60411. endOcclusionQuery(algorithmType: number): Engine;
  60412. /**
  60413. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  60414. * Please note that only one query can be issued at a time
  60415. * @returns a time token used to track the time span
  60416. */
  60417. startTimeQuery(): Nullable<_TimeToken>;
  60418. /**
  60419. * Ends a time query
  60420. * @param token defines the token used to measure the time span
  60421. * @returns the time spent (in ns)
  60422. */
  60423. endTimeQuery(token: _TimeToken): int;
  60424. /** @hidden */
  60425. _currentNonTimestampToken: Nullable<_TimeToken>;
  60426. /** @hidden */
  60427. _createTimeQuery(): WebGLQuery;
  60428. /** @hidden */
  60429. _deleteTimeQuery(query: WebGLQuery): void;
  60430. /** @hidden */
  60431. _getGlAlgorithmType(algorithmType: number): number;
  60432. /** @hidden */
  60433. _getTimeQueryResult(query: WebGLQuery): any;
  60434. /** @hidden */
  60435. _getTimeQueryAvailability(query: WebGLQuery): any;
  60436. }
  60437. interface AbstractMesh {
  60438. /**
  60439. * Backing filed
  60440. * @hidden
  60441. */
  60442. __occlusionDataStorage: _OcclusionDataStorage;
  60443. /**
  60444. * Access property
  60445. * @hidden
  60446. */
  60447. _occlusionDataStorage: _OcclusionDataStorage;
  60448. /**
  60449. * 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.
  60450. * The default value is -1 which means don't break the query and wait till the result
  60451. * @see https://doc.babylonjs.com/features/occlusionquery
  60452. */
  60453. occlusionRetryCount: number;
  60454. /**
  60455. * 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:
  60456. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query within the Mesh.
  60457. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  60458. * * 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.
  60459. * @see https://doc.babylonjs.com/features/occlusionquery
  60460. */
  60461. occlusionType: number;
  60462. /**
  60463. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  60464. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  60465. * * 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.
  60466. * @see https://doc.babylonjs.com/features/occlusionquery
  60467. */
  60468. occlusionQueryAlgorithmType: number;
  60469. /**
  60470. * 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
  60471. * @see https://doc.babylonjs.com/features/occlusionquery
  60472. */
  60473. isOccluded: boolean;
  60474. /**
  60475. * Flag to check the progress status of the query
  60476. * @see https://doc.babylonjs.com/features/occlusionquery
  60477. */
  60478. isOcclusionQueryInProgress: boolean;
  60479. }
  60480. }
  60481. declare module BABYLON {
  60482. /** @hidden */
  60483. export var _forceTransformFeedbackToBundle: boolean;
  60484. interface Engine {
  60485. /**
  60486. * Creates a webGL transform feedback object
  60487. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  60488. * @returns the webGL transform feedback object
  60489. */
  60490. createTransformFeedback(): WebGLTransformFeedback;
  60491. /**
  60492. * Delete a webGL transform feedback object
  60493. * @param value defines the webGL transform feedback object to delete
  60494. */
  60495. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  60496. /**
  60497. * Bind a webGL transform feedback object to the webgl context
  60498. * @param value defines the webGL transform feedback object to bind
  60499. */
  60500. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  60501. /**
  60502. * Begins a transform feedback operation
  60503. * @param usePoints defines if points or triangles must be used
  60504. */
  60505. beginTransformFeedback(usePoints: boolean): void;
  60506. /**
  60507. * Ends a transform feedback operation
  60508. */
  60509. endTransformFeedback(): void;
  60510. /**
  60511. * Specify the varyings to use with transform feedback
  60512. * @param program defines the associated webGL program
  60513. * @param value defines the list of strings representing the varying names
  60514. */
  60515. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  60516. /**
  60517. * Bind a webGL buffer for a transform feedback operation
  60518. * @param value defines the webGL buffer to bind
  60519. */
  60520. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  60521. }
  60522. }
  60523. declare module BABYLON {
  60524. /**
  60525. * Class used to define an additional view for the engine
  60526. * @see https://doc.babylonjs.com/how_to/multi_canvases
  60527. */
  60528. export class EngineView {
  60529. /** Defines the canvas where to render the view */
  60530. target: HTMLCanvasElement;
  60531. /** Defines an optional camera used to render the view (will use active camera else) */
  60532. camera?: Camera;
  60533. }
  60534. interface Engine {
  60535. /**
  60536. * Gets or sets the HTML element to use for attaching events
  60537. */
  60538. inputElement: Nullable<HTMLElement>;
  60539. /**
  60540. * Gets the current engine view
  60541. * @see https://doc.babylonjs.com/how_to/multi_canvases
  60542. */
  60543. activeView: Nullable<EngineView>;
  60544. /** Gets or sets the list of views */
  60545. views: EngineView[];
  60546. /**
  60547. * Register a new child canvas
  60548. * @param canvas defines the canvas to register
  60549. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  60550. * @returns the associated view
  60551. */
  60552. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  60553. /**
  60554. * Remove a registered child canvas
  60555. * @param canvas defines the canvas to remove
  60556. * @returns the current engine
  60557. */
  60558. unRegisterView(canvas: HTMLCanvasElement): Engine;
  60559. }
  60560. }
  60561. declare module BABYLON {
  60562. interface Engine {
  60563. /** @hidden */
  60564. _excludedCompressedTextures: string[];
  60565. /** @hidden */
  60566. _textureFormatInUse: string;
  60567. /**
  60568. * Gets the list of texture formats supported
  60569. */
  60570. readonly texturesSupported: Array<string>;
  60571. /**
  60572. * Gets the texture format in use
  60573. */
  60574. readonly textureFormatInUse: Nullable<string>;
  60575. /**
  60576. * Set the compressed texture extensions or file names to skip.
  60577. *
  60578. * @param skippedFiles defines the list of those texture files you want to skip
  60579. * Example: [".dds", ".env", "myfile.png"]
  60580. */
  60581. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  60582. /**
  60583. * Set the compressed texture format to use, based on the formats you have, and the formats
  60584. * supported by the hardware / browser.
  60585. *
  60586. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  60587. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  60588. * to API arguments needed to compressed textures. This puts the burden on the container
  60589. * generator to house the arcane code for determining these for current & future formats.
  60590. *
  60591. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  60592. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  60593. *
  60594. * Note: The result of this call is not taken into account when a texture is base64.
  60595. *
  60596. * @param formatsAvailable defines the list of those format families you have created
  60597. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  60598. *
  60599. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  60600. * @returns The extension selected.
  60601. */
  60602. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  60603. }
  60604. }
  60605. declare module BABYLON {
  60606. /** @hidden */
  60607. export var rgbdEncodePixelShader: {
  60608. name: string;
  60609. shader: string;
  60610. };
  60611. }
  60612. declare module BABYLON {
  60613. /**
  60614. * Raw texture data and descriptor sufficient for WebGL texture upload
  60615. */
  60616. export interface EnvironmentTextureInfo {
  60617. /**
  60618. * Version of the environment map
  60619. */
  60620. version: number;
  60621. /**
  60622. * Width of image
  60623. */
  60624. width: number;
  60625. /**
  60626. * Irradiance information stored in the file.
  60627. */
  60628. irradiance: any;
  60629. /**
  60630. * Specular information stored in the file.
  60631. */
  60632. specular: any;
  60633. }
  60634. /**
  60635. * Defines One Image in the file. It requires only the position in the file
  60636. * as well as the length.
  60637. */
  60638. interface BufferImageData {
  60639. /**
  60640. * Length of the image data.
  60641. */
  60642. length: number;
  60643. /**
  60644. * Position of the data from the null terminator delimiting the end of the JSON.
  60645. */
  60646. position: number;
  60647. }
  60648. /**
  60649. * Defines the specular data enclosed in the file.
  60650. * This corresponds to the version 1 of the data.
  60651. */
  60652. export interface EnvironmentTextureSpecularInfoV1 {
  60653. /**
  60654. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  60655. */
  60656. specularDataPosition?: number;
  60657. /**
  60658. * This contains all the images data needed to reconstruct the cubemap.
  60659. */
  60660. mipmaps: Array<BufferImageData>;
  60661. /**
  60662. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  60663. */
  60664. lodGenerationScale: number;
  60665. }
  60666. /**
  60667. * Sets of helpers addressing the serialization and deserialization of environment texture
  60668. * stored in a BabylonJS env file.
  60669. * Those files are usually stored as .env files.
  60670. */
  60671. export class EnvironmentTextureTools {
  60672. /**
  60673. * Magic number identifying the env file.
  60674. */
  60675. private static _MagicBytes;
  60676. /**
  60677. * Gets the environment info from an env file.
  60678. * @param data The array buffer containing the .env bytes.
  60679. * @returns the environment file info (the json header) if successfully parsed.
  60680. */
  60681. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  60682. /**
  60683. * Creates an environment texture from a loaded cube texture.
  60684. * @param texture defines the cube texture to convert in env file
  60685. * @return a promise containing the environment data if successful.
  60686. */
  60687. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  60688. /**
  60689. * Creates a JSON representation of the spherical data.
  60690. * @param texture defines the texture containing the polynomials
  60691. * @return the JSON representation of the spherical info
  60692. */
  60693. private static _CreateEnvTextureIrradiance;
  60694. /**
  60695. * Creates the ArrayBufferViews used for initializing environment texture image data.
  60696. * @param data the image data
  60697. * @param info parameters that determine what views will be created for accessing the underlying buffer
  60698. * @return the views described by info providing access to the underlying buffer
  60699. */
  60700. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  60701. /**
  60702. * Uploads the texture info contained in the env file to the GPU.
  60703. * @param texture defines the internal texture to upload to
  60704. * @param data defines the data to load
  60705. * @param info defines the texture info retrieved through the GetEnvInfo method
  60706. * @returns a promise
  60707. */
  60708. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  60709. private static _OnImageReadyAsync;
  60710. /**
  60711. * Uploads the levels of image data to the GPU.
  60712. * @param texture defines the internal texture to upload to
  60713. * @param imageData defines the array buffer views of image data [mipmap][face]
  60714. * @returns a promise
  60715. */
  60716. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  60717. /**
  60718. * Uploads spherical polynomials information to the texture.
  60719. * @param texture defines the texture we are trying to upload the information to
  60720. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  60721. */
  60722. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  60723. /** @hidden */
  60724. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  60725. }
  60726. }
  60727. declare module BABYLON {
  60728. /**
  60729. * Container for accessors for natively-stored mesh data buffers.
  60730. */
  60731. class NativeDataBuffer extends DataBuffer {
  60732. /**
  60733. * Accessor value used to identify/retrieve a natively-stored index buffer.
  60734. */
  60735. nativeIndexBuffer?: any;
  60736. /**
  60737. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  60738. */
  60739. nativeVertexBuffer?: any;
  60740. }
  60741. /** @hidden */
  60742. class NativeTexture extends InternalTexture {
  60743. getInternalTexture(): InternalTexture;
  60744. getViewCount(): number;
  60745. }
  60746. /** @hidden */
  60747. export class NativeEngine extends Engine {
  60748. private readonly _native;
  60749. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  60750. private readonly INVALID_HANDLE;
  60751. private _boundBuffersVertexArray;
  60752. private _currentDepthTest;
  60753. getHardwareScalingLevel(): number;
  60754. constructor();
  60755. dispose(): void;
  60756. /**
  60757. * Can be used to override the current requestAnimationFrame requester.
  60758. * @hidden
  60759. */
  60760. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  60761. /**
  60762. * Override default engine behavior.
  60763. * @param color
  60764. * @param backBuffer
  60765. * @param depth
  60766. * @param stencil
  60767. */
  60768. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  60769. /**
  60770. * Gets host document
  60771. * @returns the host document object
  60772. */
  60773. getHostDocument(): Nullable<Document>;
  60774. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  60775. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  60776. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  60777. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  60778. [key: string]: VertexBuffer;
  60779. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  60780. bindBuffers(vertexBuffers: {
  60781. [key: string]: VertexBuffer;
  60782. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  60783. recordVertexArrayObject(vertexBuffers: {
  60784. [key: string]: VertexBuffer;
  60785. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  60786. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  60787. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  60788. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  60789. /**
  60790. * Draw a list of indexed primitives
  60791. * @param fillMode defines the primitive to use
  60792. * @param indexStart defines the starting index
  60793. * @param indexCount defines the number of index to draw
  60794. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  60795. */
  60796. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  60797. /**
  60798. * Draw a list of unindexed primitives
  60799. * @param fillMode defines the primitive to use
  60800. * @param verticesStart defines the index of first vertex to draw
  60801. * @param verticesCount defines the count of vertices to draw
  60802. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  60803. */
  60804. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  60805. createPipelineContext(): IPipelineContext;
  60806. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  60807. /** @hidden */
  60808. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  60809. /** @hidden */
  60810. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  60811. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  60812. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  60813. protected _setProgram(program: WebGLProgram): void;
  60814. _releaseEffect(effect: Effect): void;
  60815. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  60816. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  60817. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  60818. bindSamplers(effect: Effect): void;
  60819. setMatrix(uniform: WebGLUniformLocation, matrix: IMatrixLike): void;
  60820. getRenderWidth(useScreen?: boolean): number;
  60821. getRenderHeight(useScreen?: boolean): number;
  60822. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  60823. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  60824. /**
  60825. * Gets the client rect of native canvas. Needed for InputManager.
  60826. * @returns a client rectangle
  60827. */
  60828. getInputElementClientRect(): Nullable<ClientRect>;
  60829. /**
  60830. * Set the z offset to apply to current rendering
  60831. * @param value defines the offset to apply
  60832. */
  60833. setZOffset(value: number): void;
  60834. /**
  60835. * Gets the current value of the zOffset
  60836. * @returns the current zOffset state
  60837. */
  60838. getZOffset(): number;
  60839. /**
  60840. * Enable or disable depth buffering
  60841. * @param enable defines the state to set
  60842. */
  60843. setDepthBuffer(enable: boolean): void;
  60844. /**
  60845. * Gets a boolean indicating if depth writing is enabled
  60846. * @returns the current depth writing state
  60847. */
  60848. getDepthWrite(): boolean;
  60849. setDepthFunctionToGreater(): void;
  60850. setDepthFunctionToGreaterOrEqual(): void;
  60851. setDepthFunctionToLess(): void;
  60852. setDepthFunctionToLessOrEqual(): void;
  60853. /**
  60854. * Enable or disable depth writing
  60855. * @param enable defines the state to set
  60856. */
  60857. setDepthWrite(enable: boolean): void;
  60858. /**
  60859. * Enable or disable color writing
  60860. * @param enable defines the state to set
  60861. */
  60862. setColorWrite(enable: boolean): void;
  60863. /**
  60864. * Gets a boolean indicating if color writing is enabled
  60865. * @returns the current color writing state
  60866. */
  60867. getColorWrite(): boolean;
  60868. /**
  60869. * Sets alpha constants used by some alpha blending modes
  60870. * @param r defines the red component
  60871. * @param g defines the green component
  60872. * @param b defines the blue component
  60873. * @param a defines the alpha component
  60874. */
  60875. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  60876. /**
  60877. * Sets the current alpha mode
  60878. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  60879. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  60880. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  60881. */
  60882. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  60883. /**
  60884. * Gets the current alpha mode
  60885. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  60886. * @returns the current alpha mode
  60887. */
  60888. getAlphaMode(): number;
  60889. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  60890. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  60891. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  60892. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  60893. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  60894. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  60895. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  60896. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  60897. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  60898. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  60899. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  60900. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  60901. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  60902. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  60903. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  60904. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  60905. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  60906. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  60907. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  60908. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  60909. setColor3(uniform: WebGLUniformLocation, color3: IColor3Like): boolean;
  60910. setColor4(uniform: WebGLUniformLocation, color3: IColor3Like, alpha: number): boolean;
  60911. wipeCaches(bruteForce?: boolean): void;
  60912. protected _createTexture(): WebGLTexture;
  60913. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  60914. /**
  60915. * Update the content of a dynamic texture
  60916. * @param texture defines the texture to update
  60917. * @param canvas defines the canvas containing the source
  60918. * @param invertY defines if data must be stored with Y axis inverted
  60919. * @param premulAlpha defines if alpha is stored as premultiplied
  60920. * @param format defines the format of the data
  60921. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  60922. */
  60923. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  60924. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  60925. updateRawTexture(texture: Nullable<InternalTexture>, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  60926. /**
  60927. * Usually called from Texture.ts.
  60928. * Passed information to create a WebGLTexture
  60929. * @param url defines a value which contains one of the following:
  60930. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  60931. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  60932. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  60933. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  60934. * @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)
  60935. * @param scene needed for loading to the correct scene
  60936. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  60937. * @param onLoad optional callback to be called upon successful completion
  60938. * @param onError optional callback to be called upon failure
  60939. * @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
  60940. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  60941. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  60942. * @param forcedExtension defines the extension to use to pick the right loader
  60943. * @param mimeType defines an optional mime type
  60944. * @param loaderOptions options to be passed to the loader
  60945. * @returns a InternalTexture for assignment back into BABYLON.Texture
  60946. */
  60947. 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;
  60948. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  60949. _releaseFramebufferObjects(texture: InternalTexture): void;
  60950. /**
  60951. * Creates a cube texture
  60952. * @param rootUrl defines the url where the files to load is located
  60953. * @param scene defines the current scene
  60954. * @param files defines the list of files to load (1 per face)
  60955. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  60956. * @param onLoad defines an optional callback raised when the texture is loaded
  60957. * @param onError defines an optional callback raised if there is an issue to load the texture
  60958. * @param format defines the format of the data
  60959. * @param forcedExtension defines the extension to use to pick the right loader
  60960. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  60961. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  60962. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  60963. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  60964. * @returns the cube texture as an InternalTexture
  60965. */
  60966. 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;
  60967. createRenderTargetTexture(size: number | {
  60968. width: number;
  60969. height: number;
  60970. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  60971. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  60972. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  60973. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  60974. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  60975. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  60976. /**
  60977. * Updates a dynamic vertex buffer.
  60978. * @param vertexBuffer the vertex buffer to update
  60979. * @param data the data used to update the vertex buffer
  60980. * @param byteOffset the byte offset of the data (optional)
  60981. * @param byteLength the byte length of the data (optional)
  60982. */
  60983. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  60984. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  60985. private _updateAnisotropicLevel;
  60986. private _getAddressMode;
  60987. /** @hidden */
  60988. _bindTexture(channel: number, texture: InternalTexture): void;
  60989. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  60990. releaseEffects(): void;
  60991. /** @hidden */
  60992. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  60993. /** @hidden */
  60994. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  60995. /** @hidden */
  60996. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  60997. /** @hidden */
  60998. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  60999. private _getNativeSamplingMode;
  61000. private _getNativeTextureFormat;
  61001. private _getNativeAlphaMode;
  61002. private _getNativeAttribType;
  61003. }
  61004. }
  61005. declare module BABYLON {
  61006. /**
  61007. * Helper class to create the best engine depending on the current hardware
  61008. */
  61009. export class EngineFactory {
  61010. /**
  61011. * Creates an engine based on the capabilities of the underlying hardware
  61012. * @param canvas Defines the canvas to use to display the result
  61013. * @param options Defines the options passed to the engine to create the context dependencies
  61014. * @returns a promise that resolves with the created engine
  61015. */
  61016. static CreateAsync(canvas: HTMLCanvasElement, options: any): Promise<ThinEngine>;
  61017. }
  61018. }
  61019. declare module BABYLON {
  61020. /**
  61021. * Gather the list of clipboard event types as constants.
  61022. */
  61023. export class ClipboardEventTypes {
  61024. /**
  61025. * The clipboard event is fired when a copy command is active (pressed).
  61026. */
  61027. static readonly COPY: number;
  61028. /**
  61029. * The clipboard event is fired when a cut command is active (pressed).
  61030. */
  61031. static readonly CUT: number;
  61032. /**
  61033. * The clipboard event is fired when a paste command is active (pressed).
  61034. */
  61035. static readonly PASTE: number;
  61036. }
  61037. /**
  61038. * This class is used to store clipboard related info for the onClipboardObservable event.
  61039. */
  61040. export class ClipboardInfo {
  61041. /**
  61042. * Defines the type of event (BABYLON.ClipboardEventTypes)
  61043. */
  61044. type: number;
  61045. /**
  61046. * Defines the related dom event
  61047. */
  61048. event: ClipboardEvent;
  61049. /**
  61050. *Creates an instance of ClipboardInfo.
  61051. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  61052. * @param event Defines the related dom event
  61053. */
  61054. constructor(
  61055. /**
  61056. * Defines the type of event (BABYLON.ClipboardEventTypes)
  61057. */
  61058. type: number,
  61059. /**
  61060. * Defines the related dom event
  61061. */
  61062. event: ClipboardEvent);
  61063. /**
  61064. * Get the clipboard event's type from the keycode.
  61065. * @param keyCode Defines the keyCode for the current keyboard event.
  61066. * @return {number}
  61067. */
  61068. static GetTypeFromCharacter(keyCode: number): number;
  61069. }
  61070. }
  61071. declare module BABYLON {
  61072. /**
  61073. * Google Daydream controller
  61074. */
  61075. export class DaydreamController extends WebVRController {
  61076. /**
  61077. * Base Url for the controller model.
  61078. */
  61079. static MODEL_BASE_URL: string;
  61080. /**
  61081. * File name for the controller model.
  61082. */
  61083. static MODEL_FILENAME: string;
  61084. /**
  61085. * Gamepad Id prefix used to identify Daydream Controller.
  61086. */
  61087. static readonly GAMEPAD_ID_PREFIX: string;
  61088. /**
  61089. * Creates a new DaydreamController from a gamepad
  61090. * @param vrGamepad the gamepad that the controller should be created from
  61091. */
  61092. constructor(vrGamepad: any);
  61093. /**
  61094. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  61095. * @param scene scene in which to add meshes
  61096. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  61097. */
  61098. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  61099. /**
  61100. * Called once for each button that changed state since the last frame
  61101. * @param buttonIdx Which button index changed
  61102. * @param state New state of the button
  61103. * @param changes Which properties on the state changed since last frame
  61104. */
  61105. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  61106. }
  61107. }
  61108. declare module BABYLON {
  61109. /**
  61110. * Gear VR Controller
  61111. */
  61112. export class GearVRController extends WebVRController {
  61113. /**
  61114. * Base Url for the controller model.
  61115. */
  61116. static MODEL_BASE_URL: string;
  61117. /**
  61118. * File name for the controller model.
  61119. */
  61120. static MODEL_FILENAME: string;
  61121. /**
  61122. * Gamepad Id prefix used to identify this controller.
  61123. */
  61124. static readonly GAMEPAD_ID_PREFIX: string;
  61125. private readonly _buttonIndexToObservableNameMap;
  61126. /**
  61127. * Creates a new GearVRController from a gamepad
  61128. * @param vrGamepad the gamepad that the controller should be created from
  61129. */
  61130. constructor(vrGamepad: any);
  61131. /**
  61132. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  61133. * @param scene scene in which to add meshes
  61134. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  61135. */
  61136. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  61137. /**
  61138. * Called once for each button that changed state since the last frame
  61139. * @param buttonIdx Which button index changed
  61140. * @param state New state of the button
  61141. * @param changes Which properties on the state changed since last frame
  61142. */
  61143. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  61144. }
  61145. }
  61146. declare module BABYLON {
  61147. /**
  61148. * Generic Controller
  61149. */
  61150. export class GenericController extends WebVRController {
  61151. /**
  61152. * Base Url for the controller model.
  61153. */
  61154. static readonly MODEL_BASE_URL: string;
  61155. /**
  61156. * File name for the controller model.
  61157. */
  61158. static readonly MODEL_FILENAME: string;
  61159. /**
  61160. * Creates a new GenericController from a gamepad
  61161. * @param vrGamepad the gamepad that the controller should be created from
  61162. */
  61163. constructor(vrGamepad: any);
  61164. /**
  61165. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  61166. * @param scene scene in which to add meshes
  61167. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  61168. */
  61169. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  61170. /**
  61171. * Called once for each button that changed state since the last frame
  61172. * @param buttonIdx Which button index changed
  61173. * @param state New state of the button
  61174. * @param changes Which properties on the state changed since last frame
  61175. */
  61176. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  61177. }
  61178. }
  61179. declare module BABYLON {
  61180. /**
  61181. * Oculus Touch Controller
  61182. */
  61183. export class OculusTouchController extends WebVRController {
  61184. /**
  61185. * Base Url for the controller model.
  61186. */
  61187. static MODEL_BASE_URL: string;
  61188. /**
  61189. * File name for the left controller model.
  61190. */
  61191. static MODEL_LEFT_FILENAME: string;
  61192. /**
  61193. * File name for the right controller model.
  61194. */
  61195. static MODEL_RIGHT_FILENAME: string;
  61196. /**
  61197. * Base Url for the Quest controller model.
  61198. */
  61199. static QUEST_MODEL_BASE_URL: string;
  61200. /**
  61201. * @hidden
  61202. * If the controllers are running on a device that needs the updated Quest controller models
  61203. */
  61204. static _IsQuest: boolean;
  61205. /**
  61206. * Fired when the secondary trigger on this controller is modified
  61207. */
  61208. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  61209. /**
  61210. * Fired when the thumb rest on this controller is modified
  61211. */
  61212. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  61213. /**
  61214. * Creates a new OculusTouchController from a gamepad
  61215. * @param vrGamepad the gamepad that the controller should be created from
  61216. */
  61217. constructor(vrGamepad: any);
  61218. /**
  61219. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  61220. * @param scene scene in which to add meshes
  61221. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  61222. */
  61223. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  61224. /**
  61225. * Fired when the A button on this controller is modified
  61226. */
  61227. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  61228. /**
  61229. * Fired when the B button on this controller is modified
  61230. */
  61231. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  61232. /**
  61233. * Fired when the X button on this controller is modified
  61234. */
  61235. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  61236. /**
  61237. * Fired when the Y button on this controller is modified
  61238. */
  61239. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  61240. /**
  61241. * Called once for each button that changed state since the last frame
  61242. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  61243. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  61244. * 2) secondary trigger (same)
  61245. * 3) A (right) X (left), touch, pressed = value
  61246. * 4) B / Y
  61247. * 5) thumb rest
  61248. * @param buttonIdx Which button index changed
  61249. * @param state New state of the button
  61250. * @param changes Which properties on the state changed since last frame
  61251. */
  61252. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  61253. }
  61254. }
  61255. declare module BABYLON {
  61256. /**
  61257. * Vive Controller
  61258. */
  61259. export class ViveController extends WebVRController {
  61260. /**
  61261. * Base Url for the controller model.
  61262. */
  61263. static MODEL_BASE_URL: string;
  61264. /**
  61265. * File name for the controller model.
  61266. */
  61267. static MODEL_FILENAME: string;
  61268. /**
  61269. * Creates a new ViveController from a gamepad
  61270. * @param vrGamepad the gamepad that the controller should be created from
  61271. */
  61272. constructor(vrGamepad: any);
  61273. /**
  61274. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  61275. * @param scene scene in which to add meshes
  61276. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  61277. */
  61278. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  61279. /**
  61280. * Fired when the left button on this controller is modified
  61281. */
  61282. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  61283. /**
  61284. * Fired when the right button on this controller is modified
  61285. */
  61286. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  61287. /**
  61288. * Fired when the menu button on this controller is modified
  61289. */
  61290. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  61291. /**
  61292. * Called once for each button that changed state since the last frame
  61293. * Vive mapping:
  61294. * 0: touchpad
  61295. * 1: trigger
  61296. * 2: left AND right buttons
  61297. * 3: menu button
  61298. * @param buttonIdx Which button index changed
  61299. * @param state New state of the button
  61300. * @param changes Which properties on the state changed since last frame
  61301. */
  61302. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  61303. }
  61304. }
  61305. declare module BABYLON {
  61306. /**
  61307. * Defines the WindowsMotionController object that the state of the windows motion controller
  61308. */
  61309. export class WindowsMotionController extends WebVRController {
  61310. /**
  61311. * The base url used to load the left and right controller models
  61312. */
  61313. static MODEL_BASE_URL: string;
  61314. /**
  61315. * The name of the left controller model file
  61316. */
  61317. static MODEL_LEFT_FILENAME: string;
  61318. /**
  61319. * The name of the right controller model file
  61320. */
  61321. static MODEL_RIGHT_FILENAME: string;
  61322. /**
  61323. * The controller name prefix for this controller type
  61324. */
  61325. static readonly GAMEPAD_ID_PREFIX: string;
  61326. /**
  61327. * The controller id pattern for this controller type
  61328. */
  61329. private static readonly GAMEPAD_ID_PATTERN;
  61330. private _loadedMeshInfo;
  61331. protected readonly _mapping: {
  61332. buttons: string[];
  61333. buttonMeshNames: {
  61334. trigger: string;
  61335. menu: string;
  61336. grip: string;
  61337. thumbstick: string;
  61338. trackpad: string;
  61339. };
  61340. buttonObservableNames: {
  61341. trigger: string;
  61342. menu: string;
  61343. grip: string;
  61344. thumbstick: string;
  61345. trackpad: string;
  61346. };
  61347. axisMeshNames: string[];
  61348. pointingPoseMeshName: string;
  61349. };
  61350. /**
  61351. * Fired when the trackpad on this controller is clicked
  61352. */
  61353. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  61354. /**
  61355. * Fired when the trackpad on this controller is modified
  61356. */
  61357. onTrackpadValuesChangedObservable: Observable<StickValues>;
  61358. /**
  61359. * The current x and y values of this controller's trackpad
  61360. */
  61361. trackpad: StickValues;
  61362. /**
  61363. * Creates a new WindowsMotionController from a gamepad
  61364. * @param vrGamepad the gamepad that the controller should be created from
  61365. */
  61366. constructor(vrGamepad: any);
  61367. /**
  61368. * Fired when the trigger on this controller is modified
  61369. */
  61370. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  61371. /**
  61372. * Fired when the menu button on this controller is modified
  61373. */
  61374. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  61375. /**
  61376. * Fired when the grip button on this controller is modified
  61377. */
  61378. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  61379. /**
  61380. * Fired when the thumbstick button on this controller is modified
  61381. */
  61382. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  61383. /**
  61384. * Fired when the touchpad button on this controller is modified
  61385. */
  61386. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  61387. /**
  61388. * Fired when the touchpad values on this controller are modified
  61389. */
  61390. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  61391. protected _updateTrackpad(): void;
  61392. /**
  61393. * Called once per frame by the engine.
  61394. */
  61395. update(): void;
  61396. /**
  61397. * Called once for each button that changed state since the last frame
  61398. * @param buttonIdx Which button index changed
  61399. * @param state New state of the button
  61400. * @param changes Which properties on the state changed since last frame
  61401. */
  61402. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  61403. /**
  61404. * Moves the buttons on the controller mesh based on their current state
  61405. * @param buttonName the name of the button to move
  61406. * @param buttonValue the value of the button which determines the buttons new position
  61407. */
  61408. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  61409. /**
  61410. * Moves the axis on the controller mesh based on its current state
  61411. * @param axis the index of the axis
  61412. * @param axisValue the value of the axis which determines the meshes new position
  61413. * @hidden
  61414. */
  61415. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  61416. /**
  61417. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  61418. * @param scene scene in which to add meshes
  61419. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  61420. */
  61421. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  61422. /**
  61423. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  61424. * can be transformed by button presses and axes values, based on this._mapping.
  61425. *
  61426. * @param scene scene in which the meshes exist
  61427. * @param meshes list of meshes that make up the controller model to process
  61428. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  61429. */
  61430. private processModel;
  61431. private createMeshInfo;
  61432. /**
  61433. * Gets the ray of the controller in the direction the controller is pointing
  61434. * @param length the length the resulting ray should be
  61435. * @returns a ray in the direction the controller is pointing
  61436. */
  61437. getForwardRay(length?: number): Ray;
  61438. /**
  61439. * Disposes of the controller
  61440. */
  61441. dispose(): void;
  61442. }
  61443. /**
  61444. * This class represents a new windows motion controller in XR.
  61445. */
  61446. export class XRWindowsMotionController extends WindowsMotionController {
  61447. /**
  61448. * Changing the original WIndowsMotionController mapping to fir the new mapping
  61449. */
  61450. protected readonly _mapping: {
  61451. buttons: string[];
  61452. buttonMeshNames: {
  61453. trigger: string;
  61454. menu: string;
  61455. grip: string;
  61456. thumbstick: string;
  61457. trackpad: string;
  61458. };
  61459. buttonObservableNames: {
  61460. trigger: string;
  61461. menu: string;
  61462. grip: string;
  61463. thumbstick: string;
  61464. trackpad: string;
  61465. };
  61466. axisMeshNames: string[];
  61467. pointingPoseMeshName: string;
  61468. };
  61469. /**
  61470. * Construct a new XR-Based windows motion controller
  61471. *
  61472. * @param gamepadInfo the gamepad object from the browser
  61473. */
  61474. constructor(gamepadInfo: any);
  61475. /**
  61476. * holds the thumbstick values (X,Y)
  61477. */
  61478. thumbstickValues: StickValues;
  61479. /**
  61480. * Fired when the thumbstick on this controller is clicked
  61481. */
  61482. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  61483. /**
  61484. * Fired when the thumbstick on this controller is modified
  61485. */
  61486. onThumbstickValuesChangedObservable: Observable<StickValues>;
  61487. /**
  61488. * Fired when the touchpad button on this controller is modified
  61489. */
  61490. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  61491. /**
  61492. * Fired when the touchpad values on this controller are modified
  61493. */
  61494. onTrackpadValuesChangedObservable: Observable<StickValues>;
  61495. /**
  61496. * Fired when the thumbstick button on this controller is modified
  61497. * here to prevent breaking changes
  61498. */
  61499. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  61500. /**
  61501. * updating the thumbstick(!) and not the trackpad.
  61502. * This is named this way due to the difference between WebVR and XR and to avoid
  61503. * changing the parent class.
  61504. */
  61505. protected _updateTrackpad(): void;
  61506. /**
  61507. * Disposes the class with joy
  61508. */
  61509. dispose(): void;
  61510. }
  61511. }
  61512. declare module BABYLON {
  61513. /**
  61514. * A directional light is defined by a direction (what a surprise!).
  61515. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  61516. * 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.
  61517. * Documentation: https://doc.babylonjs.com/babylon101/lights
  61518. */
  61519. export class DirectionalLight extends ShadowLight {
  61520. private _shadowFrustumSize;
  61521. /**
  61522. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  61523. */
  61524. get shadowFrustumSize(): number;
  61525. /**
  61526. * Specifies a fix frustum size for the shadow generation.
  61527. */
  61528. set shadowFrustumSize(value: number);
  61529. private _shadowOrthoScale;
  61530. /**
  61531. * Gets the shadow projection scale against the optimal computed one.
  61532. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  61533. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  61534. */
  61535. get shadowOrthoScale(): number;
  61536. /**
  61537. * Sets the shadow projection scale against the optimal computed one.
  61538. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  61539. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  61540. */
  61541. set shadowOrthoScale(value: number);
  61542. /**
  61543. * Automatically compute the projection matrix to best fit (including all the casters)
  61544. * on each frame.
  61545. */
  61546. autoUpdateExtends: boolean;
  61547. /**
  61548. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  61549. * on each frame. autoUpdateExtends must be set to true for this to work
  61550. */
  61551. autoCalcShadowZBounds: boolean;
  61552. private _orthoLeft;
  61553. private _orthoRight;
  61554. private _orthoTop;
  61555. private _orthoBottom;
  61556. /**
  61557. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  61558. * The directional light is emitted from everywhere in the given direction.
  61559. * It can cast shadows.
  61560. * Documentation : https://doc.babylonjs.com/babylon101/lights
  61561. * @param name The friendly name of the light
  61562. * @param direction The direction of the light
  61563. * @param scene The scene the light belongs to
  61564. */
  61565. constructor(name: string, direction: Vector3, scene: Scene);
  61566. /**
  61567. * Returns the string "DirectionalLight".
  61568. * @return The class name
  61569. */
  61570. getClassName(): string;
  61571. /**
  61572. * Returns the integer 1.
  61573. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  61574. */
  61575. getTypeID(): number;
  61576. /**
  61577. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  61578. * Returns the DirectionalLight Shadow projection matrix.
  61579. */
  61580. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  61581. /**
  61582. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  61583. * Returns the DirectionalLight Shadow projection matrix.
  61584. */
  61585. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  61586. /**
  61587. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  61588. * Returns the DirectionalLight Shadow projection matrix.
  61589. */
  61590. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  61591. protected _buildUniformLayout(): void;
  61592. /**
  61593. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  61594. * @param effect The effect to update
  61595. * @param lightIndex The index of the light in the effect to update
  61596. * @returns The directional light
  61597. */
  61598. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  61599. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  61600. /**
  61601. * Gets the minZ used for shadow according to both the scene and the light.
  61602. *
  61603. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  61604. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  61605. * @param activeCamera The camera we are returning the min for
  61606. * @returns the depth min z
  61607. */
  61608. getDepthMinZ(activeCamera: Camera): number;
  61609. /**
  61610. * Gets the maxZ used for shadow according to both the scene and the light.
  61611. *
  61612. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  61613. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  61614. * @param activeCamera The camera we are returning the max for
  61615. * @returns the depth max z
  61616. */
  61617. getDepthMaxZ(activeCamera: Camera): number;
  61618. /**
  61619. * Prepares the list of defines specific to the light type.
  61620. * @param defines the list of defines
  61621. * @param lightIndex defines the index of the light for the effect
  61622. */
  61623. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  61624. }
  61625. }
  61626. declare module BABYLON {
  61627. /**
  61628. * Class containing static functions to help procedurally build meshes
  61629. */
  61630. export class HemisphereBuilder {
  61631. /**
  61632. * Creates a hemisphere mesh
  61633. * @param name defines the name of the mesh
  61634. * @param options defines the options used to create the mesh
  61635. * @param scene defines the hosting scene
  61636. * @returns the hemisphere mesh
  61637. */
  61638. static CreateHemisphere(name: string, options: {
  61639. segments?: number;
  61640. diameter?: number;
  61641. sideOrientation?: number;
  61642. }, scene: any): Mesh;
  61643. }
  61644. }
  61645. declare module BABYLON {
  61646. /**
  61647. * A spot light is defined by a position, a direction, an angle, and an exponent.
  61648. * These values define a cone of light starting from the position, emitting toward the direction.
  61649. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  61650. * and the exponent defines the speed of the decay of the light with distance (reach).
  61651. * Documentation: https://doc.babylonjs.com/babylon101/lights
  61652. */
  61653. export class SpotLight extends ShadowLight {
  61654. private _angle;
  61655. private _innerAngle;
  61656. private _cosHalfAngle;
  61657. private _lightAngleScale;
  61658. private _lightAngleOffset;
  61659. /**
  61660. * Gets the cone angle of the spot light in Radians.
  61661. */
  61662. get angle(): number;
  61663. /**
  61664. * Sets the cone angle of the spot light in Radians.
  61665. */
  61666. set angle(value: number);
  61667. /**
  61668. * Only used in gltf falloff mode, this defines the angle where
  61669. * the directional falloff will start before cutting at angle which could be seen
  61670. * as outer angle.
  61671. */
  61672. get innerAngle(): number;
  61673. /**
  61674. * Only used in gltf falloff mode, this defines the angle where
  61675. * the directional falloff will start before cutting at angle which could be seen
  61676. * as outer angle.
  61677. */
  61678. set innerAngle(value: number);
  61679. private _shadowAngleScale;
  61680. /**
  61681. * Allows scaling the angle of the light for shadow generation only.
  61682. */
  61683. get shadowAngleScale(): number;
  61684. /**
  61685. * Allows scaling the angle of the light for shadow generation only.
  61686. */
  61687. set shadowAngleScale(value: number);
  61688. /**
  61689. * The light decay speed with the distance from the emission spot.
  61690. */
  61691. exponent: number;
  61692. private _projectionTextureMatrix;
  61693. /**
  61694. * Allows reading the projection texture
  61695. */
  61696. get projectionTextureMatrix(): Matrix;
  61697. protected _projectionTextureLightNear: number;
  61698. /**
  61699. * Gets the near clip of the Spotlight for texture projection.
  61700. */
  61701. get projectionTextureLightNear(): number;
  61702. /**
  61703. * Sets the near clip of the Spotlight for texture projection.
  61704. */
  61705. set projectionTextureLightNear(value: number);
  61706. protected _projectionTextureLightFar: number;
  61707. /**
  61708. * Gets the far clip of the Spotlight for texture projection.
  61709. */
  61710. get projectionTextureLightFar(): number;
  61711. /**
  61712. * Sets the far clip of the Spotlight for texture projection.
  61713. */
  61714. set projectionTextureLightFar(value: number);
  61715. protected _projectionTextureUpDirection: Vector3;
  61716. /**
  61717. * Gets the Up vector of the Spotlight for texture projection.
  61718. */
  61719. get projectionTextureUpDirection(): Vector3;
  61720. /**
  61721. * Sets the Up vector of the Spotlight for texture projection.
  61722. */
  61723. set projectionTextureUpDirection(value: Vector3);
  61724. private _projectionTexture;
  61725. /**
  61726. * Gets the projection texture of the light.
  61727. */
  61728. get projectionTexture(): Nullable<BaseTexture>;
  61729. /**
  61730. * Sets the projection texture of the light.
  61731. */
  61732. set projectionTexture(value: Nullable<BaseTexture>);
  61733. private static _IsProceduralTexture;
  61734. private static _IsTexture;
  61735. private _projectionTextureViewLightDirty;
  61736. private _projectionTextureProjectionLightDirty;
  61737. private _projectionTextureDirty;
  61738. private _projectionTextureViewTargetVector;
  61739. private _projectionTextureViewLightMatrix;
  61740. private _projectionTextureProjectionLightMatrix;
  61741. private _projectionTextureScalingMatrix;
  61742. /**
  61743. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  61744. * It can cast shadows.
  61745. * Documentation : https://doc.babylonjs.com/babylon101/lights
  61746. * @param name The light friendly name
  61747. * @param position The position of the spot light in the scene
  61748. * @param direction The direction of the light in the scene
  61749. * @param angle The cone angle of the light in Radians
  61750. * @param exponent The light decay speed with the distance from the emission spot
  61751. * @param scene The scene the lights belongs to
  61752. */
  61753. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  61754. /**
  61755. * Returns the string "SpotLight".
  61756. * @returns the class name
  61757. */
  61758. getClassName(): string;
  61759. /**
  61760. * Returns the integer 2.
  61761. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  61762. */
  61763. getTypeID(): number;
  61764. /**
  61765. * Overrides the direction setter to recompute the projection texture view light Matrix.
  61766. */
  61767. protected _setDirection(value: Vector3): void;
  61768. /**
  61769. * Overrides the position setter to recompute the projection texture view light Matrix.
  61770. */
  61771. protected _setPosition(value: Vector3): void;
  61772. /**
  61773. * 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.
  61774. * Returns the SpotLight.
  61775. */
  61776. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  61777. protected _computeProjectionTextureViewLightMatrix(): void;
  61778. protected _computeProjectionTextureProjectionLightMatrix(): void;
  61779. /**
  61780. * Main function for light texture projection matrix computing.
  61781. */
  61782. protected _computeProjectionTextureMatrix(): void;
  61783. protected _buildUniformLayout(): void;
  61784. private _computeAngleValues;
  61785. /**
  61786. * Sets the passed Effect "effect" with the Light textures.
  61787. * @param effect The effect to update
  61788. * @param lightIndex The index of the light in the effect to update
  61789. * @returns The light
  61790. */
  61791. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  61792. /**
  61793. * Sets the passed Effect object with the SpotLight transformed position (or position if not parented) and normalized direction.
  61794. * @param effect The effect to update
  61795. * @param lightIndex The index of the light in the effect to update
  61796. * @returns The spot light
  61797. */
  61798. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  61799. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  61800. /**
  61801. * Disposes the light and the associated resources.
  61802. */
  61803. dispose(): void;
  61804. /**
  61805. * Prepares the list of defines specific to the light type.
  61806. * @param defines the list of defines
  61807. * @param lightIndex defines the index of the light for the effect
  61808. */
  61809. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  61810. }
  61811. }
  61812. declare module BABYLON {
  61813. /**
  61814. * Gizmo that enables viewing a light
  61815. */
  61816. export class LightGizmo extends Gizmo {
  61817. private _lightMesh;
  61818. private _material;
  61819. private _cachedPosition;
  61820. private _cachedForward;
  61821. private _attachedMeshParent;
  61822. private _pointerObserver;
  61823. /**
  61824. * Event that fires each time the gizmo is clicked
  61825. */
  61826. onClickedObservable: Observable<Light>;
  61827. /**
  61828. * Creates a LightGizmo
  61829. * @param gizmoLayer The utility layer the gizmo will be added to
  61830. */
  61831. constructor(gizmoLayer?: UtilityLayerRenderer);
  61832. private _light;
  61833. /**
  61834. * The light that the gizmo is attached to
  61835. */
  61836. set light(light: Nullable<Light>);
  61837. get light(): Nullable<Light>;
  61838. /**
  61839. * Gets the material used to render the light gizmo
  61840. */
  61841. get material(): StandardMaterial;
  61842. /**
  61843. * @hidden
  61844. * Updates the gizmo to match the attached mesh's position/rotation
  61845. */
  61846. protected _update(): void;
  61847. private static _Scale;
  61848. /**
  61849. * Creates the lines for a light mesh
  61850. */
  61851. private static _CreateLightLines;
  61852. /**
  61853. * Disposes of the light gizmo
  61854. */
  61855. dispose(): void;
  61856. private static _CreateHemisphericLightMesh;
  61857. private static _CreatePointLightMesh;
  61858. private static _CreateSpotLightMesh;
  61859. private static _CreateDirectionalLightMesh;
  61860. }
  61861. }
  61862. declare module BABYLON {
  61863. /**
  61864. * Gizmo that enables viewing a camera
  61865. */
  61866. export class CameraGizmo extends Gizmo {
  61867. private _cameraMesh;
  61868. private _cameraLinesMesh;
  61869. private _material;
  61870. private _pointerObserver;
  61871. /**
  61872. * Event that fires each time the gizmo is clicked
  61873. */
  61874. onClickedObservable: Observable<Camera>;
  61875. /**
  61876. * Creates a CameraGizmo
  61877. * @param gizmoLayer The utility layer the gizmo will be added to
  61878. */
  61879. constructor(gizmoLayer?: UtilityLayerRenderer);
  61880. private _camera;
  61881. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  61882. get displayFrustum(): boolean;
  61883. set displayFrustum(value: boolean);
  61884. /**
  61885. * The camera that the gizmo is attached to
  61886. */
  61887. set camera(camera: Nullable<Camera>);
  61888. get camera(): Nullable<Camera>;
  61889. /**
  61890. * Gets the material used to render the camera gizmo
  61891. */
  61892. get material(): StandardMaterial;
  61893. /**
  61894. * @hidden
  61895. * Updates the gizmo to match the attached mesh's position/rotation
  61896. */
  61897. protected _update(): void;
  61898. private static _Scale;
  61899. private _invProjection;
  61900. /**
  61901. * Disposes of the camera gizmo
  61902. */
  61903. dispose(): void;
  61904. private static _CreateCameraMesh;
  61905. private static _CreateCameraFrustum;
  61906. }
  61907. }
  61908. declare module BABYLON {
  61909. /** @hidden */
  61910. export var backgroundFragmentDeclaration: {
  61911. name: string;
  61912. shader: string;
  61913. };
  61914. }
  61915. declare module BABYLON {
  61916. /** @hidden */
  61917. export var backgroundUboDeclaration: {
  61918. name: string;
  61919. shader: string;
  61920. };
  61921. }
  61922. declare module BABYLON {
  61923. /** @hidden */
  61924. export var backgroundPixelShader: {
  61925. name: string;
  61926. shader: string;
  61927. };
  61928. }
  61929. declare module BABYLON {
  61930. /** @hidden */
  61931. export var backgroundVertexDeclaration: {
  61932. name: string;
  61933. shader: string;
  61934. };
  61935. }
  61936. declare module BABYLON {
  61937. /** @hidden */
  61938. export var backgroundVertexShader: {
  61939. name: string;
  61940. shader: string;
  61941. };
  61942. }
  61943. declare module BABYLON {
  61944. /**
  61945. * Background material used to create an efficient environment around your scene.
  61946. */
  61947. export class BackgroundMaterial extends PushMaterial {
  61948. /**
  61949. * Standard reflectance value at parallel view angle.
  61950. */
  61951. static StandardReflectance0: number;
  61952. /**
  61953. * Standard reflectance value at grazing angle.
  61954. */
  61955. static StandardReflectance90: number;
  61956. protected _primaryColor: Color3;
  61957. /**
  61958. * Key light Color (multiply against the environment texture)
  61959. */
  61960. primaryColor: Color3;
  61961. protected __perceptualColor: Nullable<Color3>;
  61962. /**
  61963. * Experimental Internal Use Only.
  61964. *
  61965. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  61966. * This acts as a helper to set the primary color to a more "human friendly" value.
  61967. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  61968. * output color as close as possible from the chosen value.
  61969. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  61970. * part of lighting setup.)
  61971. */
  61972. get _perceptualColor(): Nullable<Color3>;
  61973. set _perceptualColor(value: Nullable<Color3>);
  61974. protected _primaryColorShadowLevel: float;
  61975. /**
  61976. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  61977. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  61978. */
  61979. get primaryColorShadowLevel(): float;
  61980. set primaryColorShadowLevel(value: float);
  61981. protected _primaryColorHighlightLevel: float;
  61982. /**
  61983. * Defines the level of the highlights (highlight area of the reflection map) in order to help scaling the colors.
  61984. * The primary color is used at the level chosen to define what the white area would look.
  61985. */
  61986. get primaryColorHighlightLevel(): float;
  61987. set primaryColorHighlightLevel(value: float);
  61988. protected _reflectionTexture: Nullable<BaseTexture>;
  61989. /**
  61990. * Reflection Texture used in the material.
  61991. * Should be author in a specific way for the best result (refer to the documentation).
  61992. */
  61993. reflectionTexture: Nullable<BaseTexture>;
  61994. protected _reflectionBlur: float;
  61995. /**
  61996. * Reflection Texture level of blur.
  61997. *
  61998. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  61999. * texture twice.
  62000. */
  62001. reflectionBlur: float;
  62002. protected _diffuseTexture: Nullable<BaseTexture>;
  62003. /**
  62004. * Diffuse Texture used in the material.
  62005. * Should be author in a specific way for the best result (refer to the documentation).
  62006. */
  62007. diffuseTexture: Nullable<BaseTexture>;
  62008. protected _shadowLights: Nullable<IShadowLight[]>;
  62009. /**
  62010. * Specify the list of lights casting shadow on the material.
  62011. * All scene shadow lights will be included if null.
  62012. */
  62013. shadowLights: Nullable<IShadowLight[]>;
  62014. protected _shadowLevel: float;
  62015. /**
  62016. * Helps adjusting the shadow to a softer level if required.
  62017. * 0 means black shadows and 1 means no shadows.
  62018. */
  62019. shadowLevel: float;
  62020. protected _sceneCenter: Vector3;
  62021. /**
  62022. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  62023. * It is usually zero but might be interesting to modify according to your setup.
  62024. */
  62025. sceneCenter: Vector3;
  62026. protected _opacityFresnel: boolean;
  62027. /**
  62028. * This helps specifying that the material is falling off to the sky box at grazing angle.
  62029. * This helps ensuring a nice transition when the camera goes under the ground.
  62030. */
  62031. opacityFresnel: boolean;
  62032. protected _reflectionFresnel: boolean;
  62033. /**
  62034. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  62035. * This helps adding a mirror texture on the ground.
  62036. */
  62037. reflectionFresnel: boolean;
  62038. protected _reflectionFalloffDistance: number;
  62039. /**
  62040. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  62041. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  62042. */
  62043. reflectionFalloffDistance: number;
  62044. protected _reflectionAmount: number;
  62045. /**
  62046. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  62047. */
  62048. reflectionAmount: number;
  62049. protected _reflectionReflectance0: number;
  62050. /**
  62051. * This specifies the weight of the reflection at grazing angle.
  62052. */
  62053. reflectionReflectance0: number;
  62054. protected _reflectionReflectance90: number;
  62055. /**
  62056. * This specifies the weight of the reflection at a perpendicular point of view.
  62057. */
  62058. reflectionReflectance90: number;
  62059. /**
  62060. * Sets the reflection reflectance fresnel values according to the default standard
  62061. * empirically know to work well :-)
  62062. */
  62063. set reflectionStandardFresnelWeight(value: number);
  62064. protected _useRGBColor: boolean;
  62065. /**
  62066. * Helps to directly use the maps channels instead of their level.
  62067. */
  62068. useRGBColor: boolean;
  62069. protected _enableNoise: boolean;
  62070. /**
  62071. * This helps reducing the banding effect that could occur on the background.
  62072. */
  62073. enableNoise: boolean;
  62074. /**
  62075. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  62076. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  62077. * Recommended to be keep at 1.0 except for special cases.
  62078. */
  62079. get fovMultiplier(): number;
  62080. set fovMultiplier(value: number);
  62081. private _fovMultiplier;
  62082. /**
  62083. * Enable the FOV adjustment feature controlled by fovMultiplier.
  62084. */
  62085. useEquirectangularFOV: boolean;
  62086. private _maxSimultaneousLights;
  62087. /**
  62088. * Number of Simultaneous lights allowed on the material.
  62089. */
  62090. maxSimultaneousLights: int;
  62091. private _shadowOnly;
  62092. /**
  62093. * Make the material only render shadows
  62094. */
  62095. shadowOnly: boolean;
  62096. /**
  62097. * Default configuration related to image processing available in the Background Material.
  62098. */
  62099. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  62100. /**
  62101. * Keep track of the image processing observer to allow dispose and replace.
  62102. */
  62103. private _imageProcessingObserver;
  62104. /**
  62105. * Attaches a new image processing configuration to the PBR Material.
  62106. * @param configuration (if null the scene configuration will be use)
  62107. */
  62108. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  62109. /**
  62110. * Gets the image processing configuration used either in this material.
  62111. */
  62112. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  62113. /**
  62114. * Sets the Default image processing configuration used either in the this material.
  62115. *
  62116. * If sets to null, the scene one is in use.
  62117. */
  62118. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  62119. /**
  62120. * Gets whether the color curves effect is enabled.
  62121. */
  62122. get cameraColorCurvesEnabled(): boolean;
  62123. /**
  62124. * Sets whether the color curves effect is enabled.
  62125. */
  62126. set cameraColorCurvesEnabled(value: boolean);
  62127. /**
  62128. * Gets whether the color grading effect is enabled.
  62129. */
  62130. get cameraColorGradingEnabled(): boolean;
  62131. /**
  62132. * Gets whether the color grading effect is enabled.
  62133. */
  62134. set cameraColorGradingEnabled(value: boolean);
  62135. /**
  62136. * Gets whether tonemapping is enabled or not.
  62137. */
  62138. get cameraToneMappingEnabled(): boolean;
  62139. /**
  62140. * Sets whether tonemapping is enabled or not
  62141. */
  62142. set cameraToneMappingEnabled(value: boolean);
  62143. /**
  62144. * The camera exposure used on this material.
  62145. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  62146. * This corresponds to a photographic exposure.
  62147. */
  62148. get cameraExposure(): float;
  62149. /**
  62150. * The camera exposure used on this material.
  62151. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  62152. * This corresponds to a photographic exposure.
  62153. */
  62154. set cameraExposure(value: float);
  62155. /**
  62156. * Gets The camera contrast used on this material.
  62157. */
  62158. get cameraContrast(): float;
  62159. /**
  62160. * Sets The camera contrast used on this material.
  62161. */
  62162. set cameraContrast(value: float);
  62163. /**
  62164. * Gets the Color Grading 2D Lookup Texture.
  62165. */
  62166. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  62167. /**
  62168. * Sets the Color Grading 2D Lookup Texture.
  62169. */
  62170. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  62171. /**
  62172. * The color grading curves provide additional color adjustment that is applied after any color grading transform (3D LUT).
  62173. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  62174. * 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;
  62175. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  62176. */
  62177. get cameraColorCurves(): Nullable<ColorCurves>;
  62178. /**
  62179. * The color grading curves provide additional color adjustment that is applied after any color grading transform (3D LUT).
  62180. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  62181. * 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;
  62182. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  62183. */
  62184. set cameraColorCurves(value: Nullable<ColorCurves>);
  62185. /**
  62186. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  62187. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  62188. */
  62189. switchToBGR: boolean;
  62190. private _renderTargets;
  62191. private _reflectionControls;
  62192. private _white;
  62193. private _primaryShadowColor;
  62194. private _primaryHighlightColor;
  62195. /**
  62196. * Instantiates a Background Material in the given scene
  62197. * @param name The friendly name of the material
  62198. * @param scene The scene to add the material to
  62199. */
  62200. constructor(name: string, scene: Scene);
  62201. /**
  62202. * Gets a boolean indicating that current material needs to register RTT
  62203. */
  62204. get hasRenderTargetTextures(): boolean;
  62205. /**
  62206. * The entire material has been created in order to prevent overdraw.
  62207. * @returns false
  62208. */
  62209. needAlphaTesting(): boolean;
  62210. /**
  62211. * The entire material has been created in order to prevent overdraw.
  62212. * @returns true if blending is enable
  62213. */
  62214. needAlphaBlending(): boolean;
  62215. /**
  62216. * Checks whether the material is ready to be rendered for a given mesh.
  62217. * @param mesh The mesh to render
  62218. * @param subMesh The submesh to check against
  62219. * @param useInstances Specify wether or not the material is used with instances
  62220. * @returns true if all the dependencies are ready (Textures, Effects...)
  62221. */
  62222. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  62223. /**
  62224. * Compute the primary color according to the chosen perceptual color.
  62225. */
  62226. private _computePrimaryColorFromPerceptualColor;
  62227. /**
  62228. * Compute the highlights and shadow colors according to their chosen levels.
  62229. */
  62230. private _computePrimaryColors;
  62231. /**
  62232. * Build the uniform buffer used in the material.
  62233. */
  62234. buildUniformLayout(): void;
  62235. /**
  62236. * Unbind the material.
  62237. */
  62238. unbind(): void;
  62239. /**
  62240. * Bind only the world matrix to the material.
  62241. * @param world The world matrix to bind.
  62242. */
  62243. bindOnlyWorldMatrix(world: Matrix): void;
  62244. /**
  62245. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  62246. * @param world The world matrix to bind.
  62247. * @param subMesh The submesh to bind for.
  62248. */
  62249. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  62250. /**
  62251. * Checks to see if a texture is used in the material.
  62252. * @param texture - Base texture to use.
  62253. * @returns - Boolean specifying if a texture is used in the material.
  62254. */
  62255. hasTexture(texture: BaseTexture): boolean;
  62256. /**
  62257. * Dispose the material.
  62258. * @param forceDisposeEffect Force disposal of the associated effect.
  62259. * @param forceDisposeTextures Force disposal of the associated textures.
  62260. */
  62261. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  62262. /**
  62263. * Clones the material.
  62264. * @param name The cloned name.
  62265. * @returns The cloned material.
  62266. */
  62267. clone(name: string): BackgroundMaterial;
  62268. /**
  62269. * Serializes the current material to its JSON representation.
  62270. * @returns The JSON representation.
  62271. */
  62272. serialize(): any;
  62273. /**
  62274. * Gets the class name of the material
  62275. * @returns "BackgroundMaterial"
  62276. */
  62277. getClassName(): string;
  62278. /**
  62279. * Parse a JSON input to create back a background material.
  62280. * @param source The JSON data to parse
  62281. * @param scene The scene to create the parsed material in
  62282. * @param rootUrl The root url of the assets the material depends upon
  62283. * @returns the instantiated BackgroundMaterial.
  62284. */
  62285. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  62286. }
  62287. }
  62288. declare module BABYLON {
  62289. /**
  62290. * Represents the different options available during the creation of
  62291. * a Environment helper.
  62292. *
  62293. * This can control the default ground, skybox and image processing setup of your scene.
  62294. */
  62295. export interface IEnvironmentHelperOptions {
  62296. /**
  62297. * Specifies whether or not to create a ground.
  62298. * True by default.
  62299. */
  62300. createGround: boolean;
  62301. /**
  62302. * Specifies the ground size.
  62303. * 15 by default.
  62304. */
  62305. groundSize: number;
  62306. /**
  62307. * The texture used on the ground for the main color.
  62308. * Comes from the BabylonJS CDN by default.
  62309. *
  62310. * Remarks: Can be either a texture or a url.
  62311. */
  62312. groundTexture: string | BaseTexture;
  62313. /**
  62314. * The color mixed in the ground texture by default.
  62315. * BabylonJS clearColor by default.
  62316. */
  62317. groundColor: Color3;
  62318. /**
  62319. * Specifies the ground opacity.
  62320. * 1 by default.
  62321. */
  62322. groundOpacity: number;
  62323. /**
  62324. * Enables the ground to receive shadows.
  62325. * True by default.
  62326. */
  62327. enableGroundShadow: boolean;
  62328. /**
  62329. * Helps preventing the shadow to be fully black on the ground.
  62330. * 0.5 by default.
  62331. */
  62332. groundShadowLevel: number;
  62333. /**
  62334. * Creates a mirror texture attach to the ground.
  62335. * false by default.
  62336. */
  62337. enableGroundMirror: boolean;
  62338. /**
  62339. * Specifies the ground mirror size ratio.
  62340. * 0.3 by default as the default kernel is 64.
  62341. */
  62342. groundMirrorSizeRatio: number;
  62343. /**
  62344. * Specifies the ground mirror blur kernel size.
  62345. * 64 by default.
  62346. */
  62347. groundMirrorBlurKernel: number;
  62348. /**
  62349. * Specifies the ground mirror visibility amount.
  62350. * 1 by default
  62351. */
  62352. groundMirrorAmount: number;
  62353. /**
  62354. * Specifies the ground mirror reflectance weight.
  62355. * This uses the standard weight of the background material to setup the fresnel effect
  62356. * of the mirror.
  62357. * 1 by default.
  62358. */
  62359. groundMirrorFresnelWeight: number;
  62360. /**
  62361. * Specifies the ground mirror Falloff distance.
  62362. * This can helps reducing the size of the reflection.
  62363. * 0 by Default.
  62364. */
  62365. groundMirrorFallOffDistance: number;
  62366. /**
  62367. * Specifies the ground mirror texture type.
  62368. * Unsigned Int by Default.
  62369. */
  62370. groundMirrorTextureType: number;
  62371. /**
  62372. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  62373. * the shown objects.
  62374. */
  62375. groundYBias: number;
  62376. /**
  62377. * Specifies whether or not to create a skybox.
  62378. * True by default.
  62379. */
  62380. createSkybox: boolean;
  62381. /**
  62382. * Specifies the skybox size.
  62383. * 20 by default.
  62384. */
  62385. skyboxSize: number;
  62386. /**
  62387. * The texture used on the skybox for the main color.
  62388. * Comes from the BabylonJS CDN by default.
  62389. *
  62390. * Remarks: Can be either a texture or a url.
  62391. */
  62392. skyboxTexture: string | BaseTexture;
  62393. /**
  62394. * The color mixed in the skybox texture by default.
  62395. * BabylonJS clearColor by default.
  62396. */
  62397. skyboxColor: Color3;
  62398. /**
  62399. * The background rotation around the Y axis of the scene.
  62400. * This helps aligning the key lights of your scene with the background.
  62401. * 0 by default.
  62402. */
  62403. backgroundYRotation: number;
  62404. /**
  62405. * Compute automatically the size of the elements to best fit with the scene.
  62406. */
  62407. sizeAuto: boolean;
  62408. /**
  62409. * Default position of the rootMesh if autoSize is not true.
  62410. */
  62411. rootPosition: Vector3;
  62412. /**
  62413. * Sets up the image processing in the scene.
  62414. * true by default.
  62415. */
  62416. setupImageProcessing: boolean;
  62417. /**
  62418. * The texture used as your environment texture in the scene.
  62419. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  62420. *
  62421. * Remarks: Can be either a texture or a url.
  62422. */
  62423. environmentTexture: string | BaseTexture;
  62424. /**
  62425. * The value of the exposure to apply to the scene.
  62426. * 0.6 by default if setupImageProcessing is true.
  62427. */
  62428. cameraExposure: number;
  62429. /**
  62430. * The value of the contrast to apply to the scene.
  62431. * 1.6 by default if setupImageProcessing is true.
  62432. */
  62433. cameraContrast: number;
  62434. /**
  62435. * Specifies whether or not tonemapping should be enabled in the scene.
  62436. * true by default if setupImageProcessing is true.
  62437. */
  62438. toneMappingEnabled: boolean;
  62439. }
  62440. /**
  62441. * The Environment helper class can be used to add a fully featured none expensive background to your scene.
  62442. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  62443. * It also helps with the default setup of your imageProcessing configuration.
  62444. */
  62445. export class EnvironmentHelper {
  62446. /**
  62447. * Default ground texture URL.
  62448. */
  62449. private static _groundTextureCDNUrl;
  62450. /**
  62451. * Default skybox texture URL.
  62452. */
  62453. private static _skyboxTextureCDNUrl;
  62454. /**
  62455. * Default environment texture URL.
  62456. */
  62457. private static _environmentTextureCDNUrl;
  62458. /**
  62459. * Creates the default options for the helper.
  62460. */
  62461. private static _getDefaultOptions;
  62462. private _rootMesh;
  62463. /**
  62464. * Gets the root mesh created by the helper.
  62465. */
  62466. get rootMesh(): Mesh;
  62467. private _skybox;
  62468. /**
  62469. * Gets the skybox created by the helper.
  62470. */
  62471. get skybox(): Nullable<Mesh>;
  62472. private _skyboxTexture;
  62473. /**
  62474. * Gets the skybox texture created by the helper.
  62475. */
  62476. get skyboxTexture(): Nullable<BaseTexture>;
  62477. private _skyboxMaterial;
  62478. /**
  62479. * Gets the skybox material created by the helper.
  62480. */
  62481. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  62482. private _ground;
  62483. /**
  62484. * Gets the ground mesh created by the helper.
  62485. */
  62486. get ground(): Nullable<Mesh>;
  62487. private _groundTexture;
  62488. /**
  62489. * Gets the ground texture created by the helper.
  62490. */
  62491. get groundTexture(): Nullable<BaseTexture>;
  62492. private _groundMirror;
  62493. /**
  62494. * Gets the ground mirror created by the helper.
  62495. */
  62496. get groundMirror(): Nullable<MirrorTexture>;
  62497. /**
  62498. * Gets the ground mirror render list to helps pushing the meshes
  62499. * you wish in the ground reflection.
  62500. */
  62501. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  62502. private _groundMaterial;
  62503. /**
  62504. * Gets the ground material created by the helper.
  62505. */
  62506. get groundMaterial(): Nullable<BackgroundMaterial>;
  62507. /**
  62508. * Stores the creation options.
  62509. */
  62510. private readonly _scene;
  62511. private _options;
  62512. /**
  62513. * This observable will be notified with any error during the creation of the environment,
  62514. * mainly texture creation errors.
  62515. */
  62516. onErrorObservable: Observable<{
  62517. message?: string;
  62518. exception?: any;
  62519. }>;
  62520. /**
  62521. * constructor
  62522. * @param options Defines the options we want to customize the helper
  62523. * @param scene The scene to add the material to
  62524. */
  62525. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  62526. /**
  62527. * Updates the background according to the new options
  62528. * @param options
  62529. */
  62530. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  62531. /**
  62532. * Sets the primary color of all the available elements.
  62533. * @param color the main color to affect to the ground and the background
  62534. */
  62535. setMainColor(color: Color3): void;
  62536. /**
  62537. * Setup the image processing according to the specified options.
  62538. */
  62539. private _setupImageProcessing;
  62540. /**
  62541. * Setup the environment texture according to the specified options.
  62542. */
  62543. private _setupEnvironmentTexture;
  62544. /**
  62545. * Setup the background according to the specified options.
  62546. */
  62547. private _setupBackground;
  62548. /**
  62549. * Get the scene sizes according to the setup.
  62550. */
  62551. private _getSceneSize;
  62552. /**
  62553. * Setup the ground according to the specified options.
  62554. */
  62555. private _setupGround;
  62556. /**
  62557. * Setup the ground material according to the specified options.
  62558. */
  62559. private _setupGroundMaterial;
  62560. /**
  62561. * Setup the ground diffuse texture according to the specified options.
  62562. */
  62563. private _setupGroundDiffuseTexture;
  62564. /**
  62565. * Setup the ground mirror texture according to the specified options.
  62566. */
  62567. private _setupGroundMirrorTexture;
  62568. /**
  62569. * Setup the ground to receive the mirror texture.
  62570. */
  62571. private _setupMirrorInGroundMaterial;
  62572. /**
  62573. * Setup the skybox according to the specified options.
  62574. */
  62575. private _setupSkybox;
  62576. /**
  62577. * Setup the skybox material according to the specified options.
  62578. */
  62579. private _setupSkyboxMaterial;
  62580. /**
  62581. * Setup the skybox reflection texture according to the specified options.
  62582. */
  62583. private _setupSkyboxReflectionTexture;
  62584. private _errorHandler;
  62585. /**
  62586. * Dispose all the elements created by the Helper.
  62587. */
  62588. dispose(): void;
  62589. }
  62590. }
  62591. declare module BABYLON {
  62592. /**
  62593. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  62594. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  62595. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  62596. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  62597. */
  62598. export abstract class TextureDome<T extends Texture> extends TransformNode {
  62599. protected onError: Nullable<(message?: string, exception?: any) => void>;
  62600. /**
  62601. * Define the source as a Monoscopic panoramic 360/180.
  62602. */
  62603. static readonly MODE_MONOSCOPIC: number;
  62604. /**
  62605. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  62606. */
  62607. static readonly MODE_TOPBOTTOM: number;
  62608. /**
  62609. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  62610. */
  62611. static readonly MODE_SIDEBYSIDE: number;
  62612. private _halfDome;
  62613. private _crossEye;
  62614. protected _useDirectMapping: boolean;
  62615. /**
  62616. * The texture being displayed on the sphere
  62617. */
  62618. protected _texture: T;
  62619. /**
  62620. * Gets the texture being displayed on the sphere
  62621. */
  62622. get texture(): T;
  62623. /**
  62624. * Sets the texture being displayed on the sphere
  62625. */
  62626. set texture(newTexture: T);
  62627. /**
  62628. * The skybox material
  62629. */
  62630. protected _material: BackgroundMaterial;
  62631. /**
  62632. * The surface used for the dome
  62633. */
  62634. protected _mesh: Mesh;
  62635. /**
  62636. * Gets the mesh used for the dome.
  62637. */
  62638. get mesh(): Mesh;
  62639. /**
  62640. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  62641. */
  62642. private _halfDomeMask;
  62643. /**
  62644. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  62645. * Also see the options.resolution property.
  62646. */
  62647. get fovMultiplier(): number;
  62648. set fovMultiplier(value: number);
  62649. protected _textureMode: number;
  62650. /**
  62651. * Gets or set the current texture mode for the texture. It can be:
  62652. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  62653. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  62654. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  62655. */
  62656. get textureMode(): number;
  62657. /**
  62658. * Sets the current texture mode for the texture. It can be:
  62659. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  62660. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  62661. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  62662. */
  62663. set textureMode(value: number);
  62664. /**
  62665. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  62666. */
  62667. get halfDome(): boolean;
  62668. /**
  62669. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  62670. */
  62671. set halfDome(enabled: boolean);
  62672. /**
  62673. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  62674. */
  62675. set crossEye(enabled: boolean);
  62676. /**
  62677. * Is it a cross-eye texture?
  62678. */
  62679. get crossEye(): boolean;
  62680. /**
  62681. * The background material of this dome.
  62682. */
  62683. get material(): BackgroundMaterial;
  62684. /**
  62685. * Oberserver used in Stereoscopic VR Mode.
  62686. */
  62687. private _onBeforeCameraRenderObserver;
  62688. /**
  62689. * Observable raised when an error occurred while loading the texture
  62690. */
  62691. onLoadErrorObservable: Observable<string>;
  62692. /**
  62693. * Observable raised when the texture finished loading
  62694. */
  62695. onLoadObservable: Observable<void>;
  62696. /**
  62697. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  62698. * @param name Element's name, child elements will append suffixes for their own names.
  62699. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  62700. * @param options An object containing optional or exposed sub element properties
  62701. */
  62702. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  62703. resolution?: number;
  62704. clickToPlay?: boolean;
  62705. autoPlay?: boolean;
  62706. loop?: boolean;
  62707. size?: number;
  62708. poster?: string;
  62709. faceForward?: boolean;
  62710. useDirectMapping?: boolean;
  62711. halfDomeMode?: boolean;
  62712. crossEyeMode?: boolean;
  62713. generateMipMaps?: boolean;
  62714. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  62715. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  62716. protected _changeTextureMode(value: number): void;
  62717. /**
  62718. * Releases resources associated with this node.
  62719. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  62720. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  62721. */
  62722. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  62723. }
  62724. }
  62725. declare module BABYLON {
  62726. /**
  62727. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  62728. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  62729. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  62730. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  62731. */
  62732. export class PhotoDome extends TextureDome<Texture> {
  62733. /**
  62734. * Define the image as a Monoscopic panoramic 360 image.
  62735. */
  62736. static readonly MODE_MONOSCOPIC: number;
  62737. /**
  62738. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  62739. */
  62740. static readonly MODE_TOPBOTTOM: number;
  62741. /**
  62742. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  62743. */
  62744. static readonly MODE_SIDEBYSIDE: number;
  62745. /**
  62746. * Gets or sets the texture being displayed on the sphere
  62747. */
  62748. get photoTexture(): Texture;
  62749. /**
  62750. * sets the texture being displayed on the sphere
  62751. */
  62752. set photoTexture(value: Texture);
  62753. /**
  62754. * Gets the current video mode for the video. It can be:
  62755. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  62756. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  62757. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  62758. */
  62759. get imageMode(): number;
  62760. /**
  62761. * Sets the current video mode for the video. It can be:
  62762. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  62763. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  62764. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  62765. */
  62766. set imageMode(value: number);
  62767. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  62768. }
  62769. }
  62770. declare module BABYLON {
  62771. /**
  62772. * Direct draw surface info
  62773. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  62774. */
  62775. export interface DDSInfo {
  62776. /**
  62777. * Width of the texture
  62778. */
  62779. width: number;
  62780. /**
  62781. * Width of the texture
  62782. */
  62783. height: number;
  62784. /**
  62785. * Number of Mipmaps for the texture
  62786. * @see https://en.wikipedia.org/wiki/Mipmap
  62787. */
  62788. mipmapCount: number;
  62789. /**
  62790. * If the textures format is a known fourCC format
  62791. * @see https://www.fourcc.org/
  62792. */
  62793. isFourCC: boolean;
  62794. /**
  62795. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  62796. */
  62797. isRGB: boolean;
  62798. /**
  62799. * If the texture is a lumincance format
  62800. */
  62801. isLuminance: boolean;
  62802. /**
  62803. * If this is a cube texture
  62804. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  62805. */
  62806. isCube: boolean;
  62807. /**
  62808. * If the texture is a compressed format eg. FOURCC_DXT1
  62809. */
  62810. isCompressed: boolean;
  62811. /**
  62812. * The dxgiFormat of the texture
  62813. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  62814. */
  62815. dxgiFormat: number;
  62816. /**
  62817. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  62818. */
  62819. textureType: number;
  62820. /**
  62821. * Sphericle polynomial created for the dds texture
  62822. */
  62823. sphericalPolynomial?: SphericalPolynomial;
  62824. }
  62825. /**
  62826. * Class used to provide DDS decompression tools
  62827. */
  62828. export class DDSTools {
  62829. /**
  62830. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  62831. */
  62832. static StoreLODInAlphaChannel: boolean;
  62833. /**
  62834. * Gets DDS information from an array buffer
  62835. * @param data defines the array buffer view to read data from
  62836. * @returns the DDS information
  62837. */
  62838. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  62839. private static _FloatView;
  62840. private static _Int32View;
  62841. private static _ToHalfFloat;
  62842. private static _FromHalfFloat;
  62843. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  62844. private static _GetHalfFloatRGBAArrayBuffer;
  62845. private static _GetFloatRGBAArrayBuffer;
  62846. private static _GetFloatAsUIntRGBAArrayBuffer;
  62847. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  62848. private static _GetRGBAArrayBuffer;
  62849. private static _ExtractLongWordOrder;
  62850. private static _GetRGBArrayBuffer;
  62851. private static _GetLuminanceArrayBuffer;
  62852. /**
  62853. * Uploads DDS Levels to a Babylon Texture
  62854. * @hidden
  62855. */
  62856. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  62857. }
  62858. interface ThinEngine {
  62859. /**
  62860. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  62861. * @param rootUrl defines the url where the file to load is located
  62862. * @param scene defines the current scene
  62863. * @param lodScale defines scale to apply to the mip map selection
  62864. * @param lodOffset defines offset to apply to the mip map selection
  62865. * @param onLoad defines an optional callback raised when the texture is loaded
  62866. * @param onError defines an optional callback raised if there is an issue to load the texture
  62867. * @param format defines the format of the data
  62868. * @param forcedExtension defines the extension to use to pick the right loader
  62869. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  62870. * @returns the cube texture as an InternalTexture
  62871. */
  62872. 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;
  62873. }
  62874. }
  62875. declare module BABYLON {
  62876. /**
  62877. * Implementation of the DDS Texture Loader.
  62878. * @hidden
  62879. */
  62880. export class _DDSTextureLoader implements IInternalTextureLoader {
  62881. /**
  62882. * Defines whether the loader supports cascade loading the different faces.
  62883. */
  62884. readonly supportCascades: boolean;
  62885. /**
  62886. * This returns if the loader support the current file information.
  62887. * @param extension defines the file extension of the file being loaded
  62888. * @returns true if the loader can load the specified file
  62889. */
  62890. canLoad(extension: string): boolean;
  62891. /**
  62892. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62893. * @param data contains the texture data
  62894. * @param texture defines the BabylonJS internal texture
  62895. * @param createPolynomials will be true if polynomials have been requested
  62896. * @param onLoad defines the callback to trigger once the texture is ready
  62897. * @param onError defines the callback to trigger in case of error
  62898. */
  62899. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62900. /**
  62901. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62902. * @param data contains the texture data
  62903. * @param texture defines the BabylonJS internal texture
  62904. * @param callback defines the method to call once ready to upload
  62905. */
  62906. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  62907. }
  62908. }
  62909. declare module BABYLON {
  62910. /**
  62911. * Implementation of the ENV Texture Loader.
  62912. * @hidden
  62913. */
  62914. export class _ENVTextureLoader implements IInternalTextureLoader {
  62915. /**
  62916. * Defines whether the loader supports cascade loading the different faces.
  62917. */
  62918. readonly supportCascades: boolean;
  62919. /**
  62920. * This returns if the loader support the current file information.
  62921. * @param extension defines the file extension of the file being loaded
  62922. * @returns true if the loader can load the specified file
  62923. */
  62924. canLoad(extension: string): boolean;
  62925. /**
  62926. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62927. * @param data contains the texture data
  62928. * @param texture defines the BabylonJS internal texture
  62929. * @param createPolynomials will be true if polynomials have been requested
  62930. * @param onLoad defines the callback to trigger once the texture is ready
  62931. * @param onError defines the callback to trigger in case of error
  62932. */
  62933. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62934. /**
  62935. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62936. * @param data contains the texture data
  62937. * @param texture defines the BabylonJS internal texture
  62938. * @param callback defines the method to call once ready to upload
  62939. */
  62940. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  62941. }
  62942. }
  62943. declare module BABYLON {
  62944. /**
  62945. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  62946. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  62947. */
  62948. export class KhronosTextureContainer {
  62949. /** contents of the KTX container file */
  62950. data: ArrayBufferView;
  62951. private static HEADER_LEN;
  62952. private static COMPRESSED_2D;
  62953. private static COMPRESSED_3D;
  62954. private static TEX_2D;
  62955. private static TEX_3D;
  62956. /**
  62957. * Gets the openGL type
  62958. */
  62959. glType: number;
  62960. /**
  62961. * Gets the openGL type size
  62962. */
  62963. glTypeSize: number;
  62964. /**
  62965. * Gets the openGL format
  62966. */
  62967. glFormat: number;
  62968. /**
  62969. * Gets the openGL internal format
  62970. */
  62971. glInternalFormat: number;
  62972. /**
  62973. * Gets the base internal format
  62974. */
  62975. glBaseInternalFormat: number;
  62976. /**
  62977. * Gets image width in pixel
  62978. */
  62979. pixelWidth: number;
  62980. /**
  62981. * Gets image height in pixel
  62982. */
  62983. pixelHeight: number;
  62984. /**
  62985. * Gets image depth in pixels
  62986. */
  62987. pixelDepth: number;
  62988. /**
  62989. * Gets the number of array elements
  62990. */
  62991. numberOfArrayElements: number;
  62992. /**
  62993. * Gets the number of faces
  62994. */
  62995. numberOfFaces: number;
  62996. /**
  62997. * Gets the number of mipmap levels
  62998. */
  62999. numberOfMipmapLevels: number;
  63000. /**
  63001. * Gets the bytes of key value data
  63002. */
  63003. bytesOfKeyValueData: number;
  63004. /**
  63005. * Gets the load type
  63006. */
  63007. loadType: number;
  63008. /**
  63009. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  63010. */
  63011. isInvalid: boolean;
  63012. /**
  63013. * Creates a new KhronosTextureContainer
  63014. * @param data contents of the KTX container file
  63015. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  63016. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  63017. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  63018. */
  63019. constructor(
  63020. /** contents of the KTX container file */
  63021. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  63022. /**
  63023. * Uploads KTX content to a Babylon Texture.
  63024. * It is assumed that the texture has already been created & is currently bound
  63025. * @hidden
  63026. */
  63027. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  63028. private _upload2DCompressedLevels;
  63029. /**
  63030. * Checks if the given data starts with a KTX file identifier.
  63031. * @param data the data to check
  63032. * @returns true if the data is a KTX file or false otherwise
  63033. */
  63034. static IsValid(data: ArrayBufferView): boolean;
  63035. }
  63036. }
  63037. declare module BABYLON {
  63038. /**
  63039. * Helper class to push actions to a pool of workers.
  63040. */
  63041. export class WorkerPool implements IDisposable {
  63042. private _workerInfos;
  63043. private _pendingActions;
  63044. /**
  63045. * Constructor
  63046. * @param workers Array of workers to use for actions
  63047. */
  63048. constructor(workers: Array<Worker>);
  63049. /**
  63050. * Terminates all workers and clears any pending actions.
  63051. */
  63052. dispose(): void;
  63053. /**
  63054. * Pushes an action to the worker pool. If all the workers are active, the action will be
  63055. * pended until a worker has completed its action.
  63056. * @param action The action to perform. Call onComplete when the action is complete.
  63057. */
  63058. push(action: (worker: Worker, onComplete: () => void) => void): void;
  63059. private _execute;
  63060. }
  63061. }
  63062. declare module BABYLON {
  63063. /**
  63064. * Class for loading KTX2 files
  63065. */
  63066. export class KhronosTextureContainer2 {
  63067. private static _WorkerPoolPromise?;
  63068. private static _Initialized;
  63069. private static _Ktx2Decoder;
  63070. /**
  63071. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  63072. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  63073. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  63074. * Urls you can change:
  63075. * URLConfig.jsDecoderModule
  63076. * URLConfig.wasmUASTCToASTC
  63077. * URLConfig.wasmUASTCToBC7
  63078. * URLConfig.wasmUASTCToRGBA_UNORM
  63079. * URLConfig.wasmUASTCToRGBA_SRGB
  63080. * URLConfig.jsMSCTranscoder
  63081. * URLConfig.wasmMSCTranscoder
  63082. * URLConfig.wasmZSTDDecoder
  63083. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#29
  63084. */
  63085. static URLConfig: {
  63086. jsDecoderModule: string;
  63087. wasmUASTCToASTC: null;
  63088. wasmUASTCToBC7: null;
  63089. wasmUASTCToRGBA_UNORM: null;
  63090. wasmUASTCToRGBA_SRGB: null;
  63091. jsMSCTranscoder: null;
  63092. wasmMSCTranscoder: null;
  63093. wasmZSTDDecoder: null;
  63094. };
  63095. /**
  63096. * Default number of workers used to handle data decoding
  63097. */
  63098. static DefaultNumWorkers: number;
  63099. private static GetDefaultNumWorkers;
  63100. private _engine;
  63101. private static _CreateWorkerPool;
  63102. /**
  63103. * Constructor
  63104. * @param engine The engine to use
  63105. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  63106. */
  63107. constructor(engine: ThinEngine, numWorkers?: number);
  63108. /** @hidden */
  63109. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture, options?: any): Promise<void>;
  63110. /**
  63111. * Stop all async operations and release resources.
  63112. */
  63113. dispose(): void;
  63114. protected _createTexture(data: any, internalTexture: InternalTexture, options?: any): void;
  63115. /**
  63116. * Checks if the given data starts with a KTX2 file identifier.
  63117. * @param data the data to check
  63118. * @returns true if the data is a KTX2 file or false otherwise
  63119. */
  63120. static IsValid(data: ArrayBufferView): boolean;
  63121. }
  63122. }
  63123. declare module BABYLON {
  63124. /**
  63125. * Implementation of the KTX Texture Loader.
  63126. * @hidden
  63127. */
  63128. export class _KTXTextureLoader implements IInternalTextureLoader {
  63129. /**
  63130. * Defines whether the loader supports cascade loading the different faces.
  63131. */
  63132. readonly supportCascades: boolean;
  63133. /**
  63134. * This returns if the loader support the current file information.
  63135. * @param extension defines the file extension of the file being loaded
  63136. * @param mimeType defines the optional mime type of the file being loaded
  63137. * @returns true if the loader can load the specified file
  63138. */
  63139. canLoad(extension: string, mimeType?: string): boolean;
  63140. /**
  63141. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  63142. * @param data contains the texture data
  63143. * @param texture defines the BabylonJS internal texture
  63144. * @param createPolynomials will be true if polynomials have been requested
  63145. * @param onLoad defines the callback to trigger once the texture is ready
  63146. * @param onError defines the callback to trigger in case of error
  63147. */
  63148. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  63149. /**
  63150. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  63151. * @param data contains the texture data
  63152. * @param texture defines the BabylonJS internal texture
  63153. * @param callback defines the method to call once ready to upload
  63154. */
  63155. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void, options?: any): void;
  63156. }
  63157. }
  63158. declare module BABYLON {
  63159. /** @hidden */
  63160. export var _forceSceneHelpersToBundle: boolean;
  63161. interface Scene {
  63162. /**
  63163. * Creates a default light for the scene.
  63164. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  63165. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  63166. */
  63167. createDefaultLight(replace?: boolean): void;
  63168. /**
  63169. * Creates a default camera for the scene.
  63170. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  63171. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  63172. * @param replace has default false, when true replaces the active camera in the scene
  63173. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  63174. */
  63175. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  63176. /**
  63177. * Creates a default camera and a default light.
  63178. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  63179. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  63180. * @param replace has the default false, when true replaces the active camera/light in the scene
  63181. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  63182. */
  63183. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  63184. /**
  63185. * Creates a new sky box
  63186. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  63187. * @param environmentTexture defines the texture to use as environment texture
  63188. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  63189. * @param scale defines the overall scale of the skybox
  63190. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  63191. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  63192. * @returns a new mesh holding the sky box
  63193. */
  63194. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  63195. /**
  63196. * Creates a new environment
  63197. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  63198. * @param options defines the options you can use to configure the environment
  63199. * @returns the new EnvironmentHelper
  63200. */
  63201. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  63202. /**
  63203. * Creates a new VREXperienceHelper
  63204. * @see https://doc.babylonjs.com/how_to/webvr_helper
  63205. * @param webVROptions defines the options used to create the new VREXperienceHelper
  63206. * @returns a new VREXperienceHelper
  63207. */
  63208. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  63209. /**
  63210. * Creates a new WebXRDefaultExperience
  63211. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  63212. * @param options experience options
  63213. * @returns a promise for a new WebXRDefaultExperience
  63214. */
  63215. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  63216. }
  63217. }
  63218. declare module BABYLON {
  63219. /**
  63220. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  63221. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  63222. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  63223. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  63224. */
  63225. export class VideoDome extends TextureDome<VideoTexture> {
  63226. /**
  63227. * Define the video source as a Monoscopic panoramic 360 video.
  63228. */
  63229. static readonly MODE_MONOSCOPIC: number;
  63230. /**
  63231. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  63232. */
  63233. static readonly MODE_TOPBOTTOM: number;
  63234. /**
  63235. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  63236. */
  63237. static readonly MODE_SIDEBYSIDE: number;
  63238. /**
  63239. * Get the video texture associated with this video dome
  63240. */
  63241. get videoTexture(): VideoTexture;
  63242. /**
  63243. * Get the video mode of this dome
  63244. */
  63245. get videoMode(): number;
  63246. /**
  63247. * Set the video mode of this dome.
  63248. * @see textureMode
  63249. */
  63250. set videoMode(value: number);
  63251. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  63252. }
  63253. }
  63254. declare module BABYLON {
  63255. /**
  63256. * This class can be used to get instrumentation data from a Babylon engine
  63257. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  63258. */
  63259. export class EngineInstrumentation implements IDisposable {
  63260. /**
  63261. * Define the instrumented engine.
  63262. */
  63263. engine: Engine;
  63264. private _captureGPUFrameTime;
  63265. private _gpuFrameTimeToken;
  63266. private _gpuFrameTime;
  63267. private _captureShaderCompilationTime;
  63268. private _shaderCompilationTime;
  63269. private _onBeginFrameObserver;
  63270. private _onEndFrameObserver;
  63271. private _onBeforeShaderCompilationObserver;
  63272. private _onAfterShaderCompilationObserver;
  63273. /**
  63274. * Gets the perf counter used for GPU frame time
  63275. */
  63276. get gpuFrameTimeCounter(): PerfCounter;
  63277. /**
  63278. * Gets the GPU frame time capture status
  63279. */
  63280. get captureGPUFrameTime(): boolean;
  63281. /**
  63282. * Enable or disable the GPU frame time capture
  63283. */
  63284. set captureGPUFrameTime(value: boolean);
  63285. /**
  63286. * Gets the perf counter used for shader compilation time
  63287. */
  63288. get shaderCompilationTimeCounter(): PerfCounter;
  63289. /**
  63290. * Gets the shader compilation time capture status
  63291. */
  63292. get captureShaderCompilationTime(): boolean;
  63293. /**
  63294. * Enable or disable the shader compilation time capture
  63295. */
  63296. set captureShaderCompilationTime(value: boolean);
  63297. /**
  63298. * Instantiates a new engine instrumentation.
  63299. * This class can be used to get instrumentation data from a Babylon engine
  63300. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  63301. * @param engine Defines the engine to instrument
  63302. */
  63303. constructor(
  63304. /**
  63305. * Define the instrumented engine.
  63306. */
  63307. engine: Engine);
  63308. /**
  63309. * Dispose and release associated resources.
  63310. */
  63311. dispose(): void;
  63312. }
  63313. }
  63314. declare module BABYLON {
  63315. /**
  63316. * This class can be used to get instrumentation data from a Babylon engine
  63317. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  63318. */
  63319. export class SceneInstrumentation implements IDisposable {
  63320. /**
  63321. * Defines the scene to instrument
  63322. */
  63323. scene: Scene;
  63324. private _captureActiveMeshesEvaluationTime;
  63325. private _activeMeshesEvaluationTime;
  63326. private _captureRenderTargetsRenderTime;
  63327. private _renderTargetsRenderTime;
  63328. private _captureFrameTime;
  63329. private _frameTime;
  63330. private _captureRenderTime;
  63331. private _renderTime;
  63332. private _captureInterFrameTime;
  63333. private _interFrameTime;
  63334. private _captureParticlesRenderTime;
  63335. private _particlesRenderTime;
  63336. private _captureSpritesRenderTime;
  63337. private _spritesRenderTime;
  63338. private _capturePhysicsTime;
  63339. private _physicsTime;
  63340. private _captureAnimationsTime;
  63341. private _animationsTime;
  63342. private _captureCameraRenderTime;
  63343. private _cameraRenderTime;
  63344. private _onBeforeActiveMeshesEvaluationObserver;
  63345. private _onAfterActiveMeshesEvaluationObserver;
  63346. private _onBeforeRenderTargetsRenderObserver;
  63347. private _onAfterRenderTargetsRenderObserver;
  63348. private _onAfterRenderObserver;
  63349. private _onBeforeDrawPhaseObserver;
  63350. private _onAfterDrawPhaseObserver;
  63351. private _onBeforeAnimationsObserver;
  63352. private _onBeforeParticlesRenderingObserver;
  63353. private _onAfterParticlesRenderingObserver;
  63354. private _onBeforeSpritesRenderingObserver;
  63355. private _onAfterSpritesRenderingObserver;
  63356. private _onBeforePhysicsObserver;
  63357. private _onAfterPhysicsObserver;
  63358. private _onAfterAnimationsObserver;
  63359. private _onBeforeCameraRenderObserver;
  63360. private _onAfterCameraRenderObserver;
  63361. /**
  63362. * Gets the perf counter used for active meshes evaluation time
  63363. */
  63364. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  63365. /**
  63366. * Gets the active meshes evaluation time capture status
  63367. */
  63368. get captureActiveMeshesEvaluationTime(): boolean;
  63369. /**
  63370. * Enable or disable the active meshes evaluation time capture
  63371. */
  63372. set captureActiveMeshesEvaluationTime(value: boolean);
  63373. /**
  63374. * Gets the perf counter used for render targets render time
  63375. */
  63376. get renderTargetsRenderTimeCounter(): PerfCounter;
  63377. /**
  63378. * Gets the render targets render time capture status
  63379. */
  63380. get captureRenderTargetsRenderTime(): boolean;
  63381. /**
  63382. * Enable or disable the render targets render time capture
  63383. */
  63384. set captureRenderTargetsRenderTime(value: boolean);
  63385. /**
  63386. * Gets the perf counter used for particles render time
  63387. */
  63388. get particlesRenderTimeCounter(): PerfCounter;
  63389. /**
  63390. * Gets the particles render time capture status
  63391. */
  63392. get captureParticlesRenderTime(): boolean;
  63393. /**
  63394. * Enable or disable the particles render time capture
  63395. */
  63396. set captureParticlesRenderTime(value: boolean);
  63397. /**
  63398. * Gets the perf counter used for sprites render time
  63399. */
  63400. get spritesRenderTimeCounter(): PerfCounter;
  63401. /**
  63402. * Gets the sprites render time capture status
  63403. */
  63404. get captureSpritesRenderTime(): boolean;
  63405. /**
  63406. * Enable or disable the sprites render time capture
  63407. */
  63408. set captureSpritesRenderTime(value: boolean);
  63409. /**
  63410. * Gets the perf counter used for physics time
  63411. */
  63412. get physicsTimeCounter(): PerfCounter;
  63413. /**
  63414. * Gets the physics time capture status
  63415. */
  63416. get capturePhysicsTime(): boolean;
  63417. /**
  63418. * Enable or disable the physics time capture
  63419. */
  63420. set capturePhysicsTime(value: boolean);
  63421. /**
  63422. * Gets the perf counter used for animations time
  63423. */
  63424. get animationsTimeCounter(): PerfCounter;
  63425. /**
  63426. * Gets the animations time capture status
  63427. */
  63428. get captureAnimationsTime(): boolean;
  63429. /**
  63430. * Enable or disable the animations time capture
  63431. */
  63432. set captureAnimationsTime(value: boolean);
  63433. /**
  63434. * Gets the perf counter used for frame time capture
  63435. */
  63436. get frameTimeCounter(): PerfCounter;
  63437. /**
  63438. * Gets the frame time capture status
  63439. */
  63440. get captureFrameTime(): boolean;
  63441. /**
  63442. * Enable or disable the frame time capture
  63443. */
  63444. set captureFrameTime(value: boolean);
  63445. /**
  63446. * Gets the perf counter used for inter-frames time capture
  63447. */
  63448. get interFrameTimeCounter(): PerfCounter;
  63449. /**
  63450. * Gets the inter-frames time capture status
  63451. */
  63452. get captureInterFrameTime(): boolean;
  63453. /**
  63454. * Enable or disable the inter-frames time capture
  63455. */
  63456. set captureInterFrameTime(value: boolean);
  63457. /**
  63458. * Gets the perf counter used for render time capture
  63459. */
  63460. get renderTimeCounter(): PerfCounter;
  63461. /**
  63462. * Gets the render time capture status
  63463. */
  63464. get captureRenderTime(): boolean;
  63465. /**
  63466. * Enable or disable the render time capture
  63467. */
  63468. set captureRenderTime(value: boolean);
  63469. /**
  63470. * Gets the perf counter used for camera render time capture
  63471. */
  63472. get cameraRenderTimeCounter(): PerfCounter;
  63473. /**
  63474. * Gets the camera render time capture status
  63475. */
  63476. get captureCameraRenderTime(): boolean;
  63477. /**
  63478. * Enable or disable the camera render time capture
  63479. */
  63480. set captureCameraRenderTime(value: boolean);
  63481. /**
  63482. * Gets the perf counter used for draw calls
  63483. */
  63484. get drawCallsCounter(): PerfCounter;
  63485. /**
  63486. * Instantiates a new scene instrumentation.
  63487. * This class can be used to get instrumentation data from a Babylon engine
  63488. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  63489. * @param scene Defines the scene to instrument
  63490. */
  63491. constructor(
  63492. /**
  63493. * Defines the scene to instrument
  63494. */
  63495. scene: Scene);
  63496. /**
  63497. * Dispose and release associated resources.
  63498. */
  63499. dispose(): void;
  63500. }
  63501. }
  63502. declare module BABYLON {
  63503. /** @hidden */
  63504. export var glowMapGenerationPixelShader: {
  63505. name: string;
  63506. shader: string;
  63507. };
  63508. }
  63509. declare module BABYLON {
  63510. /** @hidden */
  63511. export var glowMapGenerationVertexShader: {
  63512. name: string;
  63513. shader: string;
  63514. };
  63515. }
  63516. declare module BABYLON {
  63517. /**
  63518. * Effect layer options. This helps customizing the behaviour
  63519. * of the effect layer.
  63520. */
  63521. export interface IEffectLayerOptions {
  63522. /**
  63523. * Multiplication factor apply to the canvas size to compute the render target size
  63524. * used to generated the objects (the smaller the faster).
  63525. */
  63526. mainTextureRatio: number;
  63527. /**
  63528. * Enforces a fixed size texture to ensure effect stability across devices.
  63529. */
  63530. mainTextureFixedSize?: number;
  63531. /**
  63532. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  63533. */
  63534. alphaBlendingMode: number;
  63535. /**
  63536. * The camera attached to the layer.
  63537. */
  63538. camera: Nullable<Camera>;
  63539. /**
  63540. * The rendering group to draw the layer in.
  63541. */
  63542. renderingGroupId: number;
  63543. }
  63544. /**
  63545. * The effect layer Helps adding post process effect blended with the main pass.
  63546. *
  63547. * This can be for instance use to generate glow or highlight effects on the scene.
  63548. *
  63549. * The effect layer class can not be used directly and is intented to inherited from to be
  63550. * customized per effects.
  63551. */
  63552. export abstract class EffectLayer {
  63553. private _vertexBuffers;
  63554. private _indexBuffer;
  63555. private _cachedDefines;
  63556. private _effectLayerMapGenerationEffect;
  63557. private _effectLayerOptions;
  63558. private _mergeEffect;
  63559. protected _scene: Scene;
  63560. protected _engine: Engine;
  63561. protected _maxSize: number;
  63562. protected _mainTextureDesiredSize: ISize;
  63563. protected _mainTexture: RenderTargetTexture;
  63564. protected _shouldRender: boolean;
  63565. protected _postProcesses: PostProcess[];
  63566. protected _textures: BaseTexture[];
  63567. protected _emissiveTextureAndColor: {
  63568. texture: Nullable<BaseTexture>;
  63569. color: Color4;
  63570. };
  63571. /**
  63572. * The name of the layer
  63573. */
  63574. name: string;
  63575. /**
  63576. * The clear color of the texture used to generate the glow map.
  63577. */
  63578. neutralColor: Color4;
  63579. /**
  63580. * Specifies whether the highlight layer is enabled or not.
  63581. */
  63582. isEnabled: boolean;
  63583. /**
  63584. * Gets the camera attached to the layer.
  63585. */
  63586. get camera(): Nullable<Camera>;
  63587. /**
  63588. * Gets the rendering group id the layer should render in.
  63589. */
  63590. get renderingGroupId(): number;
  63591. set renderingGroupId(renderingGroupId: number);
  63592. /**
  63593. * Specifies if the bounding boxes should be rendered normally or if they should undergo the effect of the layer
  63594. */
  63595. disableBoundingBoxesFromEffectLayer: boolean;
  63596. /**
  63597. * An event triggered when the effect layer has been disposed.
  63598. */
  63599. onDisposeObservable: Observable<EffectLayer>;
  63600. /**
  63601. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  63602. */
  63603. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  63604. /**
  63605. * An event triggered when the generated texture is being merged in the scene.
  63606. */
  63607. onBeforeComposeObservable: Observable<EffectLayer>;
  63608. /**
  63609. * An event triggered when the mesh is rendered into the effect render target.
  63610. */
  63611. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  63612. /**
  63613. * An event triggered after the mesh has been rendered into the effect render target.
  63614. */
  63615. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  63616. /**
  63617. * An event triggered when the generated texture has been merged in the scene.
  63618. */
  63619. onAfterComposeObservable: Observable<EffectLayer>;
  63620. /**
  63621. * An event triggered when the effect layer changes its size.
  63622. */
  63623. onSizeChangedObservable: Observable<EffectLayer>;
  63624. /** @hidden */
  63625. static _SceneComponentInitialization: (scene: Scene) => void;
  63626. /**
  63627. * Instantiates a new effect Layer and references it in the scene.
  63628. * @param name The name of the layer
  63629. * @param scene The scene to use the layer in
  63630. */
  63631. constructor(
  63632. /** The Friendly of the effect in the scene */
  63633. name: string, scene: Scene);
  63634. /**
  63635. * Get the effect name of the layer.
  63636. * @return The effect name
  63637. */
  63638. abstract getEffectName(): string;
  63639. /**
  63640. * Checks for the readiness of the element composing the layer.
  63641. * @param subMesh the mesh to check for
  63642. * @param useInstances specify whether or not to use instances to render the mesh
  63643. * @return true if ready otherwise, false
  63644. */
  63645. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63646. /**
  63647. * Returns whether or not the layer needs stencil enabled during the mesh rendering.
  63648. * @returns true if the effect requires stencil during the main canvas render pass.
  63649. */
  63650. abstract needStencil(): boolean;
  63651. /**
  63652. * Create the merge effect. This is the shader use to blit the information back
  63653. * to the main canvas at the end of the scene rendering.
  63654. * @returns The effect containing the shader used to merge the effect on the main canvas
  63655. */
  63656. protected abstract _createMergeEffect(): Effect;
  63657. /**
  63658. * Creates the render target textures and post processes used in the effect layer.
  63659. */
  63660. protected abstract _createTextureAndPostProcesses(): void;
  63661. /**
  63662. * Implementation specific of rendering the generating effect on the main canvas.
  63663. * @param effect The effect used to render through
  63664. */
  63665. protected abstract _internalRender(effect: Effect): void;
  63666. /**
  63667. * Sets the required values for both the emissive texture and and the main color.
  63668. */
  63669. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  63670. /**
  63671. * Free any resources and references associated to a mesh.
  63672. * Internal use
  63673. * @param mesh The mesh to free.
  63674. */
  63675. abstract _disposeMesh(mesh: Mesh): void;
  63676. /**
  63677. * Serializes this layer (Glow or Highlight for example)
  63678. * @returns a serialized layer object
  63679. */
  63680. abstract serialize?(): any;
  63681. /**
  63682. * Initializes the effect layer with the required options.
  63683. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  63684. */
  63685. protected _init(options: Partial<IEffectLayerOptions>): void;
  63686. /**
  63687. * Generates the index buffer of the full screen quad blending to the main canvas.
  63688. */
  63689. private _generateIndexBuffer;
  63690. /**
  63691. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  63692. */
  63693. private _generateVertexBuffer;
  63694. /**
  63695. * Sets the main texture desired size which is the closest power of two
  63696. * of the engine canvas size.
  63697. */
  63698. private _setMainTextureSize;
  63699. /**
  63700. * Creates the main texture for the effect layer.
  63701. */
  63702. protected _createMainTexture(): void;
  63703. /**
  63704. * Adds specific effects defines.
  63705. * @param defines The defines to add specifics to.
  63706. */
  63707. protected _addCustomEffectDefines(defines: string[]): void;
  63708. /**
  63709. * Checks for the readiness of the element composing the layer.
  63710. * @param subMesh the mesh to check for
  63711. * @param useInstances specify whether or not to use instances to render the mesh
  63712. * @param emissiveTexture the associated emissive texture used to generate the glow
  63713. * @return true if ready otherwise, false
  63714. */
  63715. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  63716. /**
  63717. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  63718. */
  63719. render(): void;
  63720. /**
  63721. * Determine if a given mesh will be used in the current effect.
  63722. * @param mesh mesh to test
  63723. * @returns true if the mesh will be used
  63724. */
  63725. hasMesh(mesh: AbstractMesh): boolean;
  63726. /**
  63727. * Returns true if the layer contains information to display, otherwise false.
  63728. * @returns true if the glow layer should be rendered
  63729. */
  63730. shouldRender(): boolean;
  63731. /**
  63732. * Returns true if the mesh should render, otherwise false.
  63733. * @param mesh The mesh to render
  63734. * @returns true if it should render otherwise false
  63735. */
  63736. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  63737. /**
  63738. * Returns true if the mesh can be rendered, otherwise false.
  63739. * @param mesh The mesh to render
  63740. * @param material The material used on the mesh
  63741. * @returns true if it can be rendered otherwise false
  63742. */
  63743. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  63744. /**
  63745. * Returns true if the mesh should render, otherwise false.
  63746. * @param mesh The mesh to render
  63747. * @returns true if it should render otherwise false
  63748. */
  63749. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  63750. /**
  63751. * Renders the submesh passed in parameter to the generation map.
  63752. */
  63753. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  63754. /**
  63755. * Defines whether the current material of the mesh should be use to render the effect.
  63756. * @param mesh defines the current mesh to render
  63757. */
  63758. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  63759. /**
  63760. * Rebuild the required buffers.
  63761. * @hidden Internal use only.
  63762. */
  63763. _rebuild(): void;
  63764. /**
  63765. * Dispose only the render target textures and post process.
  63766. */
  63767. private _disposeTextureAndPostProcesses;
  63768. /**
  63769. * Dispose the highlight layer and free resources.
  63770. */
  63771. dispose(): void;
  63772. /**
  63773. * Gets the class name of the effect layer
  63774. * @returns the string with the class name of the effect layer
  63775. */
  63776. getClassName(): string;
  63777. /**
  63778. * Creates an effect layer from parsed effect layer data
  63779. * @param parsedEffectLayer defines effect layer data
  63780. * @param scene defines the current scene
  63781. * @param rootUrl defines the root URL containing the effect layer information
  63782. * @returns a parsed effect Layer
  63783. */
  63784. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  63785. }
  63786. }
  63787. declare module BABYLON {
  63788. interface AbstractScene {
  63789. /**
  63790. * The list of effect layers (highlights/glow) added to the scene
  63791. * @see https://doc.babylonjs.com/how_to/highlight_layer
  63792. * @see https://doc.babylonjs.com/how_to/glow_layer
  63793. */
  63794. effectLayers: Array<EffectLayer>;
  63795. /**
  63796. * Removes the given effect layer from this scene.
  63797. * @param toRemove defines the effect layer to remove
  63798. * @returns the index of the removed effect layer
  63799. */
  63800. removeEffectLayer(toRemove: EffectLayer): number;
  63801. /**
  63802. * Adds the given effect layer to this scene
  63803. * @param newEffectLayer defines the effect layer to add
  63804. */
  63805. addEffectLayer(newEffectLayer: EffectLayer): void;
  63806. }
  63807. /**
  63808. * Defines the layer scene component responsible to manage any effect layers
  63809. * in a given scene.
  63810. */
  63811. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  63812. /**
  63813. * The component name helpful to identify the component in the list of scene components.
  63814. */
  63815. readonly name: string;
  63816. /**
  63817. * The scene the component belongs to.
  63818. */
  63819. scene: Scene;
  63820. private _engine;
  63821. private _renderEffects;
  63822. private _needStencil;
  63823. private _previousStencilState;
  63824. /**
  63825. * Creates a new instance of the component for the given scene
  63826. * @param scene Defines the scene to register the component in
  63827. */
  63828. constructor(scene: Scene);
  63829. /**
  63830. * Registers the component in a given scene
  63831. */
  63832. register(): void;
  63833. /**
  63834. * Rebuilds the elements related to this component in case of
  63835. * context lost for instance.
  63836. */
  63837. rebuild(): void;
  63838. /**
  63839. * Serializes the component data to the specified json object
  63840. * @param serializationObject The object to serialize to
  63841. */
  63842. serialize(serializationObject: any): void;
  63843. /**
  63844. * Adds all the elements from the container to the scene
  63845. * @param container the container holding the elements
  63846. */
  63847. addFromContainer(container: AbstractScene): void;
  63848. /**
  63849. * Removes all the elements in the container from the scene
  63850. * @param container contains the elements to remove
  63851. * @param dispose if the removed element should be disposed (default: false)
  63852. */
  63853. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  63854. /**
  63855. * Disposes the component and the associated resources.
  63856. */
  63857. dispose(): void;
  63858. private _isReadyForMesh;
  63859. private _renderMainTexture;
  63860. private _setStencil;
  63861. private _setStencilBack;
  63862. private _draw;
  63863. private _drawCamera;
  63864. private _drawRenderingGroup;
  63865. }
  63866. }
  63867. declare module BABYLON {
  63868. /** @hidden */
  63869. export var glowMapMergePixelShader: {
  63870. name: string;
  63871. shader: string;
  63872. };
  63873. }
  63874. declare module BABYLON {
  63875. /** @hidden */
  63876. export var glowMapMergeVertexShader: {
  63877. name: string;
  63878. shader: string;
  63879. };
  63880. }
  63881. declare module BABYLON {
  63882. interface AbstractScene {
  63883. /**
  63884. * Return a the first highlight layer of the scene with a given name.
  63885. * @param name The name of the highlight layer to look for.
  63886. * @return The highlight layer if found otherwise null.
  63887. */
  63888. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  63889. }
  63890. /**
  63891. * Glow layer options. This helps customizing the behaviour
  63892. * of the glow layer.
  63893. */
  63894. export interface IGlowLayerOptions {
  63895. /**
  63896. * Multiplication factor apply to the canvas size to compute the render target size
  63897. * used to generated the glowing objects (the smaller the faster).
  63898. */
  63899. mainTextureRatio: number;
  63900. /**
  63901. * Enforces a fixed size texture to ensure resize independent blur.
  63902. */
  63903. mainTextureFixedSize?: number;
  63904. /**
  63905. * How big is the kernel of the blur texture.
  63906. */
  63907. blurKernelSize: number;
  63908. /**
  63909. * The camera attached to the layer.
  63910. */
  63911. camera: Nullable<Camera>;
  63912. /**
  63913. * Enable MSAA by choosing the number of samples.
  63914. */
  63915. mainTextureSamples?: number;
  63916. /**
  63917. * The rendering group to draw the layer in.
  63918. */
  63919. renderingGroupId: number;
  63920. }
  63921. /**
  63922. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  63923. *
  63924. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  63925. *
  63926. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  63927. */
  63928. export class GlowLayer extends EffectLayer {
  63929. /**
  63930. * Effect Name of the layer.
  63931. */
  63932. static readonly EffectName: string;
  63933. /**
  63934. * The default blur kernel size used for the glow.
  63935. */
  63936. static DefaultBlurKernelSize: number;
  63937. /**
  63938. * The default texture size ratio used for the glow.
  63939. */
  63940. static DefaultTextureRatio: number;
  63941. /**
  63942. * Sets the kernel size of the blur.
  63943. */
  63944. set blurKernelSize(value: number);
  63945. /**
  63946. * Gets the kernel size of the blur.
  63947. */
  63948. get blurKernelSize(): number;
  63949. /**
  63950. * Sets the glow intensity.
  63951. */
  63952. set intensity(value: number);
  63953. /**
  63954. * Gets the glow intensity.
  63955. */
  63956. get intensity(): number;
  63957. private _options;
  63958. private _intensity;
  63959. private _horizontalBlurPostprocess1;
  63960. private _verticalBlurPostprocess1;
  63961. private _horizontalBlurPostprocess2;
  63962. private _verticalBlurPostprocess2;
  63963. private _blurTexture1;
  63964. private _blurTexture2;
  63965. private _postProcesses1;
  63966. private _postProcesses2;
  63967. private _includedOnlyMeshes;
  63968. private _excludedMeshes;
  63969. private _meshesUsingTheirOwnMaterials;
  63970. /**
  63971. * Callback used to let the user override the color selection on a per mesh basis
  63972. */
  63973. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  63974. /**
  63975. * Callback used to let the user override the texture selection on a per mesh basis
  63976. */
  63977. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  63978. /**
  63979. * Instantiates a new glow Layer and references it to the scene.
  63980. * @param name The name of the layer
  63981. * @param scene The scene to use the layer in
  63982. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  63983. */
  63984. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  63985. /**
  63986. * Get the effect name of the layer.
  63987. * @return The effect name
  63988. */
  63989. getEffectName(): string;
  63990. /**
  63991. * Create the merge effect. This is the shader use to blit the information back
  63992. * to the main canvas at the end of the scene rendering.
  63993. */
  63994. protected _createMergeEffect(): Effect;
  63995. /**
  63996. * Creates the render target textures and post processes used in the glow layer.
  63997. */
  63998. protected _createTextureAndPostProcesses(): void;
  63999. /**
  64000. * Checks for the readiness of the element composing the layer.
  64001. * @param subMesh the mesh to check for
  64002. * @param useInstances specify whether or not to use instances to render the mesh
  64003. * @param emissiveTexture the associated emissive texture used to generate the glow
  64004. * @return true if ready otherwise, false
  64005. */
  64006. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64007. /**
  64008. * Returns whether or not the layer needs stencil enabled during the mesh rendering.
  64009. */
  64010. needStencil(): boolean;
  64011. /**
  64012. * Returns true if the mesh can be rendered, otherwise false.
  64013. * @param mesh The mesh to render
  64014. * @param material The material used on the mesh
  64015. * @returns true if it can be rendered otherwise false
  64016. */
  64017. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  64018. /**
  64019. * Implementation specific of rendering the generating effect on the main canvas.
  64020. * @param effect The effect used to render through
  64021. */
  64022. protected _internalRender(effect: Effect): void;
  64023. /**
  64024. * Sets the required values for both the emissive texture and and the main color.
  64025. */
  64026. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  64027. /**
  64028. * Returns true if the mesh should render, otherwise false.
  64029. * @param mesh The mesh to render
  64030. * @returns true if it should render otherwise false
  64031. */
  64032. protected _shouldRenderMesh(mesh: Mesh): boolean;
  64033. /**
  64034. * Adds specific effects defines.
  64035. * @param defines The defines to add specifics to.
  64036. */
  64037. protected _addCustomEffectDefines(defines: string[]): void;
  64038. /**
  64039. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  64040. * @param mesh The mesh to exclude from the glow layer
  64041. */
  64042. addExcludedMesh(mesh: Mesh): void;
  64043. /**
  64044. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  64045. * @param mesh The mesh to remove
  64046. */
  64047. removeExcludedMesh(mesh: Mesh): void;
  64048. /**
  64049. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  64050. * @param mesh The mesh to include in the glow layer
  64051. */
  64052. addIncludedOnlyMesh(mesh: Mesh): void;
  64053. /**
  64054. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  64055. * @param mesh The mesh to remove
  64056. */
  64057. removeIncludedOnlyMesh(mesh: Mesh): void;
  64058. /**
  64059. * Determine if a given mesh will be used in the glow layer
  64060. * @param mesh The mesh to test
  64061. * @returns true if the mesh will be highlighted by the current glow layer
  64062. */
  64063. hasMesh(mesh: AbstractMesh): boolean;
  64064. /**
  64065. * Defines whether the current material of the mesh should be use to render the effect.
  64066. * @param mesh defines the current mesh to render
  64067. */
  64068. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  64069. /**
  64070. * Add a mesh to be rendered through its own material and not with emissive only.
  64071. * @param mesh The mesh for which we need to use its material
  64072. */
  64073. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  64074. /**
  64075. * Remove a mesh from being rendered through its own material and not with emissive only.
  64076. * @param mesh The mesh for which we need to not use its material
  64077. */
  64078. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  64079. /**
  64080. * Free any resources and references associated to a mesh.
  64081. * Internal use
  64082. * @param mesh The mesh to free.
  64083. * @hidden
  64084. */
  64085. _disposeMesh(mesh: Mesh): void;
  64086. /**
  64087. * Gets the class name of the effect layer
  64088. * @returns the string with the class name of the effect layer
  64089. */
  64090. getClassName(): string;
  64091. /**
  64092. * Serializes this glow layer
  64093. * @returns a serialized glow layer object
  64094. */
  64095. serialize(): any;
  64096. /**
  64097. * Creates a Glow Layer from parsed glow layer data
  64098. * @param parsedGlowLayer defines glow layer data
  64099. * @param scene defines the current scene
  64100. * @param rootUrl defines the root URL containing the glow layer information
  64101. * @returns a parsed Glow Layer
  64102. */
  64103. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  64104. }
  64105. }
  64106. declare module BABYLON {
  64107. /** @hidden */
  64108. export var glowBlurPostProcessPixelShader: {
  64109. name: string;
  64110. shader: string;
  64111. };
  64112. }
  64113. declare module BABYLON {
  64114. interface AbstractScene {
  64115. /**
  64116. * Return a the first highlight layer of the scene with a given name.
  64117. * @param name The name of the highlight layer to look for.
  64118. * @return The highlight layer if found otherwise null.
  64119. */
  64120. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  64121. }
  64122. /**
  64123. * Highlight layer options. This helps customizing the behaviour
  64124. * of the highlight layer.
  64125. */
  64126. export interface IHighlightLayerOptions {
  64127. /**
  64128. * Multiplication factor apply to the canvas size to compute the render target size
  64129. * used to generated the glowing objects (the smaller the faster).
  64130. */
  64131. mainTextureRatio: number;
  64132. /**
  64133. * Enforces a fixed size texture to ensure resize independent blur.
  64134. */
  64135. mainTextureFixedSize?: number;
  64136. /**
  64137. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  64138. * of the picture to blur (the smaller the faster).
  64139. */
  64140. blurTextureSizeRatio: number;
  64141. /**
  64142. * How big in texel of the blur texture is the vertical blur.
  64143. */
  64144. blurVerticalSize: number;
  64145. /**
  64146. * How big in texel of the blur texture is the horizontal blur.
  64147. */
  64148. blurHorizontalSize: number;
  64149. /**
  64150. * Alpha blending mode used to apply the blur. Default is combine.
  64151. */
  64152. alphaBlendingMode: number;
  64153. /**
  64154. * The camera attached to the layer.
  64155. */
  64156. camera: Nullable<Camera>;
  64157. /**
  64158. * Should we display highlight as a solid stroke?
  64159. */
  64160. isStroke?: boolean;
  64161. /**
  64162. * The rendering group to draw the layer in.
  64163. */
  64164. renderingGroupId: number;
  64165. }
  64166. /**
  64167. * The highlight layer Helps adding a glow effect around a mesh.
  64168. *
  64169. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  64170. * glowy meshes to your scene.
  64171. *
  64172. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  64173. */
  64174. export class HighlightLayer extends EffectLayer {
  64175. name: string;
  64176. /**
  64177. * Effect Name of the highlight layer.
  64178. */
  64179. static readonly EffectName: string;
  64180. /**
  64181. * The neutral color used during the preparation of the glow effect.
  64182. * This is black by default as the blend operation is a blend operation.
  64183. */
  64184. static NeutralColor: Color4;
  64185. /**
  64186. * Stencil value used for glowing meshes.
  64187. */
  64188. static GlowingMeshStencilReference: number;
  64189. /**
  64190. * Stencil value used for the other meshes in the scene.
  64191. */
  64192. static NormalMeshStencilReference: number;
  64193. /**
  64194. * Specifies whether or not the inner glow is ACTIVE in the layer.
  64195. */
  64196. innerGlow: boolean;
  64197. /**
  64198. * Specifies whether or not the outer glow is ACTIVE in the layer.
  64199. */
  64200. outerGlow: boolean;
  64201. /**
  64202. * Specifies the horizontal size of the blur.
  64203. */
  64204. set blurHorizontalSize(value: number);
  64205. /**
  64206. * Specifies the vertical size of the blur.
  64207. */
  64208. set blurVerticalSize(value: number);
  64209. /**
  64210. * Gets the horizontal size of the blur.
  64211. */
  64212. get blurHorizontalSize(): number;
  64213. /**
  64214. * Gets the vertical size of the blur.
  64215. */
  64216. get blurVerticalSize(): number;
  64217. /**
  64218. * An event triggered when the highlight layer is being blurred.
  64219. */
  64220. onBeforeBlurObservable: Observable<HighlightLayer>;
  64221. /**
  64222. * An event triggered when the highlight layer has been blurred.
  64223. */
  64224. onAfterBlurObservable: Observable<HighlightLayer>;
  64225. private _instanceGlowingMeshStencilReference;
  64226. private _options;
  64227. private _downSamplePostprocess;
  64228. private _horizontalBlurPostprocess;
  64229. private _verticalBlurPostprocess;
  64230. private _blurTexture;
  64231. private _meshes;
  64232. private _excludedMeshes;
  64233. /**
  64234. * Instantiates a new highlight Layer and references it to the scene..
  64235. * @param name The name of the layer
  64236. * @param scene The scene to use the layer in
  64237. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  64238. */
  64239. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  64240. /**
  64241. * Get the effect name of the layer.
  64242. * @return The effect name
  64243. */
  64244. getEffectName(): string;
  64245. /**
  64246. * Create the merge effect. This is the shader use to blit the information back
  64247. * to the main canvas at the end of the scene rendering.
  64248. */
  64249. protected _createMergeEffect(): Effect;
  64250. /**
  64251. * Creates the render target textures and post processes used in the highlight layer.
  64252. */
  64253. protected _createTextureAndPostProcesses(): void;
  64254. /**
  64255. * Returns whether or not the layer needs stencil enabled during the mesh rendering.
  64256. */
  64257. needStencil(): boolean;
  64258. /**
  64259. * Checks for the readiness of the element composing the layer.
  64260. * @param subMesh the mesh to check for
  64261. * @param useInstances specify wether or not to use instances to render the mesh
  64262. * @param emissiveTexture the associated emissive texture used to generate the glow
  64263. * @return true if ready otherwise, false
  64264. */
  64265. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64266. /**
  64267. * Implementation specific of rendering the generating effect on the main canvas.
  64268. * @param effect The effect used to render through
  64269. */
  64270. protected _internalRender(effect: Effect): void;
  64271. /**
  64272. * Returns true if the layer contains information to display, otherwise false.
  64273. */
  64274. shouldRender(): boolean;
  64275. /**
  64276. * Returns true if the mesh should render, otherwise false.
  64277. * @param mesh The mesh to render
  64278. * @returns true if it should render otherwise false
  64279. */
  64280. protected _shouldRenderMesh(mesh: Mesh): boolean;
  64281. /**
  64282. * Returns true if the mesh can be rendered, otherwise false.
  64283. * @param mesh The mesh to render
  64284. * @param material The material used on the mesh
  64285. * @returns true if it can be rendered otherwise false
  64286. */
  64287. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  64288. /**
  64289. * Adds specific effects defines.
  64290. * @param defines The defines to add specifics to.
  64291. */
  64292. protected _addCustomEffectDefines(defines: string[]): void;
  64293. /**
  64294. * Sets the required values for both the emissive texture and and the main color.
  64295. */
  64296. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  64297. /**
  64298. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  64299. * @param mesh The mesh to exclude from the highlight layer
  64300. */
  64301. addExcludedMesh(mesh: Mesh): void;
  64302. /**
  64303. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  64304. * @param mesh The mesh to highlight
  64305. */
  64306. removeExcludedMesh(mesh: Mesh): void;
  64307. /**
  64308. * Determine if a given mesh will be highlighted by the current HighlightLayer
  64309. * @param mesh mesh to test
  64310. * @returns true if the mesh will be highlighted by the current HighlightLayer
  64311. */
  64312. hasMesh(mesh: AbstractMesh): boolean;
  64313. /**
  64314. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  64315. * @param mesh The mesh to highlight
  64316. * @param color The color of the highlight
  64317. * @param glowEmissiveOnly Extract the glow from the emissive texture
  64318. */
  64319. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  64320. /**
  64321. * Remove a mesh from the highlight layer in order to make it stop glowing.
  64322. * @param mesh The mesh to highlight
  64323. */
  64324. removeMesh(mesh: Mesh): void;
  64325. /**
  64326. * Remove all the meshes currently referenced in the highlight layer
  64327. */
  64328. removeAllMeshes(): void;
  64329. /**
  64330. * Force the stencil to the normal expected value for none glowing parts
  64331. */
  64332. private _defaultStencilReference;
  64333. /**
  64334. * Free any resources and references associated to a mesh.
  64335. * Internal use
  64336. * @param mesh The mesh to free.
  64337. * @hidden
  64338. */
  64339. _disposeMesh(mesh: Mesh): void;
  64340. /**
  64341. * Dispose the highlight layer and free resources.
  64342. */
  64343. dispose(): void;
  64344. /**
  64345. * Gets the class name of the effect layer
  64346. * @returns the string with the class name of the effect layer
  64347. */
  64348. getClassName(): string;
  64349. /**
  64350. * Serializes this Highlight layer
  64351. * @returns a serialized Highlight layer object
  64352. */
  64353. serialize(): any;
  64354. /**
  64355. * Creates a Highlight layer from parsed Highlight layer data
  64356. * @param parsedHightlightLayer defines the Highlight layer data
  64357. * @param scene defines the current scene
  64358. * @param rootUrl defines the root URL containing the Highlight layer information
  64359. * @returns a parsed Highlight layer
  64360. */
  64361. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  64362. }
  64363. }
  64364. declare module BABYLON {
  64365. interface AbstractScene {
  64366. /**
  64367. * The list of layers (background and foreground) of the scene
  64368. */
  64369. layers: Array<Layer>;
  64370. }
  64371. /**
  64372. * Defines the layer scene component responsible to manage any layers
  64373. * in a given scene.
  64374. */
  64375. export class LayerSceneComponent implements ISceneComponent {
  64376. /**
  64377. * The component name helpful to identify the component in the list of scene components.
  64378. */
  64379. readonly name: string;
  64380. /**
  64381. * The scene the component belongs to.
  64382. */
  64383. scene: Scene;
  64384. private _engine;
  64385. /**
  64386. * Creates a new instance of the component for the given scene
  64387. * @param scene Defines the scene to register the component in
  64388. */
  64389. constructor(scene: Scene);
  64390. /**
  64391. * Registers the component in a given scene
  64392. */
  64393. register(): void;
  64394. /**
  64395. * Rebuilds the elements related to this component in case of
  64396. * context lost for instance.
  64397. */
  64398. rebuild(): void;
  64399. /**
  64400. * Disposes the component and the associated resources.
  64401. */
  64402. dispose(): void;
  64403. private _draw;
  64404. private _drawCameraPredicate;
  64405. private _drawCameraBackground;
  64406. private _drawCameraForeground;
  64407. private _drawRenderTargetPredicate;
  64408. private _drawRenderTargetBackground;
  64409. private _drawRenderTargetForeground;
  64410. /**
  64411. * Adds all the elements from the container to the scene
  64412. * @param container the container holding the elements
  64413. */
  64414. addFromContainer(container: AbstractScene): void;
  64415. /**
  64416. * Removes all the elements in the container from the scene
  64417. * @param container contains the elements to remove
  64418. * @param dispose if the removed element should be disposed (default: false)
  64419. */
  64420. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  64421. }
  64422. }
  64423. declare module BABYLON {
  64424. /** @hidden */
  64425. export var layerPixelShader: {
  64426. name: string;
  64427. shader: string;
  64428. };
  64429. }
  64430. declare module BABYLON {
  64431. /** @hidden */
  64432. export var layerVertexShader: {
  64433. name: string;
  64434. shader: string;
  64435. };
  64436. }
  64437. declare module BABYLON {
  64438. /**
  64439. * This represents a full screen 2d layer.
  64440. * This can be useful to display a picture in the background of your scene for instance.
  64441. * @see https://www.babylonjs-playground.com/#08A2BS#1
  64442. */
  64443. export class Layer {
  64444. /**
  64445. * Define the name of the layer.
  64446. */
  64447. name: string;
  64448. /**
  64449. * Define the texture the layer should display.
  64450. */
  64451. texture: Nullable<Texture>;
  64452. /**
  64453. * Is the layer in background or foreground.
  64454. */
  64455. isBackground: boolean;
  64456. /**
  64457. * Define the color of the layer (instead of texture).
  64458. */
  64459. color: Color4;
  64460. /**
  64461. * Define the scale of the layer in order to zoom in out of the texture.
  64462. */
  64463. scale: Vector2;
  64464. /**
  64465. * Define an offset for the layer in order to shift the texture.
  64466. */
  64467. offset: Vector2;
  64468. /**
  64469. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  64470. */
  64471. alphaBlendingMode: number;
  64472. /**
  64473. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  64474. * Alpha test will not mix with the background color in case of transparency.
  64475. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  64476. */
  64477. alphaTest: boolean;
  64478. /**
  64479. * Define a mask to restrict the layer to only some of the scene cameras.
  64480. */
  64481. layerMask: number;
  64482. /**
  64483. * Define the list of render target the layer is visible into.
  64484. */
  64485. renderTargetTextures: RenderTargetTexture[];
  64486. /**
  64487. * Define if the layer is only used in renderTarget or if it also
  64488. * renders in the main frame buffer of the canvas.
  64489. */
  64490. renderOnlyInRenderTargetTextures: boolean;
  64491. private _scene;
  64492. private _vertexBuffers;
  64493. private _indexBuffer;
  64494. private _effect;
  64495. private _previousDefines;
  64496. /**
  64497. * An event triggered when the layer is disposed.
  64498. */
  64499. onDisposeObservable: Observable<Layer>;
  64500. private _onDisposeObserver;
  64501. /**
  64502. * Back compatibility with callback before the onDisposeObservable existed.
  64503. * The set callback will be triggered when the layer has been disposed.
  64504. */
  64505. set onDispose(callback: () => void);
  64506. /**
  64507. * An event triggered before rendering the scene
  64508. */
  64509. onBeforeRenderObservable: Observable<Layer>;
  64510. private _onBeforeRenderObserver;
  64511. /**
  64512. * Back compatibility with callback before the onBeforeRenderObservable existed.
  64513. * The set callback will be triggered just before rendering the layer.
  64514. */
  64515. set onBeforeRender(callback: () => void);
  64516. /**
  64517. * An event triggered after rendering the scene
  64518. */
  64519. onAfterRenderObservable: Observable<Layer>;
  64520. private _onAfterRenderObserver;
  64521. /**
  64522. * Back compatibility with callback before the onAfterRenderObservable existed.
  64523. * The set callback will be triggered just after rendering the layer.
  64524. */
  64525. set onAfterRender(callback: () => void);
  64526. /**
  64527. * Instantiates a new layer.
  64528. * This represents a full screen 2d layer.
  64529. * This can be useful to display a picture in the background of your scene for instance.
  64530. * @see https://www.babylonjs-playground.com/#08A2BS#1
  64531. * @param name Define the name of the layer in the scene
  64532. * @param imgUrl Define the url of the texture to display in the layer
  64533. * @param scene Define the scene the layer belongs to
  64534. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  64535. * @param color Defines a color for the layer
  64536. */
  64537. constructor(
  64538. /**
  64539. * Define the name of the layer.
  64540. */
  64541. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  64542. private _createIndexBuffer;
  64543. /** @hidden */
  64544. _rebuild(): void;
  64545. /**
  64546. * Renders the layer in the scene.
  64547. */
  64548. render(): void;
  64549. /**
  64550. * Disposes and releases the associated resources.
  64551. */
  64552. dispose(): void;
  64553. }
  64554. }
  64555. declare module BABYLON {
  64556. /** @hidden */
  64557. export var lensFlarePixelShader: {
  64558. name: string;
  64559. shader: string;
  64560. };
  64561. }
  64562. declare module BABYLON {
  64563. /** @hidden */
  64564. export var lensFlareVertexShader: {
  64565. name: string;
  64566. shader: string;
  64567. };
  64568. }
  64569. declare module BABYLON {
  64570. /**
  64571. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  64572. * It is usually composed of several `lensFlare`.
  64573. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  64574. */
  64575. export class LensFlareSystem {
  64576. /**
  64577. * Define the name of the lens flare system
  64578. */
  64579. name: string;
  64580. /**
  64581. * List of lens flares used in this system.
  64582. */
  64583. lensFlares: LensFlare[];
  64584. /**
  64585. * Define a limit from the border the lens flare can be visible.
  64586. */
  64587. borderLimit: number;
  64588. /**
  64589. * Define a viewport border we do not want to see the lens flare in.
  64590. */
  64591. viewportBorder: number;
  64592. /**
  64593. * Define a predicate which could limit the list of meshes able to occlude the effect.
  64594. */
  64595. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  64596. /**
  64597. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  64598. */
  64599. layerMask: number;
  64600. /**
  64601. * Define the id of the lens flare system in the scene.
  64602. * (equal to name by default)
  64603. */
  64604. id: string;
  64605. private _scene;
  64606. private _emitter;
  64607. private _vertexBuffers;
  64608. private _indexBuffer;
  64609. private _effect;
  64610. private _positionX;
  64611. private _positionY;
  64612. private _isEnabled;
  64613. /** @hidden */
  64614. static _SceneComponentInitialization: (scene: Scene) => void;
  64615. /**
  64616. * Instantiates a lens flare system.
  64617. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  64618. * It is usually composed of several `lensFlare`.
  64619. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  64620. * @param name Define the name of the lens flare system in the scene
  64621. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  64622. * @param scene Define the scene the lens flare system belongs to
  64623. */
  64624. constructor(
  64625. /**
  64626. * Define the name of the lens flare system
  64627. */
  64628. name: string, emitter: any, scene: Scene);
  64629. /**
  64630. * Define if the lens flare system is enabled.
  64631. */
  64632. get isEnabled(): boolean;
  64633. set isEnabled(value: boolean);
  64634. /**
  64635. * Get the scene the effects belongs to.
  64636. * @returns the scene holding the lens flare system
  64637. */
  64638. getScene(): Scene;
  64639. /**
  64640. * Get the emitter of the lens flare system.
  64641. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  64642. * @returns the emitter of the lens flare system
  64643. */
  64644. getEmitter(): any;
  64645. /**
  64646. * Set the emitter of the lens flare system.
  64647. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  64648. * @param newEmitter Define the new emitter of the system
  64649. */
  64650. setEmitter(newEmitter: any): void;
  64651. /**
  64652. * Get the lens flare system emitter position.
  64653. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  64654. * @returns the position
  64655. */
  64656. getEmitterPosition(): Vector3;
  64657. /**
  64658. * @hidden
  64659. */
  64660. computeEffectivePosition(globalViewport: Viewport): boolean;
  64661. /** @hidden */
  64662. _isVisible(): boolean;
  64663. /**
  64664. * @hidden
  64665. */
  64666. render(): boolean;
  64667. /**
  64668. * Dispose and release the lens flare with its associated resources.
  64669. */
  64670. dispose(): void;
  64671. /**
  64672. * Parse a lens flare system from a JSON representation
  64673. * @param parsedLensFlareSystem Define the JSON to parse
  64674. * @param scene Define the scene the parsed system should be instantiated in
  64675. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  64676. * @returns the parsed system
  64677. */
  64678. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  64679. /**
  64680. * Serialize the current Lens Flare System into a JSON representation.
  64681. * @returns the serialized JSON
  64682. */
  64683. serialize(): any;
  64684. }
  64685. }
  64686. declare module BABYLON {
  64687. /**
  64688. * This represents one of the lens effect in a `lensFlareSystem`.
  64689. * It controls one of the individual texture used in the effect.
  64690. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  64691. */
  64692. export class LensFlare {
  64693. /**
  64694. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  64695. */
  64696. size: number;
  64697. /**
  64698. * 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.
  64699. */
  64700. position: number;
  64701. /**
  64702. * Define the lens color.
  64703. */
  64704. color: Color3;
  64705. /**
  64706. * Define the lens texture.
  64707. */
  64708. texture: Nullable<Texture>;
  64709. /**
  64710. * Define the alpha mode to render this particular lens.
  64711. */
  64712. alphaMode: number;
  64713. private _system;
  64714. /**
  64715. * Creates a new Lens Flare.
  64716. * This represents one of the lens effect in a `lensFlareSystem`.
  64717. * It controls one of the individual texture used in the effect.
  64718. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  64719. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  64720. * @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.
  64721. * @param color Define the lens color
  64722. * @param imgUrl Define the lens texture url
  64723. * @param system Define the `lensFlareSystem` this flare is part of
  64724. * @returns The newly created Lens Flare
  64725. */
  64726. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  64727. /**
  64728. * Instantiates a new Lens Flare.
  64729. * This represents one of the lens effect in a `lensFlareSystem`.
  64730. * It controls one of the individual texture used in the effect.
  64731. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  64732. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  64733. * @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.
  64734. * @param color Define the lens color
  64735. * @param imgUrl Define the lens texture url
  64736. * @param system Define the `lensFlareSystem` this flare is part of
  64737. */
  64738. constructor(
  64739. /**
  64740. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  64741. */
  64742. size: number,
  64743. /**
  64744. * 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.
  64745. */
  64746. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  64747. /**
  64748. * Dispose and release the lens flare with its associated resources.
  64749. */
  64750. dispose(): void;
  64751. }
  64752. }
  64753. declare module BABYLON {
  64754. interface AbstractScene {
  64755. /**
  64756. * The list of lens flare system added to the scene
  64757. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  64758. */
  64759. lensFlareSystems: Array<LensFlareSystem>;
  64760. /**
  64761. * Removes the given lens flare system from this scene.
  64762. * @param toRemove The lens flare system to remove
  64763. * @returns The index of the removed lens flare system
  64764. */
  64765. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  64766. /**
  64767. * Adds the given lens flare system to this scene
  64768. * @param newLensFlareSystem The lens flare system to add
  64769. */
  64770. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  64771. /**
  64772. * Gets a lens flare system using its name
  64773. * @param name defines the name to look for
  64774. * @returns the lens flare system or null if not found
  64775. */
  64776. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  64777. /**
  64778. * Gets a lens flare system using its id
  64779. * @param id defines the id to look for
  64780. * @returns the lens flare system or null if not found
  64781. */
  64782. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  64783. }
  64784. /**
  64785. * Defines the lens flare scene component responsible to manage any lens flares
  64786. * in a given scene.
  64787. */
  64788. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  64789. /**
  64790. * The component name helpful to identify the component in the list of scene components.
  64791. */
  64792. readonly name: string;
  64793. /**
  64794. * The scene the component belongs to.
  64795. */
  64796. scene: Scene;
  64797. /**
  64798. * Creates a new instance of the component for the given scene
  64799. * @param scene Defines the scene to register the component in
  64800. */
  64801. constructor(scene: Scene);
  64802. /**
  64803. * Registers the component in a given scene
  64804. */
  64805. register(): void;
  64806. /**
  64807. * Rebuilds the elements related to this component in case of
  64808. * context lost for instance.
  64809. */
  64810. rebuild(): void;
  64811. /**
  64812. * Adds all the elements from the container to the scene
  64813. * @param container the container holding the elements
  64814. */
  64815. addFromContainer(container: AbstractScene): void;
  64816. /**
  64817. * Removes all the elements in the container from the scene
  64818. * @param container contains the elements to remove
  64819. * @param dispose if the removed element should be disposed (default: false)
  64820. */
  64821. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  64822. /**
  64823. * Serializes the component data to the specified json object
  64824. * @param serializationObject The object to serialize to
  64825. */
  64826. serialize(serializationObject: any): void;
  64827. /**
  64828. * Disposes the component and the associated resources.
  64829. */
  64830. dispose(): void;
  64831. private _draw;
  64832. }
  64833. }
  64834. declare module BABYLON {
  64835. /** @hidden */
  64836. export var depthPixelShader: {
  64837. name: string;
  64838. shader: string;
  64839. };
  64840. }
  64841. declare module BABYLON {
  64842. /** @hidden */
  64843. export var depthVertexShader: {
  64844. name: string;
  64845. shader: string;
  64846. };
  64847. }
  64848. declare module BABYLON {
  64849. /**
  64850. * This represents a depth renderer in Babylon.
  64851. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  64852. */
  64853. export class DepthRenderer {
  64854. private _scene;
  64855. private _depthMap;
  64856. private _effect;
  64857. private readonly _storeNonLinearDepth;
  64858. private readonly _clearColor;
  64859. /** Get if the depth renderer is using packed depth or not */
  64860. readonly isPacked: boolean;
  64861. private _cachedDefines;
  64862. private _camera;
  64863. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  64864. enabled: boolean;
  64865. /**
  64866. * Specifies that the depth renderer will only be used within
  64867. * the camera it is created for.
  64868. * This can help forcing its rendering during the camera processing.
  64869. */
  64870. useOnlyInActiveCamera: boolean;
  64871. /** @hidden */
  64872. static _SceneComponentInitialization: (scene: Scene) => void;
  64873. /**
  64874. * Instantiates a depth renderer
  64875. * @param scene The scene the renderer belongs to
  64876. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  64877. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  64878. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  64879. */
  64880. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  64881. /**
  64882. * Creates the depth rendering effect and checks if the effect is ready.
  64883. * @param subMesh The submesh to be used to render the depth map of
  64884. * @param useInstances If multiple world instances should be used
  64885. * @returns if the depth renderer is ready to render the depth map
  64886. */
  64887. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64888. /**
  64889. * Gets the texture which the depth map will be written to.
  64890. * @returns The depth map texture
  64891. */
  64892. getDepthMap(): RenderTargetTexture;
  64893. /**
  64894. * Disposes of the depth renderer.
  64895. */
  64896. dispose(): void;
  64897. }
  64898. }
  64899. declare module BABYLON {
  64900. /** @hidden */
  64901. export var minmaxReduxPixelShader: {
  64902. name: string;
  64903. shader: string;
  64904. };
  64905. }
  64906. declare module BABYLON {
  64907. /**
  64908. * This class computes a min/max reduction from a texture: it means it computes the minimum
  64909. * and maximum values from all values of the texture.
  64910. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  64911. * The source values are read from the red channel of the texture.
  64912. */
  64913. export class MinMaxReducer {
  64914. /**
  64915. * Observable triggered when the computation has been performed
  64916. */
  64917. onAfterReductionPerformed: Observable<{
  64918. min: number;
  64919. max: number;
  64920. }>;
  64921. protected _camera: Camera;
  64922. protected _sourceTexture: Nullable<RenderTargetTexture>;
  64923. protected _reductionSteps: Nullable<Array<PostProcess>>;
  64924. protected _postProcessManager: PostProcessManager;
  64925. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  64926. protected _forceFullscreenViewport: boolean;
  64927. /**
  64928. * Creates a min/max reducer
  64929. * @param camera The camera to use for the post processes
  64930. */
  64931. constructor(camera: Camera);
  64932. /**
  64933. * Gets the texture used to read the values from.
  64934. */
  64935. get sourceTexture(): Nullable<RenderTargetTexture>;
  64936. /**
  64937. * Sets the source texture to read the values from.
  64938. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  64939. * because in such textures '1' value must not be taken into account to compute the maximum
  64940. * as this value is used to clear the texture.
  64941. * Note that the computation is not activated by calling this function, you must call activate() for that!
  64942. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  64943. * @param depthRedux Indicates if the texture is a depth texture or not
  64944. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  64945. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  64946. */
  64947. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  64948. /**
  64949. * Defines the refresh rate of the computation.
  64950. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  64951. */
  64952. get refreshRate(): number;
  64953. set refreshRate(value: number);
  64954. protected _activated: boolean;
  64955. /**
  64956. * Gets the activation status of the reducer
  64957. */
  64958. get activated(): boolean;
  64959. /**
  64960. * Activates the reduction computation.
  64961. * When activated, the observers registered in onAfterReductionPerformed are
  64962. * called after the computation is performed
  64963. */
  64964. activate(): void;
  64965. /**
  64966. * Deactivates the reduction computation.
  64967. */
  64968. deactivate(): void;
  64969. /**
  64970. * Disposes the min/max reducer
  64971. * @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.
  64972. */
  64973. dispose(disposeAll?: boolean): void;
  64974. }
  64975. }
  64976. declare module BABYLON {
  64977. /**
  64978. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  64979. */
  64980. export class DepthReducer extends MinMaxReducer {
  64981. private _depthRenderer;
  64982. private _depthRendererId;
  64983. /**
  64984. * Gets the depth renderer used for the computation.
  64985. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  64986. */
  64987. get depthRenderer(): Nullable<DepthRenderer>;
  64988. /**
  64989. * Creates a depth reducer
  64990. * @param camera The camera used to render the depth texture
  64991. */
  64992. constructor(camera: Camera);
  64993. /**
  64994. * Sets the depth renderer to use to generate the depth map
  64995. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  64996. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  64997. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  64998. */
  64999. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  65000. /** @hidden */
  65001. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  65002. /**
  65003. * Activates the reduction computation.
  65004. * When activated, the observers registered in onAfterReductionPerformed are
  65005. * called after the computation is performed
  65006. */
  65007. activate(): void;
  65008. /**
  65009. * Deactivates the reduction computation.
  65010. */
  65011. deactivate(): void;
  65012. /**
  65013. * Disposes the depth reducer
  65014. * @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.
  65015. */
  65016. dispose(disposeAll?: boolean): void;
  65017. }
  65018. }
  65019. declare module BABYLON {
  65020. /**
  65021. * A CSM implementation allowing casting shadows on large scenes.
  65022. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  65023. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  65024. */
  65025. export class CascadedShadowGenerator extends ShadowGenerator {
  65026. private static readonly frustumCornersNDCSpace;
  65027. /**
  65028. * Name of the CSM class
  65029. */
  65030. static CLASSNAME: string;
  65031. /**
  65032. * Defines the default number of cascades used by the CSM.
  65033. */
  65034. static readonly DEFAULT_CASCADES_COUNT: number;
  65035. /**
  65036. * Defines the minimum number of cascades used by the CSM.
  65037. */
  65038. static readonly MIN_CASCADES_COUNT: number;
  65039. /**
  65040. * Defines the maximum number of cascades used by the CSM.
  65041. */
  65042. static readonly MAX_CASCADES_COUNT: number;
  65043. protected _validateFilter(filter: number): number;
  65044. /**
  65045. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  65046. */
  65047. penumbraDarkness: number;
  65048. private _numCascades;
  65049. /**
  65050. * Gets or set the number of cascades used by the CSM.
  65051. */
  65052. get numCascades(): number;
  65053. set numCascades(value: number);
  65054. /**
  65055. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  65056. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  65057. */
  65058. stabilizeCascades: boolean;
  65059. private _freezeShadowCastersBoundingInfo;
  65060. private _freezeShadowCastersBoundingInfoObservable;
  65061. /**
  65062. * Enables or disables the shadow casters bounding info computation.
  65063. * If your shadow casters don't move, you can disable this feature.
  65064. * If it is enabled, the bounding box computation is done every frame.
  65065. */
  65066. get freezeShadowCastersBoundingInfo(): boolean;
  65067. set freezeShadowCastersBoundingInfo(freeze: boolean);
  65068. private _scbiMin;
  65069. private _scbiMax;
  65070. protected _computeShadowCastersBoundingInfo(): void;
  65071. protected _shadowCastersBoundingInfo: BoundingInfo;
  65072. /**
  65073. * Gets or sets the shadow casters bounding info.
  65074. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  65075. * so that the system won't overwrite the bounds you provide
  65076. */
  65077. get shadowCastersBoundingInfo(): BoundingInfo;
  65078. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  65079. protected _breaksAreDirty: boolean;
  65080. protected _minDistance: number;
  65081. protected _maxDistance: number;
  65082. /**
  65083. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  65084. *
  65085. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  65086. * If you don't know these values, simply leave them to their defaults and don't call this function.
  65087. * @param min minimal distance for the breaks (default to 0.)
  65088. * @param max maximal distance for the breaks (default to 1.)
  65089. */
  65090. setMinMaxDistance(min: number, max: number): void;
  65091. /** Gets the minimal distance used in the cascade break computation */
  65092. get minDistance(): number;
  65093. /** Gets the maximal distance used in the cascade break computation */
  65094. get maxDistance(): number;
  65095. /**
  65096. * Gets the class name of that object
  65097. * @returns "CascadedShadowGenerator"
  65098. */
  65099. getClassName(): string;
  65100. private _cascadeMinExtents;
  65101. private _cascadeMaxExtents;
  65102. /**
  65103. * Gets a cascade minimum extents
  65104. * @param cascadeIndex index of the cascade
  65105. * @returns the minimum cascade extents
  65106. */
  65107. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  65108. /**
  65109. * Gets a cascade maximum extents
  65110. * @param cascadeIndex index of the cascade
  65111. * @returns the maximum cascade extents
  65112. */
  65113. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  65114. private _cascades;
  65115. private _currentLayer;
  65116. private _viewSpaceFrustumsZ;
  65117. private _viewMatrices;
  65118. private _projectionMatrices;
  65119. private _transformMatrices;
  65120. private _transformMatricesAsArray;
  65121. private _frustumLengths;
  65122. private _lightSizeUVCorrection;
  65123. private _depthCorrection;
  65124. private _frustumCornersWorldSpace;
  65125. private _frustumCenter;
  65126. private _shadowCameraPos;
  65127. private _shadowMaxZ;
  65128. /**
  65129. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  65130. * It defaults to camera.maxZ
  65131. */
  65132. get shadowMaxZ(): number;
  65133. /**
  65134. * Sets the shadow max z distance.
  65135. */
  65136. set shadowMaxZ(value: number);
  65137. protected _debug: boolean;
  65138. /**
  65139. * Gets or sets the debug flag.
  65140. * When enabled, the cascades are materialized by different colors on the screen.
  65141. */
  65142. get debug(): boolean;
  65143. set debug(dbg: boolean);
  65144. private _depthClamp;
  65145. /**
  65146. * Gets or sets the depth clamping value.
  65147. *
  65148. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  65149. * to account for the shadow casters far away.
  65150. *
  65151. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  65152. */
  65153. get depthClamp(): boolean;
  65154. set depthClamp(value: boolean);
  65155. private _cascadeBlendPercentage;
  65156. /**
  65157. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  65158. * It defaults to 0.1 (10% blending).
  65159. */
  65160. get cascadeBlendPercentage(): number;
  65161. set cascadeBlendPercentage(value: number);
  65162. private _lambda;
  65163. /**
  65164. * Gets or set the lambda parameter.
  65165. * This parameter is used to split the camera frustum and create the cascades.
  65166. * 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.
  65167. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  65168. */
  65169. get lambda(): number;
  65170. set lambda(value: number);
  65171. /**
  65172. * Gets the view matrix corresponding to a given cascade
  65173. * @param cascadeNum cascade to retrieve the view matrix from
  65174. * @returns the cascade view matrix
  65175. */
  65176. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  65177. /**
  65178. * Gets the projection matrix corresponding to a given cascade
  65179. * @param cascadeNum cascade to retrieve the projection matrix from
  65180. * @returns the cascade projection matrix
  65181. */
  65182. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  65183. /**
  65184. * Gets the transformation matrix corresponding to a given cascade
  65185. * @param cascadeNum cascade to retrieve the transformation matrix from
  65186. * @returns the cascade transformation matrix
  65187. */
  65188. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  65189. private _depthRenderer;
  65190. /**
  65191. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  65192. *
  65193. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  65194. *
  65195. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  65196. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  65197. * @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
  65198. */
  65199. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  65200. private _depthReducer;
  65201. private _autoCalcDepthBounds;
  65202. /**
  65203. * Gets or sets the autoCalcDepthBounds property.
  65204. *
  65205. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  65206. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  65207. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  65208. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  65209. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  65210. */
  65211. get autoCalcDepthBounds(): boolean;
  65212. set autoCalcDepthBounds(value: boolean);
  65213. /**
  65214. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  65215. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  65216. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  65217. * for setting the refresh rate on the renderer yourself!
  65218. */
  65219. get autoCalcDepthBoundsRefreshRate(): number;
  65220. set autoCalcDepthBoundsRefreshRate(value: number);
  65221. /**
  65222. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  65223. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  65224. * you change the camera near/far planes!
  65225. */
  65226. splitFrustum(): void;
  65227. private _splitFrustum;
  65228. private _computeMatrices;
  65229. private _computeFrustumInWorldSpace;
  65230. private _computeCascadeFrustum;
  65231. /**
  65232. * Support test.
  65233. */
  65234. static get IsSupported(): boolean;
  65235. /** @hidden */
  65236. static _SceneComponentInitialization: (scene: Scene) => void;
  65237. /**
  65238. * Creates a Cascaded Shadow Generator object.
  65239. * A ShadowGenerator is the required tool to use the shadows.
  65240. * Each directional light casting shadows needs to use its own ShadowGenerator.
  65241. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  65242. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  65243. * @param light The directional light object generating the shadows.
  65244. * @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.
  65245. */
  65246. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  65247. protected _initializeGenerator(): void;
  65248. protected _createTargetRenderTexture(): void;
  65249. protected _initializeShadowMap(): void;
  65250. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  65251. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  65252. /**
  65253. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  65254. * @param defines Defines of the material we want to update
  65255. * @param lightIndex Index of the light in the enabled light list of the material
  65256. */
  65257. prepareDefines(defines: any, lightIndex: number): void;
  65258. /**
  65259. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  65260. * defined in the generator but impacting the effect).
  65261. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  65262. * @param effect The effect we are binfing the information for
  65263. */
  65264. bindShadowLight(lightIndex: string, effect: Effect): void;
  65265. /**
  65266. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  65267. * (eq to view projection * shadow projection matrices)
  65268. * @returns The transform matrix used to create the shadow map
  65269. */
  65270. getTransformMatrix(): Matrix;
  65271. /**
  65272. * Disposes the ShadowGenerator.
  65273. * Returns nothing.
  65274. */
  65275. dispose(): void;
  65276. /**
  65277. * Serializes the shadow generator setup to a json object.
  65278. * @returns The serialized JSON object
  65279. */
  65280. serialize(): any;
  65281. /**
  65282. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  65283. * @param parsedShadowGenerator The JSON object to parse
  65284. * @param scene The scene to create the shadow map for
  65285. * @returns The parsed shadow generator
  65286. */
  65287. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  65288. }
  65289. }
  65290. declare module BABYLON {
  65291. /**
  65292. * Defines the shadow generator component responsible to manage any shadow generators
  65293. * in a given scene.
  65294. */
  65295. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  65296. /**
  65297. * The component name helpful to identify the component in the list of scene components.
  65298. */
  65299. readonly name: string;
  65300. /**
  65301. * The scene the component belongs to.
  65302. */
  65303. scene: Scene;
  65304. /**
  65305. * Creates a new instance of the component for the given scene
  65306. * @param scene Defines the scene to register the component in
  65307. */
  65308. constructor(scene: Scene);
  65309. /**
  65310. * Registers the component in a given scene
  65311. */
  65312. register(): void;
  65313. /**
  65314. * Rebuilds the elements related to this component in case of
  65315. * context lost for instance.
  65316. */
  65317. rebuild(): void;
  65318. /**
  65319. * Serializes the component data to the specified json object
  65320. * @param serializationObject The object to serialize to
  65321. */
  65322. serialize(serializationObject: any): void;
  65323. /**
  65324. * Adds all the elements from the container to the scene
  65325. * @param container the container holding the elements
  65326. */
  65327. addFromContainer(container: AbstractScene): void;
  65328. /**
  65329. * Removes all the elements in the container from the scene
  65330. * @param container contains the elements to remove
  65331. * @param dispose if the removed element should be disposed (default: false)
  65332. */
  65333. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  65334. /**
  65335. * Rebuilds the elements related to this component in case of
  65336. * context lost for instance.
  65337. */
  65338. dispose(): void;
  65339. private _gatherRenderTargets;
  65340. }
  65341. }
  65342. declare module BABYLON {
  65343. /**
  65344. * A point light is a light defined by an unique point in world space.
  65345. * The light is emitted in every direction from this point.
  65346. * A good example of a point light is a standard light bulb.
  65347. * Documentation: https://doc.babylonjs.com/babylon101/lights
  65348. */
  65349. export class PointLight extends ShadowLight {
  65350. private _shadowAngle;
  65351. /**
  65352. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  65353. * This specifies what angle the shadow will use to be created.
  65354. *
  65355. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  65356. */
  65357. get shadowAngle(): number;
  65358. /**
  65359. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  65360. * This specifies what angle the shadow will use to be created.
  65361. *
  65362. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  65363. */
  65364. set shadowAngle(value: number);
  65365. /**
  65366. * Gets the direction if it has been set.
  65367. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  65368. */
  65369. get direction(): Vector3;
  65370. /**
  65371. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  65372. */
  65373. set direction(value: Vector3);
  65374. /**
  65375. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  65376. * A PointLight emits the light in every direction.
  65377. * It can cast shadows.
  65378. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  65379. * ```javascript
  65380. * var pointLight = new PointLight("pl", camera.position, scene);
  65381. * ```
  65382. * Documentation : https://doc.babylonjs.com/babylon101/lights
  65383. * @param name The light friendly name
  65384. * @param position The position of the point light in the scene
  65385. * @param scene The scene the lights belongs to
  65386. */
  65387. constructor(name: string, position: Vector3, scene: Scene);
  65388. /**
  65389. * Returns the string "PointLight"
  65390. * @returns the class name
  65391. */
  65392. getClassName(): string;
  65393. /**
  65394. * Returns the integer 0.
  65395. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  65396. */
  65397. getTypeID(): number;
  65398. /**
  65399. * Specifies whether or not the shadowmap should be a cube texture.
  65400. * @returns true if the shadowmap needs to be a cube texture.
  65401. */
  65402. needCube(): boolean;
  65403. /**
  65404. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  65405. * @param faceIndex The index of the face we are computed the direction to generate shadow
  65406. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  65407. */
  65408. getShadowDirection(faceIndex?: number): Vector3;
  65409. /**
  65410. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  65411. * - fov = PI / 2
  65412. * - aspect ratio : 1.0
  65413. * - z-near and far equal to the active camera minZ and maxZ.
  65414. * Returns the PointLight.
  65415. */
  65416. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  65417. protected _buildUniformLayout(): void;
  65418. /**
  65419. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  65420. * @param effect The effect to update
  65421. * @param lightIndex The index of the light in the effect to update
  65422. * @returns The point light
  65423. */
  65424. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  65425. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  65426. /**
  65427. * Prepares the list of defines specific to the light type.
  65428. * @param defines the list of defines
  65429. * @param lightIndex defines the index of the light for the effect
  65430. */
  65431. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  65432. }
  65433. }
  65434. declare module BABYLON {
  65435. /**
  65436. * Header information of HDR texture files.
  65437. */
  65438. export interface HDRInfo {
  65439. /**
  65440. * The height of the texture in pixels.
  65441. */
  65442. height: number;
  65443. /**
  65444. * The width of the texture in pixels.
  65445. */
  65446. width: number;
  65447. /**
  65448. * The index of the beginning of the data in the binary file.
  65449. */
  65450. dataPosition: number;
  65451. }
  65452. /**
  65453. * This groups tools to convert HDR texture to native colors array.
  65454. */
  65455. export class HDRTools {
  65456. private static Ldexp;
  65457. private static Rgbe2float;
  65458. private static readStringLine;
  65459. /**
  65460. * Reads header information from an RGBE texture stored in a native array.
  65461. * More information on this format are available here:
  65462. * https://en.wikipedia.org/wiki/RGBE_image_format
  65463. *
  65464. * @param uint8array The binary file stored in native array.
  65465. * @return The header information.
  65466. */
  65467. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  65468. /**
  65469. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  65470. * This RGBE texture needs to store the information as a panorama.
  65471. *
  65472. * More information on this format are available here:
  65473. * https://en.wikipedia.org/wiki/RGBE_image_format
  65474. *
  65475. * @param buffer The binary file stored in an array buffer.
  65476. * @param size The expected size of the extracted cubemap.
  65477. * @return The Cube Map information.
  65478. */
  65479. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  65480. /**
  65481. * Returns the pixels data extracted from an RGBE texture.
  65482. * This pixels will be stored left to right up to down in the R G B order in one array.
  65483. *
  65484. * More information on this format are available here:
  65485. * https://en.wikipedia.org/wiki/RGBE_image_format
  65486. *
  65487. * @param uint8array The binary file stored in an array buffer.
  65488. * @param hdrInfo The header information of the file.
  65489. * @return The pixels data in RGB right to left up to down order.
  65490. */
  65491. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  65492. private static RGBE_ReadPixels_RLE;
  65493. private static RGBE_ReadPixels_NOT_RLE;
  65494. }
  65495. }
  65496. declare module BABYLON {
  65497. /**
  65498. * Effect Render Options
  65499. */
  65500. export interface IEffectRendererOptions {
  65501. /**
  65502. * Defines the vertices positions.
  65503. */
  65504. positions?: number[];
  65505. /**
  65506. * Defines the indices.
  65507. */
  65508. indices?: number[];
  65509. }
  65510. /**
  65511. * Helper class to render one or more effects.
  65512. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  65513. */
  65514. export class EffectRenderer {
  65515. private engine;
  65516. private static _DefaultOptions;
  65517. private _vertexBuffers;
  65518. private _indexBuffer;
  65519. private _fullscreenViewport;
  65520. /**
  65521. * Creates an effect renderer
  65522. * @param engine the engine to use for rendering
  65523. * @param options defines the options of the effect renderer
  65524. */
  65525. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  65526. /**
  65527. * Sets the current viewport in normalized coordinates 0-1
  65528. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  65529. */
  65530. setViewport(viewport?: Viewport): void;
  65531. /**
  65532. * Binds the embedded attributes buffer to the effect.
  65533. * @param effect Defines the effect to bind the attributes for
  65534. */
  65535. bindBuffers(effect: Effect): void;
  65536. /**
  65537. * Sets the current effect wrapper to use during draw.
  65538. * The effect needs to be ready before calling this api.
  65539. * This also sets the default full screen position attribute.
  65540. * @param effectWrapper Defines the effect to draw with
  65541. */
  65542. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  65543. /**
  65544. * Restores engine states
  65545. */
  65546. restoreStates(): void;
  65547. /**
  65548. * Draws a full screen quad.
  65549. */
  65550. draw(): void;
  65551. private isRenderTargetTexture;
  65552. /**
  65553. * renders one or more effects to a specified texture
  65554. * @param effectWrapper the effect to renderer
  65555. * @param outputTexture texture to draw to, if null it will render to the screen.
  65556. */
  65557. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  65558. /**
  65559. * Disposes of the effect renderer
  65560. */
  65561. dispose(): void;
  65562. }
  65563. /**
  65564. * Options to create an EffectWrapper
  65565. */
  65566. interface EffectWrapperCreationOptions {
  65567. /**
  65568. * Engine to use to create the effect
  65569. */
  65570. engine: ThinEngine;
  65571. /**
  65572. * Fragment shader for the effect
  65573. */
  65574. fragmentShader: string;
  65575. /**
  65576. * Use the shader store instead of direct source code
  65577. */
  65578. useShaderStore?: boolean;
  65579. /**
  65580. * Vertex shader for the effect
  65581. */
  65582. vertexShader?: string;
  65583. /**
  65584. * Attributes to use in the shader
  65585. */
  65586. attributeNames?: Array<string>;
  65587. /**
  65588. * Uniforms to use in the shader
  65589. */
  65590. uniformNames?: Array<string>;
  65591. /**
  65592. * Texture sampler names to use in the shader
  65593. */
  65594. samplerNames?: Array<string>;
  65595. /**
  65596. * Defines to use in the shader
  65597. */
  65598. defines?: Array<string>;
  65599. /**
  65600. * Callback when effect is compiled
  65601. */
  65602. onCompiled?: Nullable<(effect: Effect) => void>;
  65603. /**
  65604. * The friendly name of the effect displayed in Spector.
  65605. */
  65606. name?: string;
  65607. }
  65608. /**
  65609. * Wraps an effect to be used for rendering
  65610. */
  65611. export class EffectWrapper {
  65612. /**
  65613. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  65614. */
  65615. onApplyObservable: Observable<{}>;
  65616. /**
  65617. * The underlying effect
  65618. */
  65619. effect: Effect;
  65620. /**
  65621. * Creates an effect to be renderer
  65622. * @param creationOptions options to create the effect
  65623. */
  65624. constructor(creationOptions: EffectWrapperCreationOptions);
  65625. /**
  65626. * Disposes of the effect wrapper
  65627. */
  65628. dispose(): void;
  65629. }
  65630. }
  65631. declare module BABYLON {
  65632. /** @hidden */
  65633. export var hdrFilteringVertexShader: {
  65634. name: string;
  65635. shader: string;
  65636. };
  65637. }
  65638. declare module BABYLON {
  65639. /** @hidden */
  65640. export var hdrFilteringPixelShader: {
  65641. name: string;
  65642. shader: string;
  65643. };
  65644. }
  65645. declare module BABYLON {
  65646. /**
  65647. * Options for texture filtering
  65648. */
  65649. interface IHDRFilteringOptions {
  65650. /**
  65651. * Scales pixel intensity for the input HDR map.
  65652. */
  65653. hdrScale?: number;
  65654. /**
  65655. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  65656. */
  65657. quality?: number;
  65658. }
  65659. /**
  65660. * Filters HDR maps to get correct renderings of PBR reflections
  65661. */
  65662. export class HDRFiltering {
  65663. private _engine;
  65664. private _effectRenderer;
  65665. private _effectWrapper;
  65666. private _lodGenerationOffset;
  65667. private _lodGenerationScale;
  65668. /**
  65669. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  65670. * you care about baking speed.
  65671. */
  65672. quality: number;
  65673. /**
  65674. * Scales pixel intensity for the input HDR map.
  65675. */
  65676. hdrScale: number;
  65677. /**
  65678. * Instantiates HDR filter for reflection maps
  65679. *
  65680. * @param engine Thin engine
  65681. * @param options Options
  65682. */
  65683. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  65684. private _createRenderTarget;
  65685. private _prefilterInternal;
  65686. private _createEffect;
  65687. /**
  65688. * Get a value indicating if the filter is ready to be used
  65689. * @param texture Texture to filter
  65690. * @returns true if the filter is ready
  65691. */
  65692. isReady(texture: BaseTexture): boolean;
  65693. /**
  65694. * Prefilters a cube texture to have mipmap levels representing roughness values.
  65695. * Prefiltering will be invoked at the end of next rendering pass.
  65696. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  65697. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  65698. * @param texture Texture to filter
  65699. * @param onFinished Callback when filtering is done
  65700. * @return Promise called when prefiltering is done
  65701. */
  65702. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<void>;
  65703. }
  65704. }
  65705. declare module BABYLON {
  65706. /**
  65707. * This represents a texture coming from an HDR input.
  65708. *
  65709. * The only supported format is currently panorama picture stored in RGBE format.
  65710. * Example of such files can be found on HDRLib: http://hdrlib.com/
  65711. */
  65712. export class HDRCubeTexture extends BaseTexture {
  65713. private static _facesMapping;
  65714. private _generateHarmonics;
  65715. private _noMipmap;
  65716. private _prefilterOnLoad;
  65717. private _textureMatrix;
  65718. private _size;
  65719. private _onLoad;
  65720. private _onError;
  65721. /**
  65722. * The texture URL.
  65723. */
  65724. url: string;
  65725. protected _isBlocking: boolean;
  65726. /**
  65727. * Sets whether or not the texture is blocking during loading.
  65728. */
  65729. set isBlocking(value: boolean);
  65730. /**
  65731. * Gets whether or not the texture is blocking during loading.
  65732. */
  65733. get isBlocking(): boolean;
  65734. protected _rotationY: number;
  65735. /**
  65736. * Sets texture matrix rotation angle around Y axis in radians.
  65737. */
  65738. set rotationY(value: number);
  65739. /**
  65740. * Gets texture matrix rotation angle around Y axis radians.
  65741. */
  65742. get rotationY(): number;
  65743. /**
  65744. * Gets or sets the center of the bounding box associated with the cube texture
  65745. * It must define where the camera used to render the texture was set
  65746. */
  65747. boundingBoxPosition: Vector3;
  65748. private _boundingBoxSize;
  65749. /**
  65750. * Gets or sets the size of the bounding box associated with the cube texture
  65751. * When defined, the cubemap will switch to local mode
  65752. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  65753. * @example https://www.babylonjs-playground.com/#RNASML
  65754. */
  65755. set boundingBoxSize(value: Vector3);
  65756. get boundingBoxSize(): Vector3;
  65757. /**
  65758. * Instantiates an HDRTexture from the following parameters.
  65759. *
  65760. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  65761. * @param sceneOrEngine The scene or engine the texture will be used in
  65762. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  65763. * @param noMipmap Forces to not generate the mipmap if true
  65764. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  65765. * @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)
  65766. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  65767. */
  65768. 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>);
  65769. /**
  65770. * Get the current class name of the texture useful for serialization or dynamic coding.
  65771. * @returns "HDRCubeTexture"
  65772. */
  65773. getClassName(): string;
  65774. /**
  65775. * Occurs when the file is raw .hdr file.
  65776. */
  65777. private loadTexture;
  65778. clone(): HDRCubeTexture;
  65779. delayLoad(): void;
  65780. /**
  65781. * Get the texture reflection matrix used to rotate/transform the reflection.
  65782. * @returns the reflection matrix
  65783. */
  65784. getReflectionTextureMatrix(): Matrix;
  65785. /**
  65786. * Set the texture reflection matrix used to rotate/transform the reflection.
  65787. * @param value Define the reflection matrix to set
  65788. */
  65789. setReflectionTextureMatrix(value: Matrix): void;
  65790. /**
  65791. * Parses a JSON representation of an HDR Texture in order to create the texture
  65792. * @param parsedTexture Define the JSON representation
  65793. * @param scene Define the scene the texture should be created in
  65794. * @param rootUrl Define the root url in case we need to load relative dependencies
  65795. * @returns the newly created texture after parsing
  65796. */
  65797. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  65798. serialize(): any;
  65799. }
  65800. }
  65801. declare module BABYLON {
  65802. /**
  65803. * Class used to control physics engine
  65804. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  65805. */
  65806. export class PhysicsEngine implements IPhysicsEngine {
  65807. private _physicsPlugin;
  65808. /**
  65809. * Global value used to control the smallest number supported by the simulation
  65810. */
  65811. static Epsilon: number;
  65812. private _impostors;
  65813. private _joints;
  65814. private _subTimeStep;
  65815. /**
  65816. * Gets the gravity vector used by the simulation
  65817. */
  65818. gravity: Vector3;
  65819. /**
  65820. * Factory used to create the default physics plugin.
  65821. * @returns The default physics plugin
  65822. */
  65823. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  65824. /**
  65825. * Creates a new Physics Engine
  65826. * @param gravity defines the gravity vector used by the simulation
  65827. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  65828. */
  65829. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  65830. /**
  65831. * Sets the gravity vector used by the simulation
  65832. * @param gravity defines the gravity vector to use
  65833. */
  65834. setGravity(gravity: Vector3): void;
  65835. /**
  65836. * Set the time step of the physics engine.
  65837. * Default is 1/60.
  65838. * To slow it down, enter 1/600 for example.
  65839. * To speed it up, 1/30
  65840. * @param newTimeStep defines the new timestep to apply to this world.
  65841. */
  65842. setTimeStep(newTimeStep?: number): void;
  65843. /**
  65844. * Get the time step of the physics engine.
  65845. * @returns the current time step
  65846. */
  65847. getTimeStep(): number;
  65848. /**
  65849. * Set the sub time step of the physics engine.
  65850. * Default is 0 meaning there is no sub steps
  65851. * To increase physics resolution precision, set a small value (like 1 ms)
  65852. * @param subTimeStep defines the new sub timestep used for physics resolution.
  65853. */
  65854. setSubTimeStep(subTimeStep?: number): void;
  65855. /**
  65856. * Get the sub time step of the physics engine.
  65857. * @returns the current sub time step
  65858. */
  65859. getSubTimeStep(): number;
  65860. /**
  65861. * Release all resources
  65862. */
  65863. dispose(): void;
  65864. /**
  65865. * Gets the name of the current physics plugin
  65866. * @returns the name of the plugin
  65867. */
  65868. getPhysicsPluginName(): string;
  65869. /**
  65870. * Adding a new impostor for the impostor tracking.
  65871. * This will be done by the impostor itself.
  65872. * @param impostor the impostor to add
  65873. */
  65874. addImpostor(impostor: PhysicsImpostor): void;
  65875. /**
  65876. * Remove an impostor from the engine.
  65877. * This impostor and its mesh will not longer be updated by the physics engine.
  65878. * @param impostor the impostor to remove
  65879. */
  65880. removeImpostor(impostor: PhysicsImpostor): void;
  65881. /**
  65882. * Add a joint to the physics engine
  65883. * @param mainImpostor defines the main impostor to which the joint is added.
  65884. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  65885. * @param joint defines the joint that will connect both impostors.
  65886. */
  65887. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  65888. /**
  65889. * Removes a joint from the simulation
  65890. * @param mainImpostor defines the impostor used with the joint
  65891. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  65892. * @param joint defines the joint to remove
  65893. */
  65894. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  65895. /**
  65896. * Called by the scene. No need to call it.
  65897. * @param delta defines the timespan between frames
  65898. */
  65899. _step(delta: number): void;
  65900. /**
  65901. * Gets the current plugin used to run the simulation
  65902. * @returns current plugin
  65903. */
  65904. getPhysicsPlugin(): IPhysicsEnginePlugin;
  65905. /**
  65906. * Gets the list of physic impostors
  65907. * @returns an array of PhysicsImpostor
  65908. */
  65909. getImpostors(): Array<PhysicsImpostor>;
  65910. /**
  65911. * Gets the impostor for a physics enabled object
  65912. * @param object defines the object impersonated by the impostor
  65913. * @returns the PhysicsImpostor or null if not found
  65914. */
  65915. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  65916. /**
  65917. * Gets the impostor for a physics body object
  65918. * @param body defines physics body used by the impostor
  65919. * @returns the PhysicsImpostor or null if not found
  65920. */
  65921. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  65922. /**
  65923. * Does a raycast in the physics world
  65924. * @param from when should the ray start?
  65925. * @param to when should the ray end?
  65926. * @returns PhysicsRaycastResult
  65927. */
  65928. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  65929. }
  65930. }
  65931. declare module BABYLON {
  65932. /** @hidden */
  65933. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  65934. private _useDeltaForWorldStep;
  65935. world: any;
  65936. name: string;
  65937. private _physicsMaterials;
  65938. private _fixedTimeStep;
  65939. private _cannonRaycastResult;
  65940. private _raycastResult;
  65941. private _physicsBodysToRemoveAfterStep;
  65942. private _firstFrame;
  65943. BJSCANNON: any;
  65944. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  65945. setGravity(gravity: Vector3): void;
  65946. setTimeStep(timeStep: number): void;
  65947. getTimeStep(): number;
  65948. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  65949. private _removeMarkedPhysicsBodiesFromWorld;
  65950. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65951. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65952. generatePhysicsBody(impostor: PhysicsImpostor): void;
  65953. private _processChildMeshes;
  65954. removePhysicsBody(impostor: PhysicsImpostor): void;
  65955. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  65956. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  65957. private _addMaterial;
  65958. private _checkWithEpsilon;
  65959. private _createShape;
  65960. private _createHeightmap;
  65961. private _minus90X;
  65962. private _plus90X;
  65963. private _tmpPosition;
  65964. private _tmpDeltaPosition;
  65965. private _tmpUnityRotation;
  65966. private _updatePhysicsBodyTransformation;
  65967. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  65968. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  65969. isSupported(): boolean;
  65970. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65971. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65972. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65973. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65974. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  65975. getBodyMass(impostor: PhysicsImpostor): number;
  65976. getBodyFriction(impostor: PhysicsImpostor): number;
  65977. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  65978. getBodyRestitution(impostor: PhysicsImpostor): number;
  65979. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  65980. sleepBody(impostor: PhysicsImpostor): void;
  65981. wakeUpBody(impostor: PhysicsImpostor): void;
  65982. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  65983. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  65984. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  65985. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  65986. getRadius(impostor: PhysicsImpostor): number;
  65987. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  65988. dispose(): void;
  65989. private _extendNamespace;
  65990. /**
  65991. * Does a raycast in the physics world
  65992. * @param from when should the ray start?
  65993. * @param to when should the ray end?
  65994. * @returns PhysicsRaycastResult
  65995. */
  65996. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  65997. }
  65998. }
  65999. declare module BABYLON {
  66000. /** @hidden */
  66001. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  66002. private _useDeltaForWorldStep;
  66003. world: any;
  66004. name: string;
  66005. BJSOIMO: any;
  66006. private _raycastResult;
  66007. private _fixedTimeStep;
  66008. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  66009. setGravity(gravity: Vector3): void;
  66010. setTimeStep(timeStep: number): void;
  66011. getTimeStep(): number;
  66012. private _tmpImpostorsArray;
  66013. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  66014. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  66015. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  66016. generatePhysicsBody(impostor: PhysicsImpostor): void;
  66017. private _tmpPositionVector;
  66018. removePhysicsBody(impostor: PhysicsImpostor): void;
  66019. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  66020. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  66021. isSupported(): boolean;
  66022. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  66023. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  66024. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  66025. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  66026. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  66027. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  66028. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  66029. getBodyMass(impostor: PhysicsImpostor): number;
  66030. getBodyFriction(impostor: PhysicsImpostor): number;
  66031. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  66032. getBodyRestitution(impostor: PhysicsImpostor): number;
  66033. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  66034. sleepBody(impostor: PhysicsImpostor): void;
  66035. wakeUpBody(impostor: PhysicsImpostor): void;
  66036. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  66037. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  66038. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  66039. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  66040. getRadius(impostor: PhysicsImpostor): number;
  66041. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  66042. dispose(): void;
  66043. /**
  66044. * Does a raycast in the physics world
  66045. * @param from when should the ray start?
  66046. * @param to when should the ray end?
  66047. * @returns PhysicsRaycastResult
  66048. */
  66049. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  66050. }
  66051. }
  66052. declare module BABYLON {
  66053. /**
  66054. * AmmoJS Physics plugin
  66055. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  66056. * @see https://github.com/kripken/ammo.js/
  66057. */
  66058. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  66059. private _useDeltaForWorldStep;
  66060. /**
  66061. * Reference to the Ammo library
  66062. */
  66063. bjsAMMO: any;
  66064. /**
  66065. * Created ammoJS world which physics bodies are added to
  66066. */
  66067. world: any;
  66068. /**
  66069. * Name of the plugin
  66070. */
  66071. name: string;
  66072. private _timeStep;
  66073. private _fixedTimeStep;
  66074. private _maxSteps;
  66075. private _tmpQuaternion;
  66076. private _tmpAmmoTransform;
  66077. private _tmpAmmoQuaternion;
  66078. private _tmpAmmoConcreteContactResultCallback;
  66079. private _collisionConfiguration;
  66080. private _dispatcher;
  66081. private _overlappingPairCache;
  66082. private _solver;
  66083. private _softBodySolver;
  66084. private _tmpAmmoVectorA;
  66085. private _tmpAmmoVectorB;
  66086. private _tmpAmmoVectorC;
  66087. private _tmpAmmoVectorD;
  66088. private _tmpContactCallbackResult;
  66089. private _tmpAmmoVectorRCA;
  66090. private _tmpAmmoVectorRCB;
  66091. private _raycastResult;
  66092. private _tmpContactPoint;
  66093. private static readonly DISABLE_COLLISION_FLAG;
  66094. private static readonly KINEMATIC_FLAG;
  66095. private static readonly DISABLE_DEACTIVATION_FLAG;
  66096. /**
  66097. * Initializes the ammoJS plugin
  66098. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  66099. * @param ammoInjection can be used to inject your own ammo reference
  66100. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  66101. */
  66102. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  66103. /**
  66104. * Sets the gravity of the physics world (m/(s^2))
  66105. * @param gravity Gravity to set
  66106. */
  66107. setGravity(gravity: Vector3): void;
  66108. /**
  66109. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  66110. * @param timeStep timestep to use in seconds
  66111. */
  66112. setTimeStep(timeStep: number): void;
  66113. /**
  66114. * 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)
  66115. * @param fixedTimeStep fixedTimeStep to use in seconds
  66116. */
  66117. setFixedTimeStep(fixedTimeStep: number): void;
  66118. /**
  66119. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  66120. * @param maxSteps the maximum number of steps by the physics engine per frame
  66121. */
  66122. setMaxSteps(maxSteps: number): void;
  66123. /**
  66124. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  66125. * @returns the current timestep in seconds
  66126. */
  66127. getTimeStep(): number;
  66128. /**
  66129. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  66130. */
  66131. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  66132. private _isImpostorInContact;
  66133. private _isImpostorPairInContact;
  66134. private _stepSimulation;
  66135. /**
  66136. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  66137. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  66138. * After the step the babylon meshes are set to the position of the physics imposters
  66139. * @param delta amount of time to step forward
  66140. * @param impostors array of imposters to update before/after the step
  66141. */
  66142. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  66143. /**
  66144. * Update babylon mesh to match physics world object
  66145. * @param impostor imposter to match
  66146. */
  66147. private _afterSoftStep;
  66148. /**
  66149. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  66150. * @param impostor imposter to match
  66151. */
  66152. private _ropeStep;
  66153. /**
  66154. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  66155. * @param impostor imposter to match
  66156. */
  66157. private _softbodyOrClothStep;
  66158. private _tmpMatrix;
  66159. /**
  66160. * Applies an impulse on the imposter
  66161. * @param impostor imposter to apply impulse to
  66162. * @param force amount of force to be applied to the imposter
  66163. * @param contactPoint the location to apply the impulse on the imposter
  66164. */
  66165. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  66166. /**
  66167. * Applies a force on the imposter
  66168. * @param impostor imposter to apply force
  66169. * @param force amount of force to be applied to the imposter
  66170. * @param contactPoint the location to apply the force on the imposter
  66171. */
  66172. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  66173. /**
  66174. * Creates a physics body using the plugin
  66175. * @param impostor the imposter to create the physics body on
  66176. */
  66177. generatePhysicsBody(impostor: PhysicsImpostor): void;
  66178. /**
  66179. * Removes the physics body from the imposter and disposes of the body's memory
  66180. * @param impostor imposter to remove the physics body from
  66181. */
  66182. removePhysicsBody(impostor: PhysicsImpostor): void;
  66183. /**
  66184. * Generates a joint
  66185. * @param impostorJoint the imposter joint to create the joint with
  66186. */
  66187. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  66188. /**
  66189. * Removes a joint
  66190. * @param impostorJoint the imposter joint to remove the joint from
  66191. */
  66192. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  66193. private _addMeshVerts;
  66194. /**
  66195. * Initialise the soft body vertices to match its object's (mesh) vertices
  66196. * Softbody vertices (nodes) are in world space and to match this
  66197. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  66198. * @param impostor to create the softbody for
  66199. */
  66200. private _softVertexData;
  66201. /**
  66202. * Create an impostor's soft body
  66203. * @param impostor to create the softbody for
  66204. */
  66205. private _createSoftbody;
  66206. /**
  66207. * Create cloth for an impostor
  66208. * @param impostor to create the softbody for
  66209. */
  66210. private _createCloth;
  66211. /**
  66212. * Create rope for an impostor
  66213. * @param impostor to create the softbody for
  66214. */
  66215. private _createRope;
  66216. /**
  66217. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  66218. * @param impostor to create the custom physics shape for
  66219. */
  66220. private _createCustom;
  66221. private _addHullVerts;
  66222. private _createShape;
  66223. /**
  66224. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  66225. * @param impostor imposter containing the physics body and babylon object
  66226. */
  66227. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  66228. /**
  66229. * Sets the babylon object's position/rotation from the physics body's position/rotation
  66230. * @param impostor imposter containing the physics body and babylon object
  66231. * @param newPosition new position
  66232. * @param newRotation new rotation
  66233. */
  66234. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  66235. /**
  66236. * If this plugin is supported
  66237. * @returns true if its supported
  66238. */
  66239. isSupported(): boolean;
  66240. /**
  66241. * Sets the linear velocity of the physics body
  66242. * @param impostor imposter to set the velocity on
  66243. * @param velocity velocity to set
  66244. */
  66245. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  66246. /**
  66247. * Sets the angular velocity of the physics body
  66248. * @param impostor imposter to set the velocity on
  66249. * @param velocity velocity to set
  66250. */
  66251. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  66252. /**
  66253. * gets the linear velocity
  66254. * @param impostor imposter to get linear velocity from
  66255. * @returns linear velocity
  66256. */
  66257. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  66258. /**
  66259. * gets the angular velocity
  66260. * @param impostor imposter to get angular velocity from
  66261. * @returns angular velocity
  66262. */
  66263. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  66264. /**
  66265. * Sets the mass of physics body
  66266. * @param impostor imposter to set the mass on
  66267. * @param mass mass to set
  66268. */
  66269. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  66270. /**
  66271. * Gets the mass of the physics body
  66272. * @param impostor imposter to get the mass from
  66273. * @returns mass
  66274. */
  66275. getBodyMass(impostor: PhysicsImpostor): number;
  66276. /**
  66277. * Gets friction of the impostor
  66278. * @param impostor impostor to get friction from
  66279. * @returns friction value
  66280. */
  66281. getBodyFriction(impostor: PhysicsImpostor): number;
  66282. /**
  66283. * Sets friction of the impostor
  66284. * @param impostor impostor to set friction on
  66285. * @param friction friction value
  66286. */
  66287. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  66288. /**
  66289. * Gets restitution of the impostor
  66290. * @param impostor impostor to get restitution from
  66291. * @returns restitution value
  66292. */
  66293. getBodyRestitution(impostor: PhysicsImpostor): number;
  66294. /**
  66295. * Sets restitution of the impostor
  66296. * @param impostor impostor to set resitution on
  66297. * @param restitution resitution value
  66298. */
  66299. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  66300. /**
  66301. * Gets pressure inside the impostor
  66302. * @param impostor impostor to get pressure from
  66303. * @returns pressure value
  66304. */
  66305. getBodyPressure(impostor: PhysicsImpostor): number;
  66306. /**
  66307. * Sets pressure inside a soft body impostor
  66308. * Cloth and rope must remain 0 pressure
  66309. * @param impostor impostor to set pressure on
  66310. * @param pressure pressure value
  66311. */
  66312. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  66313. /**
  66314. * Gets stiffness of the impostor
  66315. * @param impostor impostor to get stiffness from
  66316. * @returns pressure value
  66317. */
  66318. getBodyStiffness(impostor: PhysicsImpostor): number;
  66319. /**
  66320. * Sets stiffness of the impostor
  66321. * @param impostor impostor to set stiffness on
  66322. * @param stiffness stiffness value from 0 to 1
  66323. */
  66324. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  66325. /**
  66326. * Gets velocityIterations of the impostor
  66327. * @param impostor impostor to get velocity iterations from
  66328. * @returns velocityIterations value
  66329. */
  66330. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  66331. /**
  66332. * Sets velocityIterations of the impostor
  66333. * @param impostor impostor to set velocity iterations on
  66334. * @param velocityIterations velocityIterations value
  66335. */
  66336. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  66337. /**
  66338. * Gets positionIterations of the impostor
  66339. * @param impostor impostor to get position iterations from
  66340. * @returns positionIterations value
  66341. */
  66342. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  66343. /**
  66344. * Sets positionIterations of the impostor
  66345. * @param impostor impostor to set position on
  66346. * @param positionIterations positionIterations value
  66347. */
  66348. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  66349. /**
  66350. * Append an anchor to a cloth object
  66351. * @param impostor is the cloth impostor to add anchor to
  66352. * @param otherImpostor is the rigid impostor to anchor to
  66353. * @param width ratio across width from 0 to 1
  66354. * @param height ratio up height from 0 to 1
  66355. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little stretch
  66356. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  66357. */
  66358. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  66359. /**
  66360. * Append an hook to a rope object
  66361. * @param impostor is the rope impostor to add hook to
  66362. * @param otherImpostor is the rigid impostor to hook to
  66363. * @param length ratio along the rope from 0 to 1
  66364. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little stretch
  66365. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  66366. */
  66367. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  66368. /**
  66369. * Sleeps the physics body and stops it from being active
  66370. * @param impostor impostor to sleep
  66371. */
  66372. sleepBody(impostor: PhysicsImpostor): void;
  66373. /**
  66374. * Activates the physics body
  66375. * @param impostor impostor to activate
  66376. */
  66377. wakeUpBody(impostor: PhysicsImpostor): void;
  66378. /**
  66379. * Updates the distance parameters of the joint
  66380. * @param joint joint to update
  66381. * @param maxDistance maximum distance of the joint
  66382. * @param minDistance minimum distance of the joint
  66383. */
  66384. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  66385. /**
  66386. * Sets a motor on the joint
  66387. * @param joint joint to set motor on
  66388. * @param speed speed of the motor
  66389. * @param maxForce maximum force of the motor
  66390. * @param motorIndex index of the motor
  66391. */
  66392. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  66393. /**
  66394. * Sets the motors limit
  66395. * @param joint joint to set limit on
  66396. * @param upperLimit upper limit
  66397. * @param lowerLimit lower limit
  66398. */
  66399. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  66400. /**
  66401. * Syncs the position and rotation of a mesh with the impostor
  66402. * @param mesh mesh to sync
  66403. * @param impostor impostor to update the mesh with
  66404. */
  66405. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  66406. /**
  66407. * Gets the radius of the impostor
  66408. * @param impostor impostor to get radius from
  66409. * @returns the radius
  66410. */
  66411. getRadius(impostor: PhysicsImpostor): number;
  66412. /**
  66413. * Gets the box size of the impostor
  66414. * @param impostor impostor to get box size from
  66415. * @param result the resulting box size
  66416. */
  66417. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  66418. /**
  66419. * Disposes of the impostor
  66420. */
  66421. dispose(): void;
  66422. /**
  66423. * Does a raycast in the physics world
  66424. * @param from when should the ray start?
  66425. * @param to when should the ray end?
  66426. * @returns PhysicsRaycastResult
  66427. */
  66428. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  66429. }
  66430. }
  66431. declare module BABYLON {
  66432. interface AbstractScene {
  66433. /**
  66434. * The list of reflection probes added to the scene
  66435. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  66436. */
  66437. reflectionProbes: Array<ReflectionProbe>;
  66438. /**
  66439. * Removes the given reflection probe from this scene.
  66440. * @param toRemove The reflection probe to remove
  66441. * @returns The index of the removed reflection probe
  66442. */
  66443. removeReflectionProbe(toRemove: ReflectionProbe): number;
  66444. /**
  66445. * Adds the given reflection probe to this scene.
  66446. * @param newReflectionProbe The reflection probe to add
  66447. */
  66448. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  66449. }
  66450. /**
  66451. * Class used to generate realtime reflection / refraction cube textures
  66452. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  66453. */
  66454. export class ReflectionProbe {
  66455. /** defines the name of the probe */
  66456. name: string;
  66457. private _scene;
  66458. private _renderTargetTexture;
  66459. private _projectionMatrix;
  66460. private _viewMatrix;
  66461. private _target;
  66462. private _add;
  66463. private _attachedMesh;
  66464. private _invertYAxis;
  66465. /** Gets or sets probe position (center of the cube map) */
  66466. position: Vector3;
  66467. /**
  66468. * Creates a new reflection probe
  66469. * @param name defines the name of the probe
  66470. * @param size defines the texture resolution (for each face)
  66471. * @param scene defines the hosting scene
  66472. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  66473. * @param useFloat defines if HDR data (float data) should be used to store colors (false by default)
  66474. * @param linearSpace defines if the probe should be generated in linear space or not (false by default)
  66475. */
  66476. constructor(
  66477. /** defines the name of the probe */
  66478. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean, linearSpace?: boolean);
  66479. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  66480. get samples(): number;
  66481. set samples(value: number);
  66482. /** Gets or sets the refresh rate to use (on every frame by default) */
  66483. get refreshRate(): number;
  66484. set refreshRate(value: number);
  66485. /**
  66486. * Gets the hosting scene
  66487. * @returns a Scene
  66488. */
  66489. getScene(): Scene;
  66490. /** Gets the internal CubeTexture used to render to */
  66491. get cubeTexture(): RenderTargetTexture;
  66492. /** Gets the list of meshes to render */
  66493. get renderList(): Nullable<AbstractMesh[]>;
  66494. /**
  66495. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  66496. * @param mesh defines the mesh to attach to
  66497. */
  66498. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  66499. /**
  66500. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  66501. * @param renderingGroupId The rendering group id corresponding to its index
  66502. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  66503. */
  66504. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  66505. /**
  66506. * Clean all associated resources
  66507. */
  66508. dispose(): void;
  66509. /**
  66510. * Converts the reflection probe information to a readable string for debug purpose.
  66511. * @param fullDetails Supports for multiple levels of logging within scene loading
  66512. * @returns the human readable reflection probe info
  66513. */
  66514. toString(fullDetails?: boolean): string;
  66515. /**
  66516. * Get the class name of the refection probe.
  66517. * @returns "ReflectionProbe"
  66518. */
  66519. getClassName(): string;
  66520. /**
  66521. * Serialize the reflection probe to a JSON representation we can easily use in the respective Parse function.
  66522. * @returns The JSON representation of the texture
  66523. */
  66524. serialize(): any;
  66525. /**
  66526. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  66527. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  66528. * @param scene Define the scene the parsed reflection probe should be instantiated in
  66529. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  66530. * @returns The parsed reflection probe if successful
  66531. */
  66532. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  66533. }
  66534. }
  66535. declare module BABYLON {
  66536. /** @hidden */
  66537. export var _BabylonLoaderRegistered: boolean;
  66538. /**
  66539. * Helps setting up some configuration for the babylon file loader.
  66540. */
  66541. export class BabylonFileLoaderConfiguration {
  66542. /**
  66543. * The loader does not allow injecting custom physics engine into the plugins.
  66544. * Unfortunately in ES6, we need to manually inject them into the plugin.
  66545. * So you could set this variable to your engine import to make it work.
  66546. */
  66547. static LoaderInjectedPhysicsEngine: any;
  66548. }
  66549. }
  66550. declare module BABYLON {
  66551. /**
  66552. * A material to use for fast depth-only rendering.
  66553. */
  66554. export class OcclusionMaterial extends ShaderMaterial {
  66555. constructor(name: string, scene: Scene);
  66556. }
  66557. }
  66558. declare module BABYLON {
  66559. /**
  66560. * The Physically based simple base material of BJS.
  66561. *
  66562. * This enables better naming and convention enforcements on top of the pbrMaterial.
  66563. * It is used as the base class for both the specGloss and metalRough conventions.
  66564. */
  66565. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  66566. /**
  66567. * Number of Simultaneous lights allowed on the material.
  66568. */
  66569. maxSimultaneousLights: number;
  66570. /**
  66571. * If sets to true, disables all the lights affecting the material.
  66572. */
  66573. disableLighting: boolean;
  66574. /**
  66575. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  66576. */
  66577. environmentTexture: BaseTexture;
  66578. /**
  66579. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  66580. */
  66581. invertNormalMapX: boolean;
  66582. /**
  66583. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  66584. */
  66585. invertNormalMapY: boolean;
  66586. /**
  66587. * Normal map used in the model.
  66588. */
  66589. normalTexture: BaseTexture;
  66590. /**
  66591. * Emissivie color used to self-illuminate the model.
  66592. */
  66593. emissiveColor: Color3;
  66594. /**
  66595. * Emissivie texture used to self-illuminate the model.
  66596. */
  66597. emissiveTexture: BaseTexture;
  66598. /**
  66599. * Occlusion Channel Strength.
  66600. */
  66601. occlusionStrength: number;
  66602. /**
  66603. * Occlusion Texture of the material (adding extra occlusion effects).
  66604. */
  66605. occlusionTexture: BaseTexture;
  66606. /**
  66607. * Defines the alpha limits in alpha test mode.
  66608. */
  66609. alphaCutOff: number;
  66610. /**
  66611. * Gets the current double sided mode.
  66612. */
  66613. get doubleSided(): boolean;
  66614. /**
  66615. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  66616. */
  66617. set doubleSided(value: boolean);
  66618. /**
  66619. * Stores the pre-calculated light information of a mesh in a texture.
  66620. */
  66621. lightmapTexture: BaseTexture;
  66622. /**
  66623. * If true, the light map contains occlusion information instead of lighting info.
  66624. */
  66625. useLightmapAsShadowmap: boolean;
  66626. /**
  66627. * Instantiates a new PBRMaterial instance.
  66628. *
  66629. * @param name The material name
  66630. * @param scene The scene the material will be use in.
  66631. */
  66632. constructor(name: string, scene: Scene);
  66633. getClassName(): string;
  66634. }
  66635. }
  66636. declare module BABYLON {
  66637. /**
  66638. * The PBR material of BJS following the metal roughness convention.
  66639. *
  66640. * This fits to the PBR convention in the GLTF definition:
  66641. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  66642. */
  66643. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  66644. /**
  66645. * The base color has two different interpretations depending on the value of metalness.
  66646. * When the material is a metal, the base color is the specific measured reflectance value
  66647. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  66648. * of the material.
  66649. */
  66650. baseColor: Color3;
  66651. /**
  66652. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  66653. * well as opacity information in the alpha channel.
  66654. */
  66655. baseTexture: BaseTexture;
  66656. /**
  66657. * Specifies the metallic scalar value of the material.
  66658. * Can also be used to scale the metalness values of the metallic texture.
  66659. */
  66660. metallic: number;
  66661. /**
  66662. * Specifies the roughness scalar value of the material.
  66663. * Can also be used to scale the roughness values of the metallic texture.
  66664. */
  66665. roughness: number;
  66666. /**
  66667. * Texture containing both the metallic value in the B channel and the
  66668. * roughness value in the G channel to keep better precision.
  66669. */
  66670. metallicRoughnessTexture: BaseTexture;
  66671. /**
  66672. * Instantiates a new PBRMetalRoughnessMaterial instance.
  66673. *
  66674. * @param name The material name
  66675. * @param scene The scene the material will be use in.
  66676. */
  66677. constructor(name: string, scene: Scene);
  66678. /**
  66679. * Return the current class name of the material.
  66680. */
  66681. getClassName(): string;
  66682. /**
  66683. * Makes a duplicate of the current material.
  66684. * @param name - name to use for the new material.
  66685. */
  66686. clone(name: string): PBRMetallicRoughnessMaterial;
  66687. /**
  66688. * Serialize the material to a parsable JSON object.
  66689. */
  66690. serialize(): any;
  66691. /**
  66692. * Parses a JSON object corresponding to the serialize function.
  66693. */
  66694. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  66695. }
  66696. }
  66697. declare module BABYLON {
  66698. /**
  66699. * The PBR material of BJS following the specular glossiness convention.
  66700. *
  66701. * This fits to the PBR convention in the GLTF definition:
  66702. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  66703. */
  66704. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  66705. /**
  66706. * Specifies the diffuse color of the material.
  66707. */
  66708. diffuseColor: Color3;
  66709. /**
  66710. * Specifies the diffuse texture of the material. This can also contains the opacity value in its alpha
  66711. * channel.
  66712. */
  66713. diffuseTexture: BaseTexture;
  66714. /**
  66715. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  66716. */
  66717. specularColor: Color3;
  66718. /**
  66719. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  66720. */
  66721. glossiness: number;
  66722. /**
  66723. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  66724. */
  66725. specularGlossinessTexture: BaseTexture;
  66726. /**
  66727. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  66728. */
  66729. get useMicroSurfaceFromReflectivityMapAlpha(): boolean;
  66730. /**
  66731. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  66732. *
  66733. * @param name The material name
  66734. * @param scene The scene the material will be use in.
  66735. */
  66736. constructor(name: string, scene: Scene);
  66737. /**
  66738. * Return the current class name of the material.
  66739. */
  66740. getClassName(): string;
  66741. /**
  66742. * Makes a duplicate of the current material.
  66743. * @param name - name to use for the new material.
  66744. */
  66745. clone(name: string): PBRSpecularGlossinessMaterial;
  66746. /**
  66747. * Serialize the material to a parsable JSON object.
  66748. */
  66749. serialize(): any;
  66750. /**
  66751. * Parses a JSON object corresponding to the serialize function.
  66752. */
  66753. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  66754. }
  66755. }
  66756. declare module BABYLON {
  66757. /**
  66758. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  66759. * It can help converting any input color in a desired output one. This can then be used to create effects
  66760. * from sepia, black and white to sixties or futuristic rendering...
  66761. *
  66762. * The only supported format is currently 3dl.
  66763. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  66764. */
  66765. export class ColorGradingTexture extends BaseTexture {
  66766. /**
  66767. * The texture URL.
  66768. */
  66769. url: string;
  66770. /**
  66771. * Empty line regex stored for GC.
  66772. */
  66773. private static _noneEmptyLineRegex;
  66774. private _textureMatrix;
  66775. private _onLoad;
  66776. /**
  66777. * Instantiates a ColorGradingTexture from the following parameters.
  66778. *
  66779. * @param url The location of the color grading data (currently only supporting 3dl)
  66780. * @param sceneOrEngine The scene or engine the texture will be used in
  66781. * @param onLoad defines a callback triggered when the texture has been loaded
  66782. */
  66783. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  66784. /**
  66785. * Fires the onload event from the constructor if requested.
  66786. */
  66787. private _triggerOnLoad;
  66788. /**
  66789. * Returns the texture matrix used in most of the material.
  66790. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  66791. */
  66792. getTextureMatrix(): Matrix;
  66793. /**
  66794. * Occurs when the file being loaded is a .3dl LUT file.
  66795. */
  66796. private load3dlTexture;
  66797. /**
  66798. * Starts the loading process of the texture.
  66799. */
  66800. private loadTexture;
  66801. /**
  66802. * Clones the color grading texture.
  66803. */
  66804. clone(): ColorGradingTexture;
  66805. /**
  66806. * Called during delayed load for textures.
  66807. */
  66808. delayLoad(): void;
  66809. /**
  66810. * Parses a color grading texture serialized by Babylon.
  66811. * @param parsedTexture The texture information being parsedTexture
  66812. * @param scene The scene to load the texture in
  66813. * @param rootUrl The root url of the data assets to load
  66814. * @return A color grading texture
  66815. */
  66816. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  66817. /**
  66818. * Serializes the LUT texture to json format.
  66819. */
  66820. serialize(): any;
  66821. }
  66822. }
  66823. declare module BABYLON {
  66824. /**
  66825. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  66826. */
  66827. export class EquiRectangularCubeTexture extends BaseTexture {
  66828. /** The six faces of the cube. */
  66829. private static _FacesMapping;
  66830. private _noMipmap;
  66831. private _onLoad;
  66832. private _onError;
  66833. /** The size of the cubemap. */
  66834. private _size;
  66835. /** The buffer of the image. */
  66836. private _buffer;
  66837. /** The width of the input image. */
  66838. private _width;
  66839. /** The height of the input image. */
  66840. private _height;
  66841. /** The URL to the image. */
  66842. url: string;
  66843. /**
  66844. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  66845. * @param url The location of the image
  66846. * @param scene The scene the texture will be used in
  66847. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  66848. * @param noMipmap Forces to not generate the mipmap if true
  66849. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  66850. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  66851. * @param onLoad — defines a callback called when texture is loaded
  66852. * @param onError — defines a callback called if there is an error
  66853. */
  66854. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  66855. /**
  66856. * Load the image data, by putting the image on a canvas and extracting its buffer.
  66857. */
  66858. private loadImage;
  66859. /**
  66860. * Convert the image buffer into a cubemap and create a CubeTexture.
  66861. */
  66862. private loadTexture;
  66863. /**
  66864. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  66865. * @param buffer The ArrayBuffer that should be converted.
  66866. * @returns The buffer as Float32Array.
  66867. */
  66868. private getFloat32ArrayFromArrayBuffer;
  66869. /**
  66870. * Get the current class name of the texture useful for serialization or dynamic coding.
  66871. * @returns "EquiRectangularCubeTexture"
  66872. */
  66873. getClassName(): string;
  66874. /**
  66875. * Create a clone of the current EquiRectangularCubeTexture and return it.
  66876. * @returns A clone of the current EquiRectangularCubeTexture.
  66877. */
  66878. clone(): EquiRectangularCubeTexture;
  66879. }
  66880. }
  66881. declare module BABYLON {
  66882. /**
  66883. * Defines the options related to the creation of an HtmlElementTexture
  66884. */
  66885. export interface IHtmlElementTextureOptions {
  66886. /**
  66887. * Defines whether mip maps should be created or not.
  66888. */
  66889. generateMipMaps?: boolean;
  66890. /**
  66891. * Defines the sampling mode of the texture.
  66892. */
  66893. samplingMode?: number;
  66894. /**
  66895. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  66896. */
  66897. engine: Nullable<ThinEngine>;
  66898. /**
  66899. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  66900. */
  66901. scene: Nullable<Scene>;
  66902. }
  66903. /**
  66904. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  66905. * To be as efficient as possible depending on your constraints nothing aside the first upload
  66906. * is automatically managed.
  66907. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  66908. * in your application.
  66909. *
  66910. * As the update is not automatic, you need to call them manually.
  66911. */
  66912. export class HtmlElementTexture extends BaseTexture {
  66913. /**
  66914. * The texture URL.
  66915. */
  66916. element: HTMLVideoElement | HTMLCanvasElement;
  66917. private static readonly DefaultOptions;
  66918. private _textureMatrix;
  66919. private _isVideo;
  66920. private _generateMipMaps;
  66921. private _samplingMode;
  66922. /**
  66923. * Instantiates a HtmlElementTexture from the following parameters.
  66924. *
  66925. * @param name Defines the name of the texture
  66926. * @param element Defines the video or canvas the texture is filled with
  66927. * @param options Defines the other none mandatory texture creation options
  66928. */
  66929. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  66930. private _createInternalTexture;
  66931. /**
  66932. * Returns the texture matrix used in most of the material.
  66933. */
  66934. getTextureMatrix(): Matrix;
  66935. /**
  66936. * Updates the content of the texture.
  66937. * @param invertY Defines whether the texture should be inverted on Y (false by default on video and true on canvas)
  66938. */
  66939. update(invertY?: Nullable<boolean>): void;
  66940. }
  66941. }
  66942. declare module BABYLON {
  66943. /**
  66944. * Based on jsTGALoader - Javascript loader for TGA file
  66945. * By Vincent Thibault
  66946. * @see http://blog.robrowser.com/javascript-tga-loader.html
  66947. */
  66948. export class TGATools {
  66949. private static _TYPE_INDEXED;
  66950. private static _TYPE_RGB;
  66951. private static _TYPE_GREY;
  66952. private static _TYPE_RLE_INDEXED;
  66953. private static _TYPE_RLE_RGB;
  66954. private static _TYPE_RLE_GREY;
  66955. private static _ORIGIN_MASK;
  66956. private static _ORIGIN_SHIFT;
  66957. private static _ORIGIN_BL;
  66958. private static _ORIGIN_BR;
  66959. private static _ORIGIN_UL;
  66960. private static _ORIGIN_UR;
  66961. /**
  66962. * Gets the header of a TGA file
  66963. * @param data defines the TGA data
  66964. * @returns the header
  66965. */
  66966. static GetTGAHeader(data: Uint8Array): any;
  66967. /**
  66968. * Uploads TGA content to a Babylon Texture
  66969. * @hidden
  66970. */
  66971. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  66972. /** @hidden */
  66973. 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;
  66974. /** @hidden */
  66975. 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;
  66976. /** @hidden */
  66977. 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;
  66978. /** @hidden */
  66979. 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;
  66980. /** @hidden */
  66981. 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;
  66982. /** @hidden */
  66983. 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;
  66984. }
  66985. }
  66986. declare module BABYLON {
  66987. /**
  66988. * Implementation of the TGA Texture Loader.
  66989. * @hidden
  66990. */
  66991. export class _TGATextureLoader implements IInternalTextureLoader {
  66992. /**
  66993. * Defines whether the loader supports cascade loading the different faces.
  66994. */
  66995. readonly supportCascades: boolean;
  66996. /**
  66997. * This returns if the loader support the current file information.
  66998. * @param extension defines the file extension of the file being loaded
  66999. * @returns true if the loader can load the specified file
  67000. */
  67001. canLoad(extension: string): boolean;
  67002. /**
  67003. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  67004. * @param data contains the texture data
  67005. * @param texture defines the BabylonJS internal texture
  67006. * @param createPolynomials will be true if polynomials have been requested
  67007. * @param onLoad defines the callback to trigger once the texture is ready
  67008. * @param onError defines the callback to trigger in case of error
  67009. */
  67010. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  67011. /**
  67012. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  67013. * @param data contains the texture data
  67014. * @param texture defines the BabylonJS internal texture
  67015. * @param callback defines the method to call once ready to upload
  67016. */
  67017. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  67018. }
  67019. }
  67020. declare module BABYLON {
  67021. /**
  67022. * Implementation of the HDR Texture Loader.
  67023. * @hidden
  67024. */
  67025. export class _HDRTextureLoader implements IInternalTextureLoader {
  67026. /**
  67027. * Defines whether the loader supports cascade loading the different faces.
  67028. */
  67029. readonly supportCascades: boolean;
  67030. /**
  67031. * This returns if the loader support the current file information.
  67032. * @param extension defines the file extension of the file being loaded
  67033. * @returns true if the loader can load the specified file
  67034. */
  67035. canLoad(extension: string): boolean;
  67036. /**
  67037. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  67038. * @param data contains the texture data
  67039. * @param texture defines the BabylonJS internal texture
  67040. * @param createPolynomials will be true if polynomials have been requested
  67041. * @param onLoad defines the callback to trigger once the texture is ready
  67042. * @param onError defines the callback to trigger in case of error
  67043. */
  67044. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  67045. /**
  67046. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  67047. * @param data contains the texture data
  67048. * @param texture defines the BabylonJS internal texture
  67049. * @param callback defines the method to call once ready to upload
  67050. */
  67051. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  67052. }
  67053. }
  67054. declare module BABYLON {
  67055. /**
  67056. * Info about the .basis files
  67057. */
  67058. class BasisFileInfo {
  67059. /**
  67060. * If the file has alpha
  67061. */
  67062. hasAlpha: boolean;
  67063. /**
  67064. * Info about each image of the basis file
  67065. */
  67066. images: Array<{
  67067. levels: Array<{
  67068. width: number;
  67069. height: number;
  67070. transcodedPixels: ArrayBufferView;
  67071. }>;
  67072. }>;
  67073. }
  67074. /**
  67075. * Result of transcoding a basis file
  67076. */
  67077. class TranscodeResult {
  67078. /**
  67079. * Info about the .basis file
  67080. */
  67081. fileInfo: BasisFileInfo;
  67082. /**
  67083. * Format to use when loading the file
  67084. */
  67085. format: number;
  67086. }
  67087. /**
  67088. * Configuration options for the Basis transcoder
  67089. */
  67090. export class BasisTranscodeConfiguration {
  67091. /**
  67092. * Supported compression formats used to determine the supported output format of the transcoder
  67093. */
  67094. supportedCompressionFormats?: {
  67095. /**
  67096. * etc1 compression format
  67097. */
  67098. etc1?: boolean;
  67099. /**
  67100. * s3tc compression format
  67101. */
  67102. s3tc?: boolean;
  67103. /**
  67104. * pvrtc compression format
  67105. */
  67106. pvrtc?: boolean;
  67107. /**
  67108. * etc2 compression format
  67109. */
  67110. etc2?: boolean;
  67111. };
  67112. /**
  67113. * If mipmap levels should be loaded for transcoded images (Default: true)
  67114. */
  67115. loadMipmapLevels?: boolean;
  67116. /**
  67117. * Index of a single image to load (Default: all images)
  67118. */
  67119. loadSingleImage?: number;
  67120. }
  67121. /**
  67122. * Used to load .Basis files
  67123. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  67124. */
  67125. export class BasisTools {
  67126. private static _IgnoreSupportedFormats;
  67127. /**
  67128. * URL to use when loading the basis transcoder
  67129. */
  67130. static JSModuleURL: string;
  67131. /**
  67132. * URL to use when loading the wasm module for the transcoder
  67133. */
  67134. static WasmModuleURL: string;
  67135. /**
  67136. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  67137. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  67138. * @returns internal format corresponding to the Basis format
  67139. */
  67140. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  67141. private static _WorkerPromise;
  67142. private static _Worker;
  67143. private static _actionId;
  67144. private static _CreateWorkerAsync;
  67145. /**
  67146. * Transcodes a loaded image file to compressed pixel data
  67147. * @param data image data to transcode
  67148. * @param config configuration options for the transcoding
  67149. * @returns a promise resulting in the transcoded image
  67150. */
  67151. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  67152. /**
  67153. * Loads a texture from the transcode result
  67154. * @param texture texture load to
  67155. * @param transcodeResult the result of transcoding the basis file to load from
  67156. */
  67157. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  67158. }
  67159. }
  67160. declare module BABYLON {
  67161. /**
  67162. * Loader for .basis file format
  67163. */
  67164. export class _BasisTextureLoader implements IInternalTextureLoader {
  67165. /**
  67166. * Defines whether the loader supports cascade loading the different faces.
  67167. */
  67168. readonly supportCascades: boolean;
  67169. /**
  67170. * This returns if the loader support the current file information.
  67171. * @param extension defines the file extension of the file being loaded
  67172. * @returns true if the loader can load the specified file
  67173. */
  67174. canLoad(extension: string): boolean;
  67175. /**
  67176. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  67177. * @param data contains the texture data
  67178. * @param texture defines the BabylonJS internal texture
  67179. * @param createPolynomials will be true if polynomials have been requested
  67180. * @param onLoad defines the callback to trigger once the texture is ready
  67181. * @param onError defines the callback to trigger in case of error
  67182. */
  67183. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  67184. /**
  67185. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  67186. * @param data contains the texture data
  67187. * @param texture defines the BabylonJS internal texture
  67188. * @param callback defines the method to call once ready to upload
  67189. */
  67190. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  67191. }
  67192. }
  67193. declare module BABYLON {
  67194. /**
  67195. * Defines the basic options interface of a TexturePacker Frame
  67196. */
  67197. export interface ITexturePackerFrame {
  67198. /**
  67199. * The frame ID
  67200. */
  67201. id: number;
  67202. /**
  67203. * The frames Scale
  67204. */
  67205. scale: Vector2;
  67206. /**
  67207. * The Frames offset
  67208. */
  67209. offset: Vector2;
  67210. }
  67211. /**
  67212. * This is a support class for frame Data on texture packer sets.
  67213. */
  67214. export class TexturePackerFrame implements ITexturePackerFrame {
  67215. /**
  67216. * The frame ID
  67217. */
  67218. id: number;
  67219. /**
  67220. * The frames Scale
  67221. */
  67222. scale: Vector2;
  67223. /**
  67224. * The Frames offset
  67225. */
  67226. offset: Vector2;
  67227. /**
  67228. * Initializes a texture package frame.
  67229. * @param id The numerical frame identifier
  67230. * @param scale Scalar Vector2 for UV frame
  67231. * @param offset Vector2 for the frame position in UV units.
  67232. * @returns TexturePackerFrame
  67233. */
  67234. constructor(id: number, scale: Vector2, offset: Vector2);
  67235. }
  67236. }
  67237. declare module BABYLON {
  67238. /**
  67239. * Defines the basic options interface of a TexturePacker
  67240. */
  67241. export interface ITexturePackerOptions {
  67242. /**
  67243. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  67244. */
  67245. map?: string[];
  67246. /**
  67247. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  67248. */
  67249. uvsIn?: string;
  67250. /**
  67251. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  67252. */
  67253. uvsOut?: string;
  67254. /**
  67255. * number representing the layout style. Defaults to LAYOUT_STRIP
  67256. */
  67257. layout?: number;
  67258. /**
  67259. * number of columns if using custom column count layout(2). This defaults to 4.
  67260. */
  67261. colnum?: number;
  67262. /**
  67263. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  67264. */
  67265. updateInputMeshes?: boolean;
  67266. /**
  67267. * boolean flag to dispose all the source textures. Defaults to true.
  67268. */
  67269. disposeSources?: boolean;
  67270. /**
  67271. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  67272. */
  67273. fillBlanks?: boolean;
  67274. /**
  67275. * string value representing the context fill style color. Defaults to 'black'.
  67276. */
  67277. customFillColor?: string;
  67278. /**
  67279. * Width and Height Value of each Frame in the TexturePacker Sets
  67280. */
  67281. frameSize?: number;
  67282. /**
  67283. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  67284. */
  67285. paddingRatio?: number;
  67286. /**
  67287. * Number that declares the fill method for the padding gutter.
  67288. */
  67289. paddingMode?: number;
  67290. /**
  67291. * If in SUBUV_COLOR padding mode what color to use.
  67292. */
  67293. paddingColor?: Color3 | Color4;
  67294. }
  67295. /**
  67296. * Defines the basic interface of a TexturePacker JSON File
  67297. */
  67298. export interface ITexturePackerJSON {
  67299. /**
  67300. * The frame ID
  67301. */
  67302. name: string;
  67303. /**
  67304. * The base64 channel data
  67305. */
  67306. sets: any;
  67307. /**
  67308. * The options of the Packer
  67309. */
  67310. options: ITexturePackerOptions;
  67311. /**
  67312. * The frame data of the Packer
  67313. */
  67314. frames: Array<number>;
  67315. }
  67316. /**
  67317. * This is a support class that generates a series of packed texture sets.
  67318. * @see https://doc.babylonjs.com/babylon101/materials
  67319. */
  67320. export class TexturePacker {
  67321. /** Packer Layout Constant 0 */
  67322. static readonly LAYOUT_STRIP: number;
  67323. /** Packer Layout Constant 1 */
  67324. static readonly LAYOUT_POWER2: number;
  67325. /** Packer Layout Constant 2 */
  67326. static readonly LAYOUT_COLNUM: number;
  67327. /** Packer Layout Constant 0 */
  67328. static readonly SUBUV_WRAP: number;
  67329. /** Packer Layout Constant 1 */
  67330. static readonly SUBUV_EXTEND: number;
  67331. /** Packer Layout Constant 2 */
  67332. static readonly SUBUV_COLOR: number;
  67333. /** The Name of the Texture Package */
  67334. name: string;
  67335. /** The scene scope of the TexturePacker */
  67336. scene: Scene;
  67337. /** The Meshes to target */
  67338. meshes: AbstractMesh[];
  67339. /** Arguments passed with the Constructor */
  67340. options: ITexturePackerOptions;
  67341. /** The promise that is started upon initialization */
  67342. promise: Nullable<Promise<TexturePacker | string>>;
  67343. /** The Container object for the channel sets that are generated */
  67344. sets: object;
  67345. /** The Container array for the frames that are generated */
  67346. frames: TexturePackerFrame[];
  67347. /** The expected number of textures the system is parsing. */
  67348. private _expecting;
  67349. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  67350. private _paddingValue;
  67351. /**
  67352. * Initializes a texture package series from an array of meshes or a single mesh.
  67353. * @param name The name of the package
  67354. * @param meshes The target meshes to compose the package from
  67355. * @param options The arguments that texture packer should follow while building.
  67356. * @param scene The scene which the textures are scoped to.
  67357. * @returns TexturePacker
  67358. */
  67359. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  67360. /**
  67361. * Starts the package process
  67362. * @param resolve The promises resolution function
  67363. * @returns TexturePacker
  67364. */
  67365. private _createFrames;
  67366. /**
  67367. * Calculates the Size of the Channel Sets
  67368. * @returns Vector2
  67369. */
  67370. private _calculateSize;
  67371. /**
  67372. * Calculates the UV data for the frames.
  67373. * @param baseSize the base frameSize
  67374. * @param padding the base frame padding
  67375. * @param dtSize size of the Dynamic Texture for that channel
  67376. * @param dtUnits is 1/dtSize
  67377. * @param update flag to update the input meshes
  67378. */
  67379. private _calculateMeshUVFrames;
  67380. /**
  67381. * Calculates the frames Offset.
  67382. * @param index of the frame
  67383. * @returns Vector2
  67384. */
  67385. private _getFrameOffset;
  67386. /**
  67387. * Updates a Mesh to the frame data
  67388. * @param mesh that is the target
  67389. * @param frameID or the frame index
  67390. */
  67391. private _updateMeshUV;
  67392. /**
  67393. * Updates a Meshes materials to use the texture packer channels
  67394. * @param m is the mesh to target
  67395. * @param force all channels on the packer to be set.
  67396. */
  67397. private _updateTextureReferences;
  67398. /**
  67399. * Public method to set a Mesh to a frame
  67400. * @param m that is the target
  67401. * @param frameID or the frame index
  67402. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  67403. */
  67404. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  67405. /**
  67406. * Starts the async promise to compile the texture packer.
  67407. * @returns Promise<void>
  67408. */
  67409. processAsync(): Promise<void>;
  67410. /**
  67411. * Disposes all textures associated with this packer
  67412. */
  67413. dispose(): void;
  67414. /**
  67415. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  67416. * @param imageType is the image type to use.
  67417. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  67418. */
  67419. download(imageType?: string, quality?: number): void;
  67420. /**
  67421. * Public method to load a texturePacker JSON file.
  67422. * @param data of the JSON file in string format.
  67423. */
  67424. updateFromJSON(data: string): void;
  67425. }
  67426. }
  67427. declare module BABYLON {
  67428. /**
  67429. * 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.
  67430. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  67431. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  67432. */
  67433. export class CustomProceduralTexture extends ProceduralTexture {
  67434. private _animate;
  67435. private _time;
  67436. private _config;
  67437. private _texturePath;
  67438. /**
  67439. * Instantiates a new Custom Procedural Texture.
  67440. * 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.
  67441. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  67442. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  67443. * @param name Define the name of the texture
  67444. * @param texturePath Define the folder path containing all the custom texture related files (config, shaders...)
  67445. * @param size Define the size of the texture to create
  67446. * @param scene Define the scene the texture belongs to
  67447. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  67448. * @param generateMipMaps Define if the texture should creates mip maps or not
  67449. */
  67450. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  67451. private _loadJson;
  67452. /**
  67453. * Is the texture ready to be used ? (rendered at least once)
  67454. * @returns true if ready, otherwise, false.
  67455. */
  67456. isReady(): boolean;
  67457. /**
  67458. * Render the texture to its associated render target.
  67459. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  67460. */
  67461. render(useCameraPostProcess?: boolean): void;
  67462. /**
  67463. * Update the list of dependant textures samplers in the shader.
  67464. */
  67465. updateTextures(): void;
  67466. /**
  67467. * Update the uniform values of the procedural texture in the shader.
  67468. */
  67469. updateShaderUniforms(): void;
  67470. /**
  67471. * Define if the texture animates or not.
  67472. */
  67473. get animate(): boolean;
  67474. set animate(value: boolean);
  67475. }
  67476. }
  67477. declare module BABYLON {
  67478. /** @hidden */
  67479. export var noisePixelShader: {
  67480. name: string;
  67481. shader: string;
  67482. };
  67483. }
  67484. declare module BABYLON {
  67485. /**
  67486. * Class used to generate noise procedural textures
  67487. */
  67488. export class NoiseProceduralTexture extends ProceduralTexture {
  67489. /** Gets or sets the start time (default is 0) */
  67490. time: number;
  67491. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  67492. brightness: number;
  67493. /** Defines the number of octaves to process */
  67494. octaves: number;
  67495. /** Defines the level of persistence (0.8 by default) */
  67496. persistence: number;
  67497. /** Gets or sets animation speed factor (default is 1) */
  67498. animationSpeedFactor: number;
  67499. /**
  67500. * Creates a new NoiseProceduralTexture
  67501. * @param name defines the name fo the texture
  67502. * @param size defines the size of the texture (default is 256)
  67503. * @param scene defines the hosting scene
  67504. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  67505. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  67506. */
  67507. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  67508. private _updateShaderUniforms;
  67509. protected _getDefines(): string;
  67510. /** Generate the current state of the procedural texture */
  67511. render(useCameraPostProcess?: boolean): void;
  67512. /**
  67513. * Serializes this noise procedural texture
  67514. * @returns a serialized noise procedural texture object
  67515. */
  67516. serialize(): any;
  67517. /**
  67518. * Clone the texture.
  67519. * @returns the cloned texture
  67520. */
  67521. clone(): NoiseProceduralTexture;
  67522. /**
  67523. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  67524. * @param parsedTexture defines parsed texture data
  67525. * @param scene defines the current scene
  67526. * @param rootUrl defines the root URL containing noise procedural texture information
  67527. * @returns a parsed NoiseProceduralTexture
  67528. */
  67529. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  67530. }
  67531. }
  67532. declare module BABYLON {
  67533. /**
  67534. * Raw cube texture where the raw buffers are passed in
  67535. */
  67536. export class RawCubeTexture extends CubeTexture {
  67537. /**
  67538. * Creates a cube texture where the raw buffers are passed in.
  67539. * @param scene defines the scene the texture is attached to
  67540. * @param data defines the array of data to use to create each face
  67541. * @param size defines the size of the textures
  67542. * @param format defines the format of the data
  67543. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  67544. * @param generateMipMaps defines if the engine should generate the mip levels
  67545. * @param invertY defines if data must be stored with Y axis inverted
  67546. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  67547. * @param compression defines the compression used (null by default)
  67548. */
  67549. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  67550. /**
  67551. * Updates the raw cube texture.
  67552. * @param data defines the data to store
  67553. * @param format defines the data format
  67554. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  67555. * @param invertY defines if data must be stored with Y axis inverted
  67556. * @param compression defines the compression used (null by default)
  67557. * @param level defines which level of the texture to update
  67558. */
  67559. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  67560. /**
  67561. * Updates a raw cube texture with RGBD encoded data.
  67562. * @param data defines the array of data [mipmap][face] to use to create each face
  67563. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  67564. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  67565. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  67566. * @returns a promise that resolves when the operation is complete
  67567. */
  67568. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  67569. /**
  67570. * Clones the raw cube texture.
  67571. * @return a new cube texture
  67572. */
  67573. clone(): CubeTexture;
  67574. /** @hidden */
  67575. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  67576. }
  67577. }
  67578. declare module BABYLON {
  67579. /**
  67580. * Class used to store 3D textures containing user data
  67581. */
  67582. export class RawTexture3D extends Texture {
  67583. /** Gets or sets the texture format to use */
  67584. format: number;
  67585. /**
  67586. * Create a new RawTexture3D
  67587. * @param data defines the data of the texture
  67588. * @param width defines the width of the texture
  67589. * @param height defines the height of the texture
  67590. * @param depth defines the depth of the texture
  67591. * @param format defines the texture format to use
  67592. * @param scene defines the hosting scene
  67593. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  67594. * @param invertY defines if texture must be stored with Y axis inverted
  67595. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  67596. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  67597. */
  67598. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  67599. /** Gets or sets the texture format to use */
  67600. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  67601. /**
  67602. * Update the texture with new data
  67603. * @param data defines the data to store in the texture
  67604. */
  67605. update(data: ArrayBufferView): void;
  67606. }
  67607. }
  67608. declare module BABYLON {
  67609. /**
  67610. * Creates a refraction texture used by refraction channel of the standard material.
  67611. * It is like a mirror but to see through a material.
  67612. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  67613. */
  67614. export class RefractionTexture extends RenderTargetTexture {
  67615. /**
  67616. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  67617. * 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.
  67618. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  67619. */
  67620. refractionPlane: Plane;
  67621. /**
  67622. * Define how deep under the surface we should see.
  67623. */
  67624. depth: number;
  67625. /**
  67626. * Creates a refraction texture used by refraction channel of the standard material.
  67627. * It is like a mirror but to see through a material.
  67628. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  67629. * @param name Define the texture name
  67630. * @param size Define the size of the underlying texture
  67631. * @param scene Define the scene the refraction belongs to
  67632. * @param generateMipMaps Define if we need to generate mips level for the refraction
  67633. */
  67634. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  67635. /**
  67636. * Clone the refraction texture.
  67637. * @returns the cloned texture
  67638. */
  67639. clone(): RefractionTexture;
  67640. /**
  67641. * Serialize the texture to a JSON representation you could use in Parse later on
  67642. * @returns the serialized JSON representation
  67643. */
  67644. serialize(): any;
  67645. }
  67646. }
  67647. declare module BABYLON {
  67648. /**
  67649. * Block used to add support for vertex skinning (bones)
  67650. */
  67651. export class BonesBlock extends NodeMaterialBlock {
  67652. /**
  67653. * Creates a new BonesBlock
  67654. * @param name defines the block name
  67655. */
  67656. constructor(name: string);
  67657. /**
  67658. * Initialize the block and prepare the context for build
  67659. * @param state defines the state that will be used for the build
  67660. */
  67661. initialize(state: NodeMaterialBuildState): void;
  67662. /**
  67663. * Gets the current class name
  67664. * @returns the class name
  67665. */
  67666. getClassName(): string;
  67667. /**
  67668. * Gets the matrix indices input component
  67669. */
  67670. get matricesIndices(): NodeMaterialConnectionPoint;
  67671. /**
  67672. * Gets the matrix weights input component
  67673. */
  67674. get matricesWeights(): NodeMaterialConnectionPoint;
  67675. /**
  67676. * Gets the extra matrix indices input component
  67677. */
  67678. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  67679. /**
  67680. * Gets the extra matrix weights input component
  67681. */
  67682. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  67683. /**
  67684. * Gets the world input component
  67685. */
  67686. get world(): NodeMaterialConnectionPoint;
  67687. /**
  67688. * Gets the output component
  67689. */
  67690. get output(): NodeMaterialConnectionPoint;
  67691. autoConfigure(material: NodeMaterial): void;
  67692. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  67693. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67694. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67695. protected _buildBlock(state: NodeMaterialBuildState): this;
  67696. }
  67697. }
  67698. declare module BABYLON {
  67699. /**
  67700. * Block used to add support for instances
  67701. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  67702. */
  67703. export class InstancesBlock extends NodeMaterialBlock {
  67704. /**
  67705. * Creates a new InstancesBlock
  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 first world row input component
  67716. */
  67717. get world0(): NodeMaterialConnectionPoint;
  67718. /**
  67719. * Gets the second world row input component
  67720. */
  67721. get world1(): NodeMaterialConnectionPoint;
  67722. /**
  67723. * Gets the third world row input component
  67724. */
  67725. get world2(): NodeMaterialConnectionPoint;
  67726. /**
  67727. * Gets the forth world row input component
  67728. */
  67729. get world3(): NodeMaterialConnectionPoint;
  67730. /**
  67731. * Gets the world input component
  67732. */
  67733. get world(): NodeMaterialConnectionPoint;
  67734. /**
  67735. * Gets the output component
  67736. */
  67737. get output(): NodeMaterialConnectionPoint;
  67738. /**
  67739. * Gets the instanceID component
  67740. */
  67741. get instanceID(): NodeMaterialConnectionPoint;
  67742. autoConfigure(material: NodeMaterial): void;
  67743. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  67744. protected _buildBlock(state: NodeMaterialBuildState): this;
  67745. }
  67746. }
  67747. declare module BABYLON {
  67748. /**
  67749. * Block used to add morph targets support to vertex shader
  67750. */
  67751. export class MorphTargetsBlock extends NodeMaterialBlock {
  67752. private _repeatableContentAnchor;
  67753. /**
  67754. * Create a new MorphTargetsBlock
  67755. * @param name defines the block name
  67756. */
  67757. constructor(name: string);
  67758. /**
  67759. * Gets the current class name
  67760. * @returns the class name
  67761. */
  67762. getClassName(): string;
  67763. /**
  67764. * Gets the position input component
  67765. */
  67766. get position(): NodeMaterialConnectionPoint;
  67767. /**
  67768. * Gets the normal input component
  67769. */
  67770. get normal(): NodeMaterialConnectionPoint;
  67771. /**
  67772. * Gets the tangent input component
  67773. */
  67774. get tangent(): NodeMaterialConnectionPoint;
  67775. /**
  67776. * Gets the tangent input component
  67777. */
  67778. get uv(): NodeMaterialConnectionPoint;
  67779. /**
  67780. * Gets the position output component
  67781. */
  67782. get positionOutput(): NodeMaterialConnectionPoint;
  67783. /**
  67784. * Gets the normal output component
  67785. */
  67786. get normalOutput(): NodeMaterialConnectionPoint;
  67787. /**
  67788. * Gets the tangent output component
  67789. */
  67790. get tangentOutput(): NodeMaterialConnectionPoint;
  67791. /**
  67792. * Gets the tangent output component
  67793. */
  67794. get uvOutput(): NodeMaterialConnectionPoint;
  67795. initialize(state: NodeMaterialBuildState): void;
  67796. autoConfigure(material: NodeMaterial): void;
  67797. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67798. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67799. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  67800. protected _buildBlock(state: NodeMaterialBuildState): this;
  67801. }
  67802. }
  67803. declare module BABYLON {
  67804. /**
  67805. * Block used to get data information from a light
  67806. */
  67807. export class LightInformationBlock extends NodeMaterialBlock {
  67808. private _lightDataUniformName;
  67809. private _lightColorUniformName;
  67810. private _lightTypeDefineName;
  67811. /**
  67812. * Gets or sets the light associated with this block
  67813. */
  67814. light: Nullable<Light>;
  67815. /**
  67816. * Creates a new LightInformationBlock
  67817. * @param name defines the block name
  67818. */
  67819. constructor(name: string);
  67820. /**
  67821. * Gets the current class name
  67822. * @returns the class name
  67823. */
  67824. getClassName(): string;
  67825. /**
  67826. * Gets the world position input component
  67827. */
  67828. get worldPosition(): NodeMaterialConnectionPoint;
  67829. /**
  67830. * Gets the direction output component
  67831. */
  67832. get direction(): NodeMaterialConnectionPoint;
  67833. /**
  67834. * Gets the direction output component
  67835. */
  67836. get color(): NodeMaterialConnectionPoint;
  67837. /**
  67838. * Gets the direction output component
  67839. */
  67840. get intensity(): NodeMaterialConnectionPoint;
  67841. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67842. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67843. protected _buildBlock(state: NodeMaterialBuildState): this;
  67844. serialize(): any;
  67845. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67846. }
  67847. }
  67848. declare module BABYLON {
  67849. /**
  67850. * Block used to add image processing support to fragment shader
  67851. */
  67852. export class ImageProcessingBlock extends NodeMaterialBlock {
  67853. /**
  67854. * Create a new ImageProcessingBlock
  67855. * @param name defines the block name
  67856. */
  67857. constructor(name: string);
  67858. /**
  67859. * Gets the current class name
  67860. * @returns the class name
  67861. */
  67862. getClassName(): string;
  67863. /**
  67864. * Gets the color input component
  67865. */
  67866. get color(): NodeMaterialConnectionPoint;
  67867. /**
  67868. * Gets the output component
  67869. */
  67870. get output(): NodeMaterialConnectionPoint;
  67871. /**
  67872. * Initialize the block and prepare the context for build
  67873. * @param state defines the state that will be used for the build
  67874. */
  67875. initialize(state: NodeMaterialBuildState): void;
  67876. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  67877. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67878. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67879. protected _buildBlock(state: NodeMaterialBuildState): this;
  67880. }
  67881. }
  67882. declare module BABYLON {
  67883. /**
  67884. * Block used to perturb normals based on a normal map
  67885. */
  67886. export class PerturbNormalBlock extends NodeMaterialBlock {
  67887. private _tangentSpaceParameterName;
  67888. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  67889. invertX: boolean;
  67890. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  67891. invertY: boolean;
  67892. /**
  67893. * Create a new PerturbNormalBlock
  67894. * @param name defines the block name
  67895. */
  67896. constructor(name: string);
  67897. /**
  67898. * Gets the current class name
  67899. * @returns the class name
  67900. */
  67901. getClassName(): string;
  67902. /**
  67903. * Gets the world position input component
  67904. */
  67905. get worldPosition(): NodeMaterialConnectionPoint;
  67906. /**
  67907. * Gets the world normal input component
  67908. */
  67909. get worldNormal(): NodeMaterialConnectionPoint;
  67910. /**
  67911. * Gets the world tangent input component
  67912. */
  67913. get worldTangent(): NodeMaterialConnectionPoint;
  67914. /**
  67915. * Gets the uv input component
  67916. */
  67917. get uv(): NodeMaterialConnectionPoint;
  67918. /**
  67919. * Gets the normal map color input component
  67920. */
  67921. get normalMapColor(): NodeMaterialConnectionPoint;
  67922. /**
  67923. * Gets the strength input component
  67924. */
  67925. get strength(): NodeMaterialConnectionPoint;
  67926. /**
  67927. * Gets the output component
  67928. */
  67929. get output(): NodeMaterialConnectionPoint;
  67930. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67931. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67932. autoConfigure(material: NodeMaterial): void;
  67933. protected _buildBlock(state: NodeMaterialBuildState): this;
  67934. protected _dumpPropertiesCode(): string;
  67935. serialize(): any;
  67936. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67937. }
  67938. }
  67939. declare module BABYLON {
  67940. /**
  67941. * Block used to discard a pixel if a value is smaller than a cutoff
  67942. */
  67943. export class DiscardBlock extends NodeMaterialBlock {
  67944. /**
  67945. * Create a new DiscardBlock
  67946. * @param name defines the block name
  67947. */
  67948. constructor(name: string);
  67949. /**
  67950. * Gets the current class name
  67951. * @returns the class name
  67952. */
  67953. getClassName(): string;
  67954. /**
  67955. * Gets the color input component
  67956. */
  67957. get value(): NodeMaterialConnectionPoint;
  67958. /**
  67959. * Gets the cutoff input component
  67960. */
  67961. get cutoff(): NodeMaterialConnectionPoint;
  67962. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67963. }
  67964. }
  67965. declare module BABYLON {
  67966. /**
  67967. * Block used to test if the fragment shader is front facing
  67968. */
  67969. export class FrontFacingBlock extends NodeMaterialBlock {
  67970. /**
  67971. * Creates a new FrontFacingBlock
  67972. * @param name defines the block name
  67973. */
  67974. constructor(name: string);
  67975. /**
  67976. * Gets the current class name
  67977. * @returns the class name
  67978. */
  67979. getClassName(): string;
  67980. /**
  67981. * Gets the output component
  67982. */
  67983. get output(): NodeMaterialConnectionPoint;
  67984. protected _buildBlock(state: NodeMaterialBuildState): this;
  67985. }
  67986. }
  67987. declare module BABYLON {
  67988. /**
  67989. * Block used to get the derivative value on x and y of a given input
  67990. */
  67991. export class DerivativeBlock extends NodeMaterialBlock {
  67992. /**
  67993. * Create a new DerivativeBlock
  67994. * @param name defines the block name
  67995. */
  67996. constructor(name: string);
  67997. /**
  67998. * Gets the current class name
  67999. * @returns the class name
  68000. */
  68001. getClassName(): string;
  68002. /**
  68003. * Gets the input component
  68004. */
  68005. get input(): NodeMaterialConnectionPoint;
  68006. /**
  68007. * Gets the derivative output on x
  68008. */
  68009. get dx(): NodeMaterialConnectionPoint;
  68010. /**
  68011. * Gets the derivative output on y
  68012. */
  68013. get dy(): NodeMaterialConnectionPoint;
  68014. protected _buildBlock(state: NodeMaterialBuildState): this;
  68015. }
  68016. }
  68017. declare module BABYLON {
  68018. /**
  68019. * Block used to make gl_FragCoord available
  68020. */
  68021. export class FragCoordBlock extends NodeMaterialBlock {
  68022. /**
  68023. * Creates a new FragCoordBlock
  68024. * @param name defines the block name
  68025. */
  68026. constructor(name: string);
  68027. /**
  68028. * Gets the current class name
  68029. * @returns the class name
  68030. */
  68031. getClassName(): string;
  68032. /**
  68033. * Gets the xy component
  68034. */
  68035. get xy(): NodeMaterialConnectionPoint;
  68036. /**
  68037. * Gets the xyz component
  68038. */
  68039. get xyz(): NodeMaterialConnectionPoint;
  68040. /**
  68041. * Gets the xyzw component
  68042. */
  68043. get xyzw(): NodeMaterialConnectionPoint;
  68044. /**
  68045. * Gets the x component
  68046. */
  68047. get x(): NodeMaterialConnectionPoint;
  68048. /**
  68049. * Gets the y component
  68050. */
  68051. get y(): NodeMaterialConnectionPoint;
  68052. /**
  68053. * Gets the z component
  68054. */
  68055. get z(): NodeMaterialConnectionPoint;
  68056. /**
  68057. * Gets the w component
  68058. */
  68059. get output(): NodeMaterialConnectionPoint;
  68060. protected writeOutputs(state: NodeMaterialBuildState): string;
  68061. protected _buildBlock(state: NodeMaterialBuildState): this;
  68062. }
  68063. }
  68064. declare module BABYLON {
  68065. /**
  68066. * Block used to get the screen sizes
  68067. */
  68068. export class ScreenSizeBlock extends NodeMaterialBlock {
  68069. private _varName;
  68070. private _scene;
  68071. /**
  68072. * Creates a new ScreenSizeBlock
  68073. * @param name defines the block name
  68074. */
  68075. constructor(name: string);
  68076. /**
  68077. * Gets the current class name
  68078. * @returns the class name
  68079. */
  68080. getClassName(): string;
  68081. /**
  68082. * Gets the xy component
  68083. */
  68084. get xy(): NodeMaterialConnectionPoint;
  68085. /**
  68086. * Gets the x component
  68087. */
  68088. get x(): NodeMaterialConnectionPoint;
  68089. /**
  68090. * Gets the y component
  68091. */
  68092. get y(): NodeMaterialConnectionPoint;
  68093. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  68094. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  68095. protected _buildBlock(state: NodeMaterialBuildState): this;
  68096. }
  68097. }
  68098. declare module BABYLON {
  68099. /**
  68100. * Block used to add support for scene fog
  68101. */
  68102. export class FogBlock extends NodeMaterialBlock {
  68103. private _fogDistanceName;
  68104. private _fogParameters;
  68105. /**
  68106. * Create a new FogBlock
  68107. * @param name defines the block name
  68108. */
  68109. constructor(name: string);
  68110. /**
  68111. * Gets the current class name
  68112. * @returns the class name
  68113. */
  68114. getClassName(): string;
  68115. /**
  68116. * Gets the world position input component
  68117. */
  68118. get worldPosition(): NodeMaterialConnectionPoint;
  68119. /**
  68120. * Gets the view input component
  68121. */
  68122. get view(): NodeMaterialConnectionPoint;
  68123. /**
  68124. * Gets the color input component
  68125. */
  68126. get input(): NodeMaterialConnectionPoint;
  68127. /**
  68128. * Gets the fog color input component
  68129. */
  68130. get fogColor(): NodeMaterialConnectionPoint;
  68131. /**
  68132. * Gets the output component
  68133. */
  68134. get output(): NodeMaterialConnectionPoint;
  68135. autoConfigure(material: NodeMaterial): void;
  68136. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68137. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  68138. protected _buildBlock(state: NodeMaterialBuildState): this;
  68139. }
  68140. }
  68141. declare module BABYLON {
  68142. /**
  68143. * Block used to add light in the fragment shader
  68144. */
  68145. export class LightBlock extends NodeMaterialBlock {
  68146. private _lightId;
  68147. /**
  68148. * Gets or sets the light associated with this block
  68149. */
  68150. light: Nullable<Light>;
  68151. /**
  68152. * Create a new LightBlock
  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 world position input component
  68163. */
  68164. get worldPosition(): NodeMaterialConnectionPoint;
  68165. /**
  68166. * Gets the world normal input component
  68167. */
  68168. get worldNormal(): NodeMaterialConnectionPoint;
  68169. /**
  68170. * Gets the camera (or eye) position component
  68171. */
  68172. get cameraPosition(): NodeMaterialConnectionPoint;
  68173. /**
  68174. * Gets the glossiness component
  68175. */
  68176. get glossiness(): NodeMaterialConnectionPoint;
  68177. /**
  68178. * Gets the glossiness power component
  68179. */
  68180. get glossPower(): NodeMaterialConnectionPoint;
  68181. /**
  68182. * Gets the diffuse color component
  68183. */
  68184. get diffuseColor(): NodeMaterialConnectionPoint;
  68185. /**
  68186. * Gets the specular color component
  68187. */
  68188. get specularColor(): NodeMaterialConnectionPoint;
  68189. /**
  68190. * Gets the view matrix component
  68191. */
  68192. get view(): NodeMaterialConnectionPoint;
  68193. /**
  68194. * Gets the diffuse output component
  68195. */
  68196. get diffuseOutput(): NodeMaterialConnectionPoint;
  68197. /**
  68198. * Gets the specular output component
  68199. */
  68200. get specularOutput(): NodeMaterialConnectionPoint;
  68201. /**
  68202. * Gets the shadow output component
  68203. */
  68204. get shadow(): NodeMaterialConnectionPoint;
  68205. autoConfigure(material: NodeMaterial): void;
  68206. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68207. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  68208. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  68209. private _injectVertexCode;
  68210. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  68211. serialize(): any;
  68212. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68213. }
  68214. }
  68215. declare module BABYLON {
  68216. /**
  68217. * Block used to read a reflection texture from a sampler
  68218. */
  68219. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  68220. /**
  68221. * Create a new ReflectionTextureBlock
  68222. * @param name defines the block name
  68223. */
  68224. constructor(name: string);
  68225. /**
  68226. * Gets the current class name
  68227. * @returns the class name
  68228. */
  68229. getClassName(): string;
  68230. /**
  68231. * Gets the world position input component
  68232. */
  68233. get position(): NodeMaterialConnectionPoint;
  68234. /**
  68235. * Gets the world position input component
  68236. */
  68237. get worldPosition(): NodeMaterialConnectionPoint;
  68238. /**
  68239. * Gets the world normal input component
  68240. */
  68241. get worldNormal(): NodeMaterialConnectionPoint;
  68242. /**
  68243. * Gets the world input component
  68244. */
  68245. get world(): NodeMaterialConnectionPoint;
  68246. /**
  68247. * Gets the camera (or eye) position component
  68248. */
  68249. get cameraPosition(): NodeMaterialConnectionPoint;
  68250. /**
  68251. * Gets the view input component
  68252. */
  68253. get view(): NodeMaterialConnectionPoint;
  68254. /**
  68255. * Gets the rgb output component
  68256. */
  68257. get rgb(): NodeMaterialConnectionPoint;
  68258. /**
  68259. * Gets the rgba output component
  68260. */
  68261. get rgba(): NodeMaterialConnectionPoint;
  68262. /**
  68263. * Gets the r output component
  68264. */
  68265. get r(): NodeMaterialConnectionPoint;
  68266. /**
  68267. * Gets the g output component
  68268. */
  68269. get g(): NodeMaterialConnectionPoint;
  68270. /**
  68271. * Gets the b output component
  68272. */
  68273. get b(): NodeMaterialConnectionPoint;
  68274. /**
  68275. * Gets the a output component
  68276. */
  68277. get a(): NodeMaterialConnectionPoint;
  68278. autoConfigure(material: NodeMaterial): void;
  68279. protected _buildBlock(state: NodeMaterialBuildState): this;
  68280. }
  68281. }
  68282. declare module BABYLON {
  68283. /**
  68284. * Block used to add 2 vectors
  68285. */
  68286. export class AddBlock extends NodeMaterialBlock {
  68287. /**
  68288. * Creates a new AddBlock
  68289. * @param name defines the block name
  68290. */
  68291. constructor(name: string);
  68292. /**
  68293. * Gets the current class name
  68294. * @returns the class name
  68295. */
  68296. getClassName(): string;
  68297. /**
  68298. * Gets the left operand input component
  68299. */
  68300. get left(): NodeMaterialConnectionPoint;
  68301. /**
  68302. * Gets the right operand input component
  68303. */
  68304. get right(): NodeMaterialConnectionPoint;
  68305. /**
  68306. * Gets the output component
  68307. */
  68308. get output(): NodeMaterialConnectionPoint;
  68309. protected _buildBlock(state: NodeMaterialBuildState): this;
  68310. }
  68311. }
  68312. declare module BABYLON {
  68313. /**
  68314. * Block used to scale a vector by a float
  68315. */
  68316. export class ScaleBlock extends NodeMaterialBlock {
  68317. /**
  68318. * Creates a new ScaleBlock
  68319. * @param name defines the block name
  68320. */
  68321. constructor(name: string);
  68322. /**
  68323. * Gets the current class name
  68324. * @returns the class name
  68325. */
  68326. getClassName(): string;
  68327. /**
  68328. * Gets the input component
  68329. */
  68330. get input(): NodeMaterialConnectionPoint;
  68331. /**
  68332. * Gets the factor input component
  68333. */
  68334. get factor(): NodeMaterialConnectionPoint;
  68335. /**
  68336. * Gets the output component
  68337. */
  68338. get output(): NodeMaterialConnectionPoint;
  68339. protected _buildBlock(state: NodeMaterialBuildState): this;
  68340. }
  68341. }
  68342. declare module BABYLON {
  68343. /**
  68344. * Block used to clamp a float
  68345. */
  68346. export class ClampBlock extends NodeMaterialBlock {
  68347. /** Gets or sets the minimum range */
  68348. minimum: number;
  68349. /** Gets or sets the maximum range */
  68350. maximum: number;
  68351. /**
  68352. * Creates a new ClampBlock
  68353. * @param name defines the block name
  68354. */
  68355. constructor(name: string);
  68356. /**
  68357. * Gets the current class name
  68358. * @returns the class name
  68359. */
  68360. getClassName(): string;
  68361. /**
  68362. * Gets the value input component
  68363. */
  68364. get value(): NodeMaterialConnectionPoint;
  68365. /**
  68366. * Gets the output component
  68367. */
  68368. get output(): NodeMaterialConnectionPoint;
  68369. protected _buildBlock(state: NodeMaterialBuildState): this;
  68370. protected _dumpPropertiesCode(): string;
  68371. serialize(): any;
  68372. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68373. }
  68374. }
  68375. declare module BABYLON {
  68376. /**
  68377. * Block used to apply a cross product between 2 vectors
  68378. */
  68379. export class CrossBlock extends NodeMaterialBlock {
  68380. /**
  68381. * Creates a new CrossBlock
  68382. * @param name defines the block name
  68383. */
  68384. constructor(name: string);
  68385. /**
  68386. * Gets the current class name
  68387. * @returns the class name
  68388. */
  68389. getClassName(): string;
  68390. /**
  68391. * Gets the left operand input component
  68392. */
  68393. get left(): NodeMaterialConnectionPoint;
  68394. /**
  68395. * Gets the right operand input component
  68396. */
  68397. get right(): NodeMaterialConnectionPoint;
  68398. /**
  68399. * Gets the output component
  68400. */
  68401. get output(): NodeMaterialConnectionPoint;
  68402. protected _buildBlock(state: NodeMaterialBuildState): this;
  68403. }
  68404. }
  68405. declare module BABYLON {
  68406. /**
  68407. * Block used to apply a dot product between 2 vectors
  68408. */
  68409. export class DotBlock extends NodeMaterialBlock {
  68410. /**
  68411. * Creates a new DotBlock
  68412. * @param name defines the block name
  68413. */
  68414. constructor(name: string);
  68415. /**
  68416. * Gets the current class name
  68417. * @returns the class name
  68418. */
  68419. getClassName(): string;
  68420. /**
  68421. * Gets the left operand input component
  68422. */
  68423. get left(): NodeMaterialConnectionPoint;
  68424. /**
  68425. * Gets the right operand input component
  68426. */
  68427. get right(): NodeMaterialConnectionPoint;
  68428. /**
  68429. * Gets the output component
  68430. */
  68431. get output(): NodeMaterialConnectionPoint;
  68432. protected _buildBlock(state: NodeMaterialBuildState): this;
  68433. }
  68434. }
  68435. declare module BABYLON {
  68436. /**
  68437. * Block used to normalize a vector
  68438. */
  68439. export class NormalizeBlock extends NodeMaterialBlock {
  68440. /**
  68441. * Creates a new NormalizeBlock
  68442. * @param name defines the block name
  68443. */
  68444. constructor(name: string);
  68445. /**
  68446. * Gets the current class name
  68447. * @returns the class name
  68448. */
  68449. getClassName(): string;
  68450. /**
  68451. * Gets the input component
  68452. */
  68453. get input(): NodeMaterialConnectionPoint;
  68454. /**
  68455. * Gets the output component
  68456. */
  68457. get output(): NodeMaterialConnectionPoint;
  68458. protected _buildBlock(state: NodeMaterialBuildState): this;
  68459. }
  68460. }
  68461. declare module BABYLON {
  68462. /**
  68463. * Block used to create a Color3/4 out of individual inputs (one for each component)
  68464. */
  68465. export class ColorMergerBlock extends NodeMaterialBlock {
  68466. /**
  68467. * Create a new ColorMergerBlock
  68468. * @param name defines the block name
  68469. */
  68470. constructor(name: string);
  68471. /**
  68472. * Gets the current class name
  68473. * @returns the class name
  68474. */
  68475. getClassName(): string;
  68476. /**
  68477. * Gets the rgb component (input)
  68478. */
  68479. get rgbIn(): NodeMaterialConnectionPoint;
  68480. /**
  68481. * Gets the r component (input)
  68482. */
  68483. get r(): NodeMaterialConnectionPoint;
  68484. /**
  68485. * Gets the g component (input)
  68486. */
  68487. get g(): NodeMaterialConnectionPoint;
  68488. /**
  68489. * Gets the b component (input)
  68490. */
  68491. get b(): NodeMaterialConnectionPoint;
  68492. /**
  68493. * Gets the a component (input)
  68494. */
  68495. get a(): NodeMaterialConnectionPoint;
  68496. /**
  68497. * Gets the rgba component (output)
  68498. */
  68499. get rgba(): NodeMaterialConnectionPoint;
  68500. /**
  68501. * Gets the rgb component (output)
  68502. */
  68503. get rgbOut(): NodeMaterialConnectionPoint;
  68504. /**
  68505. * Gets the rgb component (output)
  68506. * @deprecated Please use rgbOut instead.
  68507. */
  68508. get rgb(): NodeMaterialConnectionPoint;
  68509. protected _buildBlock(state: NodeMaterialBuildState): this;
  68510. }
  68511. }
  68512. declare module BABYLON {
  68513. /**
  68514. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  68515. */
  68516. export class VectorSplitterBlock extends NodeMaterialBlock {
  68517. /**
  68518. * Create a new VectorSplitterBlock
  68519. * @param name defines the block name
  68520. */
  68521. constructor(name: string);
  68522. /**
  68523. * Gets the current class name
  68524. * @returns the class name
  68525. */
  68526. getClassName(): string;
  68527. /**
  68528. * Gets the xyzw component (input)
  68529. */
  68530. get xyzw(): NodeMaterialConnectionPoint;
  68531. /**
  68532. * Gets the xyz component (input)
  68533. */
  68534. get xyzIn(): NodeMaterialConnectionPoint;
  68535. /**
  68536. * Gets the xy component (input)
  68537. */
  68538. get xyIn(): NodeMaterialConnectionPoint;
  68539. /**
  68540. * Gets the xyz component (output)
  68541. */
  68542. get xyzOut(): NodeMaterialConnectionPoint;
  68543. /**
  68544. * Gets the xy component (output)
  68545. */
  68546. get xyOut(): NodeMaterialConnectionPoint;
  68547. /**
  68548. * Gets the x component (output)
  68549. */
  68550. get x(): NodeMaterialConnectionPoint;
  68551. /**
  68552. * Gets the y component (output)
  68553. */
  68554. get y(): NodeMaterialConnectionPoint;
  68555. /**
  68556. * Gets the z component (output)
  68557. */
  68558. get z(): NodeMaterialConnectionPoint;
  68559. /**
  68560. * Gets the w component (output)
  68561. */
  68562. get w(): NodeMaterialConnectionPoint;
  68563. protected _inputRename(name: string): string;
  68564. protected _outputRename(name: string): string;
  68565. protected _buildBlock(state: NodeMaterialBuildState): this;
  68566. }
  68567. }
  68568. declare module BABYLON {
  68569. /**
  68570. * Block used to lerp between 2 values
  68571. */
  68572. export class LerpBlock extends NodeMaterialBlock {
  68573. /**
  68574. * Creates a new LerpBlock
  68575. * @param name defines the block name
  68576. */
  68577. constructor(name: string);
  68578. /**
  68579. * Gets the current class name
  68580. * @returns the class name
  68581. */
  68582. getClassName(): string;
  68583. /**
  68584. * Gets the left operand input component
  68585. */
  68586. get left(): NodeMaterialConnectionPoint;
  68587. /**
  68588. * Gets the right operand input component
  68589. */
  68590. get right(): NodeMaterialConnectionPoint;
  68591. /**
  68592. * Gets the gradient operand input component
  68593. */
  68594. get gradient(): NodeMaterialConnectionPoint;
  68595. /**
  68596. * Gets the output component
  68597. */
  68598. get output(): NodeMaterialConnectionPoint;
  68599. protected _buildBlock(state: NodeMaterialBuildState): this;
  68600. }
  68601. }
  68602. declare module BABYLON {
  68603. /**
  68604. * Block used to divide 2 vectors
  68605. */
  68606. export class DivideBlock extends NodeMaterialBlock {
  68607. /**
  68608. * Creates a new DivideBlock
  68609. * @param name defines the block name
  68610. */
  68611. constructor(name: string);
  68612. /**
  68613. * Gets the current class name
  68614. * @returns the class name
  68615. */
  68616. getClassName(): string;
  68617. /**
  68618. * Gets the left operand input component
  68619. */
  68620. get left(): NodeMaterialConnectionPoint;
  68621. /**
  68622. * Gets the right operand input component
  68623. */
  68624. get right(): NodeMaterialConnectionPoint;
  68625. /**
  68626. * Gets the output component
  68627. */
  68628. get output(): NodeMaterialConnectionPoint;
  68629. protected _buildBlock(state: NodeMaterialBuildState): this;
  68630. }
  68631. }
  68632. declare module BABYLON {
  68633. /**
  68634. * Block used to subtract 2 vectors
  68635. */
  68636. export class SubtractBlock extends NodeMaterialBlock {
  68637. /**
  68638. * Creates a new SubtractBlock
  68639. * @param name defines the block name
  68640. */
  68641. constructor(name: string);
  68642. /**
  68643. * Gets the current class name
  68644. * @returns the class name
  68645. */
  68646. getClassName(): string;
  68647. /**
  68648. * Gets the left operand input component
  68649. */
  68650. get left(): NodeMaterialConnectionPoint;
  68651. /**
  68652. * Gets the right operand input component
  68653. */
  68654. get right(): NodeMaterialConnectionPoint;
  68655. /**
  68656. * Gets the output component
  68657. */
  68658. get output(): NodeMaterialConnectionPoint;
  68659. protected _buildBlock(state: NodeMaterialBuildState): this;
  68660. }
  68661. }
  68662. declare module BABYLON {
  68663. /**
  68664. * Block used to step a value
  68665. */
  68666. export class StepBlock extends NodeMaterialBlock {
  68667. /**
  68668. * Creates a new StepBlock
  68669. * @param name defines the block name
  68670. */
  68671. constructor(name: string);
  68672. /**
  68673. * Gets the current class name
  68674. * @returns the class name
  68675. */
  68676. getClassName(): string;
  68677. /**
  68678. * Gets the value operand input component
  68679. */
  68680. get value(): NodeMaterialConnectionPoint;
  68681. /**
  68682. * Gets the edge operand input component
  68683. */
  68684. get edge(): NodeMaterialConnectionPoint;
  68685. /**
  68686. * Gets the output component
  68687. */
  68688. get output(): NodeMaterialConnectionPoint;
  68689. protected _buildBlock(state: NodeMaterialBuildState): this;
  68690. }
  68691. }
  68692. declare module BABYLON {
  68693. /**
  68694. * Block used to get the opposite (1 - x) of a value
  68695. */
  68696. export class OneMinusBlock extends NodeMaterialBlock {
  68697. /**
  68698. * Creates a new OneMinusBlock
  68699. * @param name defines the block name
  68700. */
  68701. constructor(name: string);
  68702. /**
  68703. * Gets the current class name
  68704. * @returns the class name
  68705. */
  68706. getClassName(): string;
  68707. /**
  68708. * Gets the input component
  68709. */
  68710. get input(): NodeMaterialConnectionPoint;
  68711. /**
  68712. * Gets the output component
  68713. */
  68714. get output(): NodeMaterialConnectionPoint;
  68715. protected _buildBlock(state: NodeMaterialBuildState): this;
  68716. }
  68717. }
  68718. declare module BABYLON {
  68719. /**
  68720. * Block used to get the view direction
  68721. */
  68722. export class ViewDirectionBlock extends NodeMaterialBlock {
  68723. /**
  68724. * Creates a new ViewDirectionBlock
  68725. * @param name defines the block name
  68726. */
  68727. constructor(name: string);
  68728. /**
  68729. * Gets the current class name
  68730. * @returns the class name
  68731. */
  68732. getClassName(): string;
  68733. /**
  68734. * Gets the world position component
  68735. */
  68736. get worldPosition(): NodeMaterialConnectionPoint;
  68737. /**
  68738. * Gets the camera position component
  68739. */
  68740. get cameraPosition(): NodeMaterialConnectionPoint;
  68741. /**
  68742. * Gets the output component
  68743. */
  68744. get output(): NodeMaterialConnectionPoint;
  68745. autoConfigure(material: NodeMaterial): void;
  68746. protected _buildBlock(state: NodeMaterialBuildState): this;
  68747. }
  68748. }
  68749. declare module BABYLON {
  68750. /**
  68751. * Block used to compute fresnel value
  68752. */
  68753. export class FresnelBlock extends NodeMaterialBlock {
  68754. /**
  68755. * Create a new FresnelBlock
  68756. * @param name defines the block name
  68757. */
  68758. constructor(name: string);
  68759. /**
  68760. * Gets the current class name
  68761. * @returns the class name
  68762. */
  68763. getClassName(): string;
  68764. /**
  68765. * Gets the world normal input component
  68766. */
  68767. get worldNormal(): NodeMaterialConnectionPoint;
  68768. /**
  68769. * Gets the view direction input component
  68770. */
  68771. get viewDirection(): NodeMaterialConnectionPoint;
  68772. /**
  68773. * Gets the bias input component
  68774. */
  68775. get bias(): NodeMaterialConnectionPoint;
  68776. /**
  68777. * Gets the camera (or eye) position component
  68778. */
  68779. get power(): NodeMaterialConnectionPoint;
  68780. /**
  68781. * Gets the fresnel output component
  68782. */
  68783. get fresnel(): NodeMaterialConnectionPoint;
  68784. autoConfigure(material: NodeMaterial): void;
  68785. protected _buildBlock(state: NodeMaterialBuildState): this;
  68786. }
  68787. }
  68788. declare module BABYLON {
  68789. /**
  68790. * Block used to get the max of 2 values
  68791. */
  68792. export class MaxBlock extends NodeMaterialBlock {
  68793. /**
  68794. * Creates a new MaxBlock
  68795. * @param name defines the block name
  68796. */
  68797. constructor(name: string);
  68798. /**
  68799. * Gets the current class name
  68800. * @returns the class name
  68801. */
  68802. getClassName(): string;
  68803. /**
  68804. * Gets the left operand input component
  68805. */
  68806. get left(): NodeMaterialConnectionPoint;
  68807. /**
  68808. * Gets the right operand input component
  68809. */
  68810. get right(): NodeMaterialConnectionPoint;
  68811. /**
  68812. * Gets the output component
  68813. */
  68814. get output(): NodeMaterialConnectionPoint;
  68815. protected _buildBlock(state: NodeMaterialBuildState): this;
  68816. }
  68817. }
  68818. declare module BABYLON {
  68819. /**
  68820. * Block used to get the min of 2 values
  68821. */
  68822. export class MinBlock extends NodeMaterialBlock {
  68823. /**
  68824. * Creates a new MinBlock
  68825. * @param name defines the block name
  68826. */
  68827. constructor(name: string);
  68828. /**
  68829. * Gets the current class name
  68830. * @returns the class name
  68831. */
  68832. getClassName(): string;
  68833. /**
  68834. * Gets the left operand input component
  68835. */
  68836. get left(): NodeMaterialConnectionPoint;
  68837. /**
  68838. * Gets the right operand input component
  68839. */
  68840. get right(): NodeMaterialConnectionPoint;
  68841. /**
  68842. * Gets the output component
  68843. */
  68844. get output(): NodeMaterialConnectionPoint;
  68845. protected _buildBlock(state: NodeMaterialBuildState): this;
  68846. }
  68847. }
  68848. declare module BABYLON {
  68849. /**
  68850. * Block used to get the distance between 2 values
  68851. */
  68852. export class DistanceBlock extends NodeMaterialBlock {
  68853. /**
  68854. * Creates a new DistanceBlock
  68855. * @param name defines the block name
  68856. */
  68857. constructor(name: string);
  68858. /**
  68859. * Gets the current class name
  68860. * @returns the class name
  68861. */
  68862. getClassName(): string;
  68863. /**
  68864. * Gets the left operand input component
  68865. */
  68866. get left(): NodeMaterialConnectionPoint;
  68867. /**
  68868. * Gets the right operand input component
  68869. */
  68870. get right(): NodeMaterialConnectionPoint;
  68871. /**
  68872. * Gets the output component
  68873. */
  68874. get output(): NodeMaterialConnectionPoint;
  68875. protected _buildBlock(state: NodeMaterialBuildState): this;
  68876. }
  68877. }
  68878. declare module BABYLON {
  68879. /**
  68880. * Block used to get the length of a vector
  68881. */
  68882. export class LengthBlock extends NodeMaterialBlock {
  68883. /**
  68884. * Creates a new LengthBlock
  68885. * @param name defines the block name
  68886. */
  68887. constructor(name: string);
  68888. /**
  68889. * Gets the current class name
  68890. * @returns the class name
  68891. */
  68892. getClassName(): string;
  68893. /**
  68894. * Gets the value input component
  68895. */
  68896. get value(): NodeMaterialConnectionPoint;
  68897. /**
  68898. * Gets the output component
  68899. */
  68900. get output(): NodeMaterialConnectionPoint;
  68901. protected _buildBlock(state: NodeMaterialBuildState): this;
  68902. }
  68903. }
  68904. declare module BABYLON {
  68905. /**
  68906. * Block used to get negative version of a value (i.e. x * -1)
  68907. */
  68908. export class NegateBlock extends NodeMaterialBlock {
  68909. /**
  68910. * Creates a new NegateBlock
  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 value input component
  68921. */
  68922. get value(): NodeMaterialConnectionPoint;
  68923. /**
  68924. * Gets the output component
  68925. */
  68926. get output(): NodeMaterialConnectionPoint;
  68927. protected _buildBlock(state: NodeMaterialBuildState): this;
  68928. }
  68929. }
  68930. declare module BABYLON {
  68931. /**
  68932. * Block used to get the value of the first parameter raised to the power of the second
  68933. */
  68934. export class PowBlock extends NodeMaterialBlock {
  68935. /**
  68936. * Creates a new PowBlock
  68937. * @param name defines the block name
  68938. */
  68939. constructor(name: string);
  68940. /**
  68941. * Gets the current class name
  68942. * @returns the class name
  68943. */
  68944. getClassName(): string;
  68945. /**
  68946. * Gets the value operand input component
  68947. */
  68948. get value(): NodeMaterialConnectionPoint;
  68949. /**
  68950. * Gets the power operand input component
  68951. */
  68952. get power(): NodeMaterialConnectionPoint;
  68953. /**
  68954. * Gets the output component
  68955. */
  68956. get output(): NodeMaterialConnectionPoint;
  68957. protected _buildBlock(state: NodeMaterialBuildState): this;
  68958. }
  68959. }
  68960. declare module BABYLON {
  68961. /**
  68962. * Block used to get a random number
  68963. */
  68964. export class RandomNumberBlock extends NodeMaterialBlock {
  68965. /**
  68966. * Creates a new RandomNumberBlock
  68967. * @param name defines the block name
  68968. */
  68969. constructor(name: string);
  68970. /**
  68971. * Gets the current class name
  68972. * @returns the class name
  68973. */
  68974. getClassName(): string;
  68975. /**
  68976. * Gets the seed input component
  68977. */
  68978. get seed(): NodeMaterialConnectionPoint;
  68979. /**
  68980. * Gets the output component
  68981. */
  68982. get output(): NodeMaterialConnectionPoint;
  68983. protected _buildBlock(state: NodeMaterialBuildState): this;
  68984. }
  68985. }
  68986. declare module BABYLON {
  68987. /**
  68988. * Block used to compute arc tangent of 2 values
  68989. */
  68990. export class ArcTan2Block extends NodeMaterialBlock {
  68991. /**
  68992. * Creates a new ArcTan2Block
  68993. * @param name defines the block name
  68994. */
  68995. constructor(name: string);
  68996. /**
  68997. * Gets the current class name
  68998. * @returns the class name
  68999. */
  69000. getClassName(): string;
  69001. /**
  69002. * Gets the x operand input component
  69003. */
  69004. get x(): NodeMaterialConnectionPoint;
  69005. /**
  69006. * Gets the y operand input component
  69007. */
  69008. get y(): NodeMaterialConnectionPoint;
  69009. /**
  69010. * Gets the output component
  69011. */
  69012. get output(): NodeMaterialConnectionPoint;
  69013. protected _buildBlock(state: NodeMaterialBuildState): this;
  69014. }
  69015. }
  69016. declare module BABYLON {
  69017. /**
  69018. * Block used to smooth step a value
  69019. */
  69020. export class SmoothStepBlock extends NodeMaterialBlock {
  69021. /**
  69022. * Creates a new SmoothStepBlock
  69023. * @param name defines the block name
  69024. */
  69025. constructor(name: string);
  69026. /**
  69027. * Gets the current class name
  69028. * @returns the class name
  69029. */
  69030. getClassName(): string;
  69031. /**
  69032. * Gets the value operand input component
  69033. */
  69034. get value(): NodeMaterialConnectionPoint;
  69035. /**
  69036. * Gets the first edge operand input component
  69037. */
  69038. get edge0(): NodeMaterialConnectionPoint;
  69039. /**
  69040. * Gets the second edge operand input component
  69041. */
  69042. get edge1(): NodeMaterialConnectionPoint;
  69043. /**
  69044. * Gets the output component
  69045. */
  69046. get output(): NodeMaterialConnectionPoint;
  69047. protected _buildBlock(state: NodeMaterialBuildState): this;
  69048. }
  69049. }
  69050. declare module BABYLON {
  69051. /**
  69052. * Block used to get the reciprocal (1 / x) of a value
  69053. */
  69054. export class ReciprocalBlock extends NodeMaterialBlock {
  69055. /**
  69056. * Creates a new ReciprocalBlock
  69057. * @param name defines the block name
  69058. */
  69059. constructor(name: string);
  69060. /**
  69061. * Gets the current class name
  69062. * @returns the class name
  69063. */
  69064. getClassName(): string;
  69065. /**
  69066. * Gets the input component
  69067. */
  69068. get input(): NodeMaterialConnectionPoint;
  69069. /**
  69070. * Gets the output component
  69071. */
  69072. get output(): NodeMaterialConnectionPoint;
  69073. protected _buildBlock(state: NodeMaterialBuildState): this;
  69074. }
  69075. }
  69076. declare module BABYLON {
  69077. /**
  69078. * Block used to replace a color by another one
  69079. */
  69080. export class ReplaceColorBlock extends NodeMaterialBlock {
  69081. /**
  69082. * Creates a new ReplaceColorBlock
  69083. * @param name defines the block name
  69084. */
  69085. constructor(name: string);
  69086. /**
  69087. * Gets the current class name
  69088. * @returns the class name
  69089. */
  69090. getClassName(): string;
  69091. /**
  69092. * Gets the value input component
  69093. */
  69094. get value(): NodeMaterialConnectionPoint;
  69095. /**
  69096. * Gets the reference input component
  69097. */
  69098. get reference(): NodeMaterialConnectionPoint;
  69099. /**
  69100. * Gets the distance input component
  69101. */
  69102. get distance(): NodeMaterialConnectionPoint;
  69103. /**
  69104. * Gets the replacement input component
  69105. */
  69106. get replacement(): NodeMaterialConnectionPoint;
  69107. /**
  69108. * Gets the output component
  69109. */
  69110. get output(): NodeMaterialConnectionPoint;
  69111. protected _buildBlock(state: NodeMaterialBuildState): this;
  69112. }
  69113. }
  69114. declare module BABYLON {
  69115. /**
  69116. * Block used to posterize a value
  69117. * @see https://en.wikipedia.org/wiki/Posterization
  69118. */
  69119. export class PosterizeBlock extends NodeMaterialBlock {
  69120. /**
  69121. * Creates a new PosterizeBlock
  69122. * @param name defines the block name
  69123. */
  69124. constructor(name: string);
  69125. /**
  69126. * Gets the current class name
  69127. * @returns the class name
  69128. */
  69129. getClassName(): string;
  69130. /**
  69131. * Gets the value input component
  69132. */
  69133. get value(): NodeMaterialConnectionPoint;
  69134. /**
  69135. * Gets the steps input component
  69136. */
  69137. get steps(): NodeMaterialConnectionPoint;
  69138. /**
  69139. * Gets the output component
  69140. */
  69141. get output(): NodeMaterialConnectionPoint;
  69142. protected _buildBlock(state: NodeMaterialBuildState): this;
  69143. }
  69144. }
  69145. declare module BABYLON {
  69146. /**
  69147. * Operations supported by the Wave block
  69148. */
  69149. export enum WaveBlockKind {
  69150. /** SawTooth */
  69151. SawTooth = 0,
  69152. /** Square */
  69153. Square = 1,
  69154. /** Triangle */
  69155. Triangle = 2
  69156. }
  69157. /**
  69158. * Block used to apply wave operation to floats
  69159. */
  69160. export class WaveBlock extends NodeMaterialBlock {
  69161. /**
  69162. * Gets or sets the kibnd of wave to be applied by the block
  69163. */
  69164. kind: WaveBlockKind;
  69165. /**
  69166. * Creates a new WaveBlock
  69167. * @param name defines the block name
  69168. */
  69169. constructor(name: string);
  69170. /**
  69171. * Gets the current class name
  69172. * @returns the class name
  69173. */
  69174. getClassName(): string;
  69175. /**
  69176. * Gets the input component
  69177. */
  69178. get input(): NodeMaterialConnectionPoint;
  69179. /**
  69180. * Gets the output component
  69181. */
  69182. get output(): NodeMaterialConnectionPoint;
  69183. protected _buildBlock(state: NodeMaterialBuildState): this;
  69184. serialize(): any;
  69185. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69186. }
  69187. }
  69188. declare module BABYLON {
  69189. /**
  69190. * Class used to store a color step for the GradientBlock
  69191. */
  69192. export class GradientBlockColorStep {
  69193. private _step;
  69194. /**
  69195. * Gets value indicating which step this color is associated with (between 0 and 1)
  69196. */
  69197. get step(): number;
  69198. /**
  69199. * Sets a value indicating which step this color is associated with (between 0 and 1)
  69200. */
  69201. set step(val: number);
  69202. private _color;
  69203. /**
  69204. * Gets the color associated with this step
  69205. */
  69206. get color(): Color3;
  69207. /**
  69208. * Sets the color associated with this step
  69209. */
  69210. set color(val: Color3);
  69211. /**
  69212. * Creates a new GradientBlockColorStep
  69213. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  69214. * @param color defines the color associated with this step
  69215. */
  69216. constructor(step: number, color: Color3);
  69217. }
  69218. /**
  69219. * Block used to return a color from a gradient based on an input value between 0 and 1
  69220. */
  69221. export class GradientBlock extends NodeMaterialBlock {
  69222. /**
  69223. * Gets or sets the list of color steps
  69224. */
  69225. colorSteps: GradientBlockColorStep[];
  69226. /** Gets an observable raised when the value is changed */
  69227. onValueChangedObservable: Observable<GradientBlock>;
  69228. /** calls observable when the value is changed*/
  69229. colorStepsUpdated(): void;
  69230. /**
  69231. * Creates a new GradientBlock
  69232. * @param name defines the block name
  69233. */
  69234. constructor(name: string);
  69235. /**
  69236. * Gets the current class name
  69237. * @returns the class name
  69238. */
  69239. getClassName(): string;
  69240. /**
  69241. * Gets the gradient input component
  69242. */
  69243. get gradient(): NodeMaterialConnectionPoint;
  69244. /**
  69245. * Gets the output component
  69246. */
  69247. get output(): NodeMaterialConnectionPoint;
  69248. private _writeColorConstant;
  69249. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  69250. serialize(): any;
  69251. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69252. protected _dumpPropertiesCode(): string;
  69253. }
  69254. }
  69255. declare module BABYLON {
  69256. /**
  69257. * Block used to normalize lerp between 2 values
  69258. */
  69259. export class NLerpBlock extends NodeMaterialBlock {
  69260. /**
  69261. * Creates a new NLerpBlock
  69262. * @param name defines the block name
  69263. */
  69264. constructor(name: string);
  69265. /**
  69266. * Gets the current class name
  69267. * @returns the class name
  69268. */
  69269. getClassName(): string;
  69270. /**
  69271. * Gets the left operand input component
  69272. */
  69273. get left(): NodeMaterialConnectionPoint;
  69274. /**
  69275. * Gets the right operand input component
  69276. */
  69277. get right(): NodeMaterialConnectionPoint;
  69278. /**
  69279. * Gets the gradient operand input component
  69280. */
  69281. get gradient(): NodeMaterialConnectionPoint;
  69282. /**
  69283. * Gets the output component
  69284. */
  69285. get output(): NodeMaterialConnectionPoint;
  69286. protected _buildBlock(state: NodeMaterialBuildState): this;
  69287. }
  69288. }
  69289. declare module BABYLON {
  69290. /**
  69291. * block used to Generate a Worley Noise 3D Noise Pattern
  69292. */
  69293. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  69294. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  69295. manhattanDistance: boolean;
  69296. /**
  69297. * Creates a new WorleyNoise3DBlock
  69298. * @param name defines the block name
  69299. */
  69300. constructor(name: string);
  69301. /**
  69302. * Gets the current class name
  69303. * @returns the class name
  69304. */
  69305. getClassName(): string;
  69306. /**
  69307. * Gets the seed input component
  69308. */
  69309. get seed(): NodeMaterialConnectionPoint;
  69310. /**
  69311. * Gets the jitter input component
  69312. */
  69313. get jitter(): NodeMaterialConnectionPoint;
  69314. /**
  69315. * Gets the output component
  69316. */
  69317. get output(): NodeMaterialConnectionPoint;
  69318. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  69319. /**
  69320. * Exposes the properties to the UI?
  69321. */
  69322. protected _dumpPropertiesCode(): string;
  69323. /**
  69324. * Exposes the properties to the Serialize?
  69325. */
  69326. serialize(): any;
  69327. /**
  69328. * Exposes the properties to the deserialize?
  69329. */
  69330. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69331. }
  69332. }
  69333. declare module BABYLON {
  69334. /**
  69335. * block used to Generate a Simplex Perlin 3d Noise Pattern
  69336. */
  69337. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  69338. /**
  69339. * Creates a new SimplexPerlin3DBlock
  69340. * @param name defines the block name
  69341. */
  69342. constructor(name: string);
  69343. /**
  69344. * Gets the current class name
  69345. * @returns the class name
  69346. */
  69347. getClassName(): string;
  69348. /**
  69349. * Gets the seed operand input component
  69350. */
  69351. get seed(): NodeMaterialConnectionPoint;
  69352. /**
  69353. * Gets the output component
  69354. */
  69355. get output(): NodeMaterialConnectionPoint;
  69356. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  69357. }
  69358. }
  69359. declare module BABYLON {
  69360. /**
  69361. * Block used to blend normals
  69362. */
  69363. export class NormalBlendBlock extends NodeMaterialBlock {
  69364. /**
  69365. * Creates a new NormalBlendBlock
  69366. * @param name defines the block name
  69367. */
  69368. constructor(name: string);
  69369. /**
  69370. * Gets the current class name
  69371. * @returns the class name
  69372. */
  69373. getClassName(): string;
  69374. /**
  69375. * Gets the first input component
  69376. */
  69377. get normalMap0(): NodeMaterialConnectionPoint;
  69378. /**
  69379. * Gets the second input component
  69380. */
  69381. get normalMap1(): NodeMaterialConnectionPoint;
  69382. /**
  69383. * Gets the output component
  69384. */
  69385. get output(): NodeMaterialConnectionPoint;
  69386. protected _buildBlock(state: NodeMaterialBuildState): this;
  69387. }
  69388. }
  69389. declare module BABYLON {
  69390. /**
  69391. * Block used to rotate a 2d vector by a given angle
  69392. */
  69393. export class Rotate2dBlock extends NodeMaterialBlock {
  69394. /**
  69395. * Creates a new Rotate2dBlock
  69396. * @param name defines the block name
  69397. */
  69398. constructor(name: string);
  69399. /**
  69400. * Gets the current class name
  69401. * @returns the class name
  69402. */
  69403. getClassName(): string;
  69404. /**
  69405. * Gets the input vector
  69406. */
  69407. get input(): NodeMaterialConnectionPoint;
  69408. /**
  69409. * Gets the input angle
  69410. */
  69411. get angle(): NodeMaterialConnectionPoint;
  69412. /**
  69413. * Gets the output component
  69414. */
  69415. get output(): NodeMaterialConnectionPoint;
  69416. autoConfigure(material: NodeMaterial): void;
  69417. protected _buildBlock(state: NodeMaterialBuildState): this;
  69418. }
  69419. }
  69420. declare module BABYLON {
  69421. /**
  69422. * Block used to get the reflected vector from a direction and a normal
  69423. */
  69424. export class ReflectBlock extends NodeMaterialBlock {
  69425. /**
  69426. * Creates a new ReflectBlock
  69427. * @param name defines the block name
  69428. */
  69429. constructor(name: string);
  69430. /**
  69431. * Gets the current class name
  69432. * @returns the class name
  69433. */
  69434. getClassName(): string;
  69435. /**
  69436. * Gets the incident component
  69437. */
  69438. get incident(): NodeMaterialConnectionPoint;
  69439. /**
  69440. * Gets the normal component
  69441. */
  69442. get normal(): NodeMaterialConnectionPoint;
  69443. /**
  69444. * Gets the output component
  69445. */
  69446. get output(): NodeMaterialConnectionPoint;
  69447. protected _buildBlock(state: NodeMaterialBuildState): this;
  69448. }
  69449. }
  69450. declare module BABYLON {
  69451. /**
  69452. * Block used to get the refracted vector from a direction and a normal
  69453. */
  69454. export class RefractBlock extends NodeMaterialBlock {
  69455. /**
  69456. * Creates a new RefractBlock
  69457. * @param name defines the block name
  69458. */
  69459. constructor(name: string);
  69460. /**
  69461. * Gets the current class name
  69462. * @returns the class name
  69463. */
  69464. getClassName(): string;
  69465. /**
  69466. * Gets the incident component
  69467. */
  69468. get incident(): NodeMaterialConnectionPoint;
  69469. /**
  69470. * Gets the normal component
  69471. */
  69472. get normal(): NodeMaterialConnectionPoint;
  69473. /**
  69474. * Gets the index of refraction component
  69475. */
  69476. get ior(): NodeMaterialConnectionPoint;
  69477. /**
  69478. * Gets the output component
  69479. */
  69480. get output(): NodeMaterialConnectionPoint;
  69481. protected _buildBlock(state: NodeMaterialBuildState): this;
  69482. }
  69483. }
  69484. declare module BABYLON {
  69485. /**
  69486. * Block used to desaturate a color
  69487. */
  69488. export class DesaturateBlock extends NodeMaterialBlock {
  69489. /**
  69490. * Creates a new DesaturateBlock
  69491. * @param name defines the block name
  69492. */
  69493. constructor(name: string);
  69494. /**
  69495. * Gets the current class name
  69496. * @returns the class name
  69497. */
  69498. getClassName(): string;
  69499. /**
  69500. * Gets the color operand input component
  69501. */
  69502. get color(): NodeMaterialConnectionPoint;
  69503. /**
  69504. * Gets the level operand input component
  69505. */
  69506. get level(): NodeMaterialConnectionPoint;
  69507. /**
  69508. * Gets the output component
  69509. */
  69510. get output(): NodeMaterialConnectionPoint;
  69511. protected _buildBlock(state: NodeMaterialBuildState): this;
  69512. }
  69513. }
  69514. declare module BABYLON {
  69515. /**
  69516. * Block used to implement the reflection module of the PBR material
  69517. */
  69518. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  69519. /** @hidden */
  69520. _defineLODReflectionAlpha: string;
  69521. /** @hidden */
  69522. _defineLinearSpecularReflection: string;
  69523. private _vEnvironmentIrradianceName;
  69524. /** @hidden */
  69525. _vReflectionMicrosurfaceInfosName: string;
  69526. /** @hidden */
  69527. _vReflectionInfosName: string;
  69528. /** @hidden */
  69529. _vReflectionFilteringInfoName: string;
  69530. private _scene;
  69531. /**
  69532. * The properties below are set by the main PBR block prior to calling methods of this class.
  69533. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  69534. * It's less burden on the user side in the editor part.
  69535. */
  69536. /** @hidden */
  69537. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  69538. /** @hidden */
  69539. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  69540. /** @hidden */
  69541. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  69542. /** @hidden */
  69543. viewConnectionPoint: NodeMaterialConnectionPoint;
  69544. /**
  69545. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  69546. * diffuse part of the IBL.
  69547. */
  69548. useSphericalHarmonics: boolean;
  69549. /**
  69550. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  69551. */
  69552. forceIrradianceInFragment: boolean;
  69553. /**
  69554. * Create a new ReflectionBlock
  69555. * @param name defines the block name
  69556. */
  69557. constructor(name: string);
  69558. /**
  69559. * Gets the current class name
  69560. * @returns the class name
  69561. */
  69562. getClassName(): string;
  69563. /**
  69564. * Gets the position input component
  69565. */
  69566. get position(): NodeMaterialConnectionPoint;
  69567. /**
  69568. * Gets the world position input component
  69569. */
  69570. get worldPosition(): NodeMaterialConnectionPoint;
  69571. /**
  69572. * Gets the world normal input component
  69573. */
  69574. get worldNormal(): NodeMaterialConnectionPoint;
  69575. /**
  69576. * Gets the world input component
  69577. */
  69578. get world(): NodeMaterialConnectionPoint;
  69579. /**
  69580. * Gets the camera (or eye) position component
  69581. */
  69582. get cameraPosition(): NodeMaterialConnectionPoint;
  69583. /**
  69584. * Gets the view input component
  69585. */
  69586. get view(): NodeMaterialConnectionPoint;
  69587. /**
  69588. * Gets the color input component
  69589. */
  69590. get color(): NodeMaterialConnectionPoint;
  69591. /**
  69592. * Gets the reflection object output component
  69593. */
  69594. get reflection(): NodeMaterialConnectionPoint;
  69595. /**
  69596. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  69597. */
  69598. get hasTexture(): boolean;
  69599. /**
  69600. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  69601. */
  69602. get reflectionColor(): string;
  69603. protected _getTexture(): Nullable<BaseTexture>;
  69604. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69605. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  69606. /**
  69607. * Gets the code to inject in the vertex shader
  69608. * @param state current state of the node material building
  69609. * @returns the shader code
  69610. */
  69611. handleVertexSide(state: NodeMaterialBuildState): string;
  69612. /**
  69613. * Gets the main code of the block (fragment side)
  69614. * @param state current state of the node material building
  69615. * @param normalVarName name of the existing variable corresponding to the normal
  69616. * @returns the shader code
  69617. */
  69618. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  69619. protected _buildBlock(state: NodeMaterialBuildState): this;
  69620. protected _dumpPropertiesCode(): string;
  69621. serialize(): any;
  69622. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69623. }
  69624. }
  69625. declare module BABYLON {
  69626. /**
  69627. * Block used to implement the sheen module of the PBR material
  69628. */
  69629. export class SheenBlock extends NodeMaterialBlock {
  69630. /**
  69631. * Create a new SheenBlock
  69632. * @param name defines the block name
  69633. */
  69634. constructor(name: string);
  69635. /**
  69636. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  69637. * It allows the strength of the sheen effect to not depend on the base color of the material,
  69638. * making it easier to setup and tweak the effect
  69639. */
  69640. albedoScaling: boolean;
  69641. /**
  69642. * Defines if the sheen is linked to the sheen color.
  69643. */
  69644. linkSheenWithAlbedo: boolean;
  69645. /**
  69646. * Initialize the block and prepare the context for build
  69647. * @param state defines the state that will be used for the build
  69648. */
  69649. initialize(state: NodeMaterialBuildState): void;
  69650. /**
  69651. * Gets the current class name
  69652. * @returns the class name
  69653. */
  69654. getClassName(): string;
  69655. /**
  69656. * Gets the intensity input component
  69657. */
  69658. get intensity(): NodeMaterialConnectionPoint;
  69659. /**
  69660. * Gets the color input component
  69661. */
  69662. get color(): NodeMaterialConnectionPoint;
  69663. /**
  69664. * Gets the roughness input component
  69665. */
  69666. get roughness(): NodeMaterialConnectionPoint;
  69667. /**
  69668. * Gets the sheen object output component
  69669. */
  69670. get sheen(): NodeMaterialConnectionPoint;
  69671. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69672. /**
  69673. * Gets the main code of the block (fragment side)
  69674. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  69675. * @returns the shader code
  69676. */
  69677. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  69678. protected _buildBlock(state: NodeMaterialBuildState): this;
  69679. protected _dumpPropertiesCode(): string;
  69680. serialize(): any;
  69681. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69682. }
  69683. }
  69684. declare module BABYLON {
  69685. /**
  69686. * Block used to implement the anisotropy module of the PBR material
  69687. */
  69688. export class AnisotropyBlock extends NodeMaterialBlock {
  69689. /**
  69690. * The two properties below are set by the main PBR block prior to calling methods of this class.
  69691. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  69692. * It's less burden on the user side in the editor part.
  69693. */
  69694. /** @hidden */
  69695. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  69696. /** @hidden */
  69697. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  69698. /**
  69699. * Create a new AnisotropyBlock
  69700. * @param name defines the block name
  69701. */
  69702. constructor(name: string);
  69703. /**
  69704. * Initialize the block and prepare the context for build
  69705. * @param state defines the state that will be used for the build
  69706. */
  69707. initialize(state: NodeMaterialBuildState): void;
  69708. /**
  69709. * Gets the current class name
  69710. * @returns the class name
  69711. */
  69712. getClassName(): string;
  69713. /**
  69714. * Gets the intensity input component
  69715. */
  69716. get intensity(): NodeMaterialConnectionPoint;
  69717. /**
  69718. * Gets the direction input component
  69719. */
  69720. get direction(): NodeMaterialConnectionPoint;
  69721. /**
  69722. * Gets the uv input component
  69723. */
  69724. get uv(): NodeMaterialConnectionPoint;
  69725. /**
  69726. * Gets the worldTangent input component
  69727. */
  69728. get worldTangent(): NodeMaterialConnectionPoint;
  69729. /**
  69730. * Gets the anisotropy object output component
  69731. */
  69732. get anisotropy(): NodeMaterialConnectionPoint;
  69733. private _generateTBNSpace;
  69734. /**
  69735. * Gets the main code of the block (fragment side)
  69736. * @param state current state of the node material building
  69737. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  69738. * @returns the shader code
  69739. */
  69740. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  69741. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69742. protected _buildBlock(state: NodeMaterialBuildState): this;
  69743. }
  69744. }
  69745. declare module BABYLON {
  69746. /**
  69747. * Block used to implement the clear coat module of the PBR material
  69748. */
  69749. export class ClearCoatBlock extends NodeMaterialBlock {
  69750. private _scene;
  69751. /**
  69752. * Create a new ClearCoatBlock
  69753. * @param name defines the block name
  69754. */
  69755. constructor(name: string);
  69756. /**
  69757. * Defines if the F0 value should be remapped to account for the interface change in the material.
  69758. */
  69759. remapF0OnInterfaceChange: boolean;
  69760. /**
  69761. * Initialize the block and prepare the context for build
  69762. * @param state defines the state that will be used for the build
  69763. */
  69764. initialize(state: NodeMaterialBuildState): void;
  69765. /**
  69766. * Gets the current class name
  69767. * @returns the class name
  69768. */
  69769. getClassName(): string;
  69770. /**
  69771. * Gets the intensity input component
  69772. */
  69773. get intensity(): NodeMaterialConnectionPoint;
  69774. /**
  69775. * Gets the roughness input component
  69776. */
  69777. get roughness(): NodeMaterialConnectionPoint;
  69778. /**
  69779. * Gets the ior input component
  69780. */
  69781. get indexOfRefraction(): NodeMaterialConnectionPoint;
  69782. /**
  69783. * Gets the bump texture input component
  69784. */
  69785. get normalMapColor(): NodeMaterialConnectionPoint;
  69786. /**
  69787. * Gets the uv input component
  69788. */
  69789. get uv(): NodeMaterialConnectionPoint;
  69790. /**
  69791. * Gets the tint color input component
  69792. */
  69793. get tintColor(): NodeMaterialConnectionPoint;
  69794. /**
  69795. * Gets the tint "at distance" input component
  69796. */
  69797. get tintAtDistance(): NodeMaterialConnectionPoint;
  69798. /**
  69799. * Gets the tint thickness input component
  69800. */
  69801. get tintThickness(): NodeMaterialConnectionPoint;
  69802. /**
  69803. * Gets the world tangent input component
  69804. */
  69805. get worldTangent(): NodeMaterialConnectionPoint;
  69806. /**
  69807. * Gets the clear coat object output component
  69808. */
  69809. get clearcoat(): NodeMaterialConnectionPoint;
  69810. autoConfigure(material: NodeMaterial): void;
  69811. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69812. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  69813. private _generateTBNSpace;
  69814. /**
  69815. * Gets the main code of the block (fragment side)
  69816. * @param state current state of the node material building
  69817. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  69818. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  69819. * @param worldPosVarName name of the variable holding the world position
  69820. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  69821. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  69822. * @param worldNormalVarName name of the variable holding the world normal
  69823. * @returns the shader code
  69824. */
  69825. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  69826. protected _buildBlock(state: NodeMaterialBuildState): this;
  69827. protected _dumpPropertiesCode(): string;
  69828. serialize(): any;
  69829. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69830. }
  69831. }
  69832. declare module BABYLON {
  69833. /**
  69834. * Block used to implement the sub surface module of the PBR material
  69835. */
  69836. export class SubSurfaceBlock extends NodeMaterialBlock {
  69837. /**
  69838. * Create a new SubSurfaceBlock
  69839. * @param name defines the block name
  69840. */
  69841. constructor(name: string);
  69842. /**
  69843. * Initialize the block and prepare the context for build
  69844. * @param state defines the state that will be used for the build
  69845. */
  69846. initialize(state: NodeMaterialBuildState): void;
  69847. /**
  69848. * Gets the current class name
  69849. * @returns the class name
  69850. */
  69851. getClassName(): string;
  69852. /**
  69853. * Gets the thickness component
  69854. */
  69855. get thickness(): NodeMaterialConnectionPoint;
  69856. /**
  69857. * Gets the tint color input component
  69858. */
  69859. get tintColor(): NodeMaterialConnectionPoint;
  69860. /**
  69861. * Gets the translucency intensity input component
  69862. */
  69863. get translucencyIntensity(): NodeMaterialConnectionPoint;
  69864. /**
  69865. * Gets the translucency diffusion distance input component
  69866. */
  69867. get translucencyDiffusionDist(): NodeMaterialConnectionPoint;
  69868. /**
  69869. * Gets the refraction object parameters
  69870. */
  69871. get refraction(): NodeMaterialConnectionPoint;
  69872. /**
  69873. * Gets the sub surface object output component
  69874. */
  69875. get subsurface(): NodeMaterialConnectionPoint;
  69876. autoConfigure(material: NodeMaterial): void;
  69877. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69878. /**
  69879. * Gets the main code of the block (fragment side)
  69880. * @param state current state of the node material building
  69881. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  69882. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  69883. * @param worldPosVarName name of the variable holding the world position
  69884. * @returns the shader code
  69885. */
  69886. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  69887. protected _buildBlock(state: NodeMaterialBuildState): this;
  69888. }
  69889. }
  69890. declare module BABYLON {
  69891. /**
  69892. * Block used to implement the PBR metallic/roughness model
  69893. */
  69894. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  69895. /**
  69896. * Gets or sets the light associated with this block
  69897. */
  69898. light: Nullable<Light>;
  69899. private _lightId;
  69900. private _scene;
  69901. private _environmentBRDFTexture;
  69902. private _environmentBrdfSamplerName;
  69903. private _vNormalWName;
  69904. private _invertNormalName;
  69905. private _metallicReflectanceColor;
  69906. private _metallicF0Factor;
  69907. private _vMetallicReflectanceFactorsName;
  69908. /**
  69909. * Create a new ReflectionBlock
  69910. * @param name defines the block name
  69911. */
  69912. constructor(name: string);
  69913. /**
  69914. * Intensity of the direct lights e.g. the four lights available in your scene.
  69915. * This impacts both the direct diffuse and specular highlights.
  69916. */
  69917. directIntensity: number;
  69918. /**
  69919. * Intensity of the environment e.g. how much the environment will light the object
  69920. * either through harmonics for rough material or through the reflection for shiny ones.
  69921. */
  69922. environmentIntensity: number;
  69923. /**
  69924. * This is a special control allowing the reduction of the specular highlights coming from the
  69925. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  69926. */
  69927. specularIntensity: number;
  69928. /**
  69929. * Defines the falloff type used in this material.
  69930. * It by default is Physical.
  69931. */
  69932. lightFalloff: number;
  69933. /**
  69934. * Specifies that alpha test should be used
  69935. */
  69936. useAlphaTest: boolean;
  69937. /**
  69938. * Defines the alpha limits in alpha test mode.
  69939. */
  69940. alphaTestCutoff: number;
  69941. /**
  69942. * Specifies that alpha blending should be used
  69943. */
  69944. useAlphaBlending: boolean;
  69945. /**
  69946. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  69947. * A car glass is a good example of that. When the street lights reflects on it you can not see what is behind.
  69948. */
  69949. useRadianceOverAlpha: boolean;
  69950. /**
  69951. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  69952. * A car glass is a good example of that. When sun reflects on it you can not see what is behind.
  69953. */
  69954. useSpecularOverAlpha: boolean;
  69955. /**
  69956. * Enables specular anti aliasing in the PBR shader.
  69957. * It will both interacts on the Geometry for analytical and IBL lighting.
  69958. * It also prefilter the roughness map based on the bump values.
  69959. */
  69960. enableSpecularAntiAliasing: boolean;
  69961. /**
  69962. * Enables realtime filtering on the texture.
  69963. */
  69964. realTimeFiltering: boolean;
  69965. /**
  69966. * Quality switch for realtime filtering
  69967. */
  69968. realTimeFilteringQuality: number;
  69969. /**
  69970. * Defines if the material uses energy conservation.
  69971. */
  69972. useEnergyConservation: boolean;
  69973. /**
  69974. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  69975. * too much the area relying on ambient texture to define their ambient occlusion.
  69976. */
  69977. useRadianceOcclusion: boolean;
  69978. /**
  69979. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  69980. * makes the reflect vector face the model (under horizon).
  69981. */
  69982. useHorizonOcclusion: boolean;
  69983. /**
  69984. * If set to true, no lighting calculations will be applied.
  69985. */
  69986. unlit: boolean;
  69987. /**
  69988. * Force normal to face away from face.
  69989. */
  69990. forceNormalForward: boolean;
  69991. /**
  69992. * Defines the material debug mode.
  69993. * It helps seeing only some components of the material while troubleshooting.
  69994. */
  69995. debugMode: number;
  69996. /**
  69997. * Specify from where on screen the debug mode should start.
  69998. * The value goes from -1 (full screen) to 1 (not visible)
  69999. * It helps with side by side comparison against the final render
  70000. * This defaults to 0
  70001. */
  70002. debugLimit: number;
  70003. /**
  70004. * As the default viewing range might not be enough (if the ambient is really small for instance)
  70005. * You can use the factor to better multiply the final value.
  70006. */
  70007. debugFactor: number;
  70008. /**
  70009. * Initialize the block and prepare the context for build
  70010. * @param state defines the state that will be used for the build
  70011. */
  70012. initialize(state: NodeMaterialBuildState): void;
  70013. /**
  70014. * Gets the current class name
  70015. * @returns the class name
  70016. */
  70017. getClassName(): string;
  70018. /**
  70019. * Gets the world position input component
  70020. */
  70021. get worldPosition(): NodeMaterialConnectionPoint;
  70022. /**
  70023. * Gets the world normal input component
  70024. */
  70025. get worldNormal(): NodeMaterialConnectionPoint;
  70026. /**
  70027. * Gets the view matrix parameter
  70028. */
  70029. get view(): NodeMaterialConnectionPoint;
  70030. /**
  70031. * Gets the camera position input component
  70032. */
  70033. get cameraPosition(): NodeMaterialConnectionPoint;
  70034. /**
  70035. * Gets the perturbed normal input component
  70036. */
  70037. get perturbedNormal(): NodeMaterialConnectionPoint;
  70038. /**
  70039. * Gets the base color input component
  70040. */
  70041. get baseColor(): NodeMaterialConnectionPoint;
  70042. /**
  70043. * Gets the metallic input component
  70044. */
  70045. get metallic(): NodeMaterialConnectionPoint;
  70046. /**
  70047. * Gets the roughness input component
  70048. */
  70049. get roughness(): NodeMaterialConnectionPoint;
  70050. /**
  70051. * Gets the ambient occlusion input component
  70052. */
  70053. get ambientOcc(): NodeMaterialConnectionPoint;
  70054. /**
  70055. * Gets the opacity input component
  70056. */
  70057. get opacity(): NodeMaterialConnectionPoint;
  70058. /**
  70059. * Gets the index of refraction input component
  70060. */
  70061. get indexOfRefraction(): NodeMaterialConnectionPoint;
  70062. /**
  70063. * Gets the ambient color input component
  70064. */
  70065. get ambientColor(): NodeMaterialConnectionPoint;
  70066. /**
  70067. * Gets the reflection object parameters
  70068. */
  70069. get reflection(): NodeMaterialConnectionPoint;
  70070. /**
  70071. * Gets the clear coat object parameters
  70072. */
  70073. get clearcoat(): NodeMaterialConnectionPoint;
  70074. /**
  70075. * Gets the sheen object parameters
  70076. */
  70077. get sheen(): NodeMaterialConnectionPoint;
  70078. /**
  70079. * Gets the sub surface object parameters
  70080. */
  70081. get subsurface(): NodeMaterialConnectionPoint;
  70082. /**
  70083. * Gets the anisotropy object parameters
  70084. */
  70085. get anisotropy(): NodeMaterialConnectionPoint;
  70086. /**
  70087. * Gets the ambient output component
  70088. */
  70089. get ambientClr(): NodeMaterialConnectionPoint;
  70090. /**
  70091. * Gets the diffuse output component
  70092. */
  70093. get diffuseDir(): NodeMaterialConnectionPoint;
  70094. /**
  70095. * Gets the specular output component
  70096. */
  70097. get specularDir(): NodeMaterialConnectionPoint;
  70098. /**
  70099. * Gets the clear coat output component
  70100. */
  70101. get clearcoatDir(): NodeMaterialConnectionPoint;
  70102. /**
  70103. * Gets the sheen output component
  70104. */
  70105. get sheenDir(): NodeMaterialConnectionPoint;
  70106. /**
  70107. * Gets the indirect diffuse output component
  70108. */
  70109. get diffuseIndirect(): NodeMaterialConnectionPoint;
  70110. /**
  70111. * Gets the indirect specular output component
  70112. */
  70113. get specularIndirect(): NodeMaterialConnectionPoint;
  70114. /**
  70115. * Gets the indirect clear coat output component
  70116. */
  70117. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  70118. /**
  70119. * Gets the indirect sheen output component
  70120. */
  70121. get sheenIndirect(): NodeMaterialConnectionPoint;
  70122. /**
  70123. * Gets the refraction output component
  70124. */
  70125. get refraction(): NodeMaterialConnectionPoint;
  70126. /**
  70127. * Gets the global lighting output component
  70128. */
  70129. get lighting(): NodeMaterialConnectionPoint;
  70130. /**
  70131. * Gets the shadow output component
  70132. */
  70133. get shadow(): NodeMaterialConnectionPoint;
  70134. /**
  70135. * Gets the alpha output component
  70136. */
  70137. get alpha(): NodeMaterialConnectionPoint;
  70138. autoConfigure(material: NodeMaterial): void;
  70139. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  70140. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  70141. isReady(): boolean;
  70142. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  70143. private _injectVertexCode;
  70144. private _getAlbedoOpacityCode;
  70145. private _getAmbientOcclusionCode;
  70146. private _getReflectivityCode;
  70147. protected _buildBlock(state: NodeMaterialBuildState): this;
  70148. protected _dumpPropertiesCode(): string;
  70149. serialize(): any;
  70150. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  70151. }
  70152. }
  70153. declare module BABYLON {
  70154. /**
  70155. * Block used to compute value of one parameter modulo another
  70156. */
  70157. export class ModBlock extends NodeMaterialBlock {
  70158. /**
  70159. * Creates a new ModBlock
  70160. * @param name defines the block name
  70161. */
  70162. constructor(name: string);
  70163. /**
  70164. * Gets the current class name
  70165. * @returns the class name
  70166. */
  70167. getClassName(): string;
  70168. /**
  70169. * Gets the left operand input component
  70170. */
  70171. get left(): NodeMaterialConnectionPoint;
  70172. /**
  70173. * Gets the right operand input component
  70174. */
  70175. get right(): NodeMaterialConnectionPoint;
  70176. /**
  70177. * Gets the output component
  70178. */
  70179. get output(): NodeMaterialConnectionPoint;
  70180. protected _buildBlock(state: NodeMaterialBuildState): this;
  70181. }
  70182. }
  70183. declare module BABYLON {
  70184. /**
  70185. * Configuration for Draco compression
  70186. */
  70187. export interface IDracoCompressionConfiguration {
  70188. /**
  70189. * Configuration for the decoder.
  70190. */
  70191. decoder: {
  70192. /**
  70193. * The url to the WebAssembly module.
  70194. */
  70195. wasmUrl?: string;
  70196. /**
  70197. * The url to the WebAssembly binary.
  70198. */
  70199. wasmBinaryUrl?: string;
  70200. /**
  70201. * The url to the fallback JavaScript module.
  70202. */
  70203. fallbackUrl?: string;
  70204. };
  70205. }
  70206. /**
  70207. * Draco compression (https://google.github.io/draco/)
  70208. *
  70209. * This class wraps the Draco module.
  70210. *
  70211. * **Encoder**
  70212. *
  70213. * The encoder is not currently implemented.
  70214. *
  70215. * **Decoder**
  70216. *
  70217. * 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.
  70218. *
  70219. * To update the configuration, use the following code:
  70220. * ```javascript
  70221. * DracoCompression.Configuration = {
  70222. * decoder: {
  70223. * wasmUrl: "<url to the WebAssembly library>",
  70224. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  70225. * fallbackUrl: "<url to the fallback JavaScript library>",
  70226. * }
  70227. * };
  70228. * ```
  70229. *
  70230. * 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.
  70231. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  70232. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  70233. *
  70234. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  70235. * ```javascript
  70236. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  70237. * ```
  70238. *
  70239. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  70240. */
  70241. export class DracoCompression implements IDisposable {
  70242. private _workerPoolPromise?;
  70243. private _decoderModulePromise?;
  70244. /**
  70245. * The configuration. Defaults to the following urls:
  70246. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  70247. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  70248. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  70249. */
  70250. static Configuration: IDracoCompressionConfiguration;
  70251. /**
  70252. * Returns true if the decoder configuration is available.
  70253. */
  70254. static get DecoderAvailable(): boolean;
  70255. /**
  70256. * Default number of workers to create when creating the draco compression object.
  70257. */
  70258. static DefaultNumWorkers: number;
  70259. private static GetDefaultNumWorkers;
  70260. private static _Default;
  70261. /**
  70262. * Default instance for the draco compression object.
  70263. */
  70264. static get Default(): DracoCompression;
  70265. /**
  70266. * Constructor
  70267. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  70268. */
  70269. constructor(numWorkers?: number);
  70270. /**
  70271. * Stop all async operations and release resources.
  70272. */
  70273. dispose(): void;
  70274. /**
  70275. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  70276. * @returns a promise that resolves when ready
  70277. */
  70278. whenReadyAsync(): Promise<void>;
  70279. /**
  70280. * Decode Draco compressed mesh data to vertex data.
  70281. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  70282. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  70283. * @returns A promise that resolves with the decoded vertex data
  70284. */
  70285. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  70286. [kind: string]: number;
  70287. }): Promise<VertexData>;
  70288. }
  70289. }
  70290. declare module BABYLON {
  70291. /**
  70292. * Class for building Constructive Solid Geometry
  70293. */
  70294. export class CSG {
  70295. private polygons;
  70296. /**
  70297. * The world matrix
  70298. */
  70299. matrix: Matrix;
  70300. /**
  70301. * Stores the position
  70302. */
  70303. position: Vector3;
  70304. /**
  70305. * Stores the rotation
  70306. */
  70307. rotation: Vector3;
  70308. /**
  70309. * Stores the rotation quaternion
  70310. */
  70311. rotationQuaternion: Nullable<Quaternion>;
  70312. /**
  70313. * Stores the scaling vector
  70314. */
  70315. scaling: Vector3;
  70316. /**
  70317. * Convert the Mesh to CSG
  70318. * @param mesh The Mesh to convert to CSG
  70319. * @returns A new CSG from the Mesh
  70320. */
  70321. static FromMesh(mesh: Mesh): CSG;
  70322. /**
  70323. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  70324. * @param polygons Polygons used to construct a CSG solid
  70325. */
  70326. private static FromPolygons;
  70327. /**
  70328. * Clones, or makes a deep copy, of the CSG
  70329. * @returns A new CSG
  70330. */
  70331. clone(): CSG;
  70332. /**
  70333. * Unions this CSG with another CSG
  70334. * @param csg The CSG to union against this CSG
  70335. * @returns The unioned CSG
  70336. */
  70337. union(csg: CSG): CSG;
  70338. /**
  70339. * Unions this CSG with another CSG in place
  70340. * @param csg The CSG to union against this CSG
  70341. */
  70342. unionInPlace(csg: CSG): void;
  70343. /**
  70344. * Subtracts this CSG with another CSG
  70345. * @param csg The CSG to subtract against this CSG
  70346. * @returns A new CSG
  70347. */
  70348. subtract(csg: CSG): CSG;
  70349. /**
  70350. * Subtracts this CSG with another CSG in place
  70351. * @param csg The CSG to subtract against this CSG
  70352. */
  70353. subtractInPlace(csg: CSG): void;
  70354. /**
  70355. * Intersect this CSG with another CSG
  70356. * @param csg The CSG to intersect against this CSG
  70357. * @returns A new CSG
  70358. */
  70359. intersect(csg: CSG): CSG;
  70360. /**
  70361. * Intersects this CSG with another CSG in place
  70362. * @param csg The CSG to intersect against this CSG
  70363. */
  70364. intersectInPlace(csg: CSG): void;
  70365. /**
  70366. * Return a new CSG solid with solid and empty space switched. This solid is
  70367. * not modified.
  70368. * @returns A new CSG solid with solid and empty space switched
  70369. */
  70370. inverse(): CSG;
  70371. /**
  70372. * Inverses the CSG in place
  70373. */
  70374. inverseInPlace(): void;
  70375. /**
  70376. * This is used to keep meshes transformations so they can be restored
  70377. * when we build back a Babylon Mesh
  70378. * NB : All CSG operations are performed in world coordinates
  70379. * @param csg The CSG to copy the transform attributes from
  70380. * @returns This CSG
  70381. */
  70382. copyTransformAttributes(csg: CSG): CSG;
  70383. /**
  70384. * Build Raw mesh from CSG
  70385. * Coordinates here are in world space
  70386. * @param name The name of the mesh geometry
  70387. * @param scene The Scene
  70388. * @param keepSubMeshes Specifies if the submeshes should be kept
  70389. * @returns A new Mesh
  70390. */
  70391. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  70392. /**
  70393. * Build Mesh from CSG taking material and transforms into account
  70394. * @param name The name of the Mesh
  70395. * @param material The material of the Mesh
  70396. * @param scene The Scene
  70397. * @param keepSubMeshes Specifies if submeshes should be kept
  70398. * @returns The new Mesh
  70399. */
  70400. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  70401. }
  70402. }
  70403. declare module BABYLON {
  70404. /**
  70405. * Class used to create a trail following a mesh
  70406. */
  70407. export class TrailMesh extends Mesh {
  70408. private _generator;
  70409. private _autoStart;
  70410. private _running;
  70411. private _diameter;
  70412. private _length;
  70413. private _sectionPolygonPointsCount;
  70414. private _sectionVectors;
  70415. private _sectionNormalVectors;
  70416. private _beforeRenderObserver;
  70417. /**
  70418. * @constructor
  70419. * @param name The value used by scene.getMeshByName() to do a lookup.
  70420. * @param generator The mesh or transform node to generate a trail.
  70421. * @param scene The scene to add this mesh to.
  70422. * @param diameter Diameter of trailing mesh. Default is 1.
  70423. * @param length Length of trailing mesh. Default is 60.
  70424. * @param autoStart Automatically start trailing mesh. Default true.
  70425. */
  70426. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  70427. /**
  70428. * "TrailMesh"
  70429. * @returns "TrailMesh"
  70430. */
  70431. getClassName(): string;
  70432. private _createMesh;
  70433. /**
  70434. * Start trailing mesh.
  70435. */
  70436. start(): void;
  70437. /**
  70438. * Stop trailing mesh.
  70439. */
  70440. stop(): void;
  70441. /**
  70442. * Update trailing mesh geometry.
  70443. */
  70444. update(): void;
  70445. /**
  70446. * Returns a new TrailMesh object.
  70447. * @param name is a string, the name given to the new mesh
  70448. * @param newGenerator use new generator object for cloned trail mesh
  70449. * @returns a new mesh
  70450. */
  70451. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  70452. /**
  70453. * Serializes this trail mesh
  70454. * @param serializationObject object to write serialization to
  70455. */
  70456. serialize(serializationObject: any): void;
  70457. /**
  70458. * Parses a serialized trail mesh
  70459. * @param parsedMesh the serialized mesh
  70460. * @param scene the scene to create the trail mesh in
  70461. * @returns the created trail mesh
  70462. */
  70463. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  70464. }
  70465. }
  70466. declare module BABYLON {
  70467. /**
  70468. * Class containing static functions to help procedurally build meshes
  70469. */
  70470. export class TiledBoxBuilder {
  70471. /**
  70472. * Creates a box mesh
  70473. * 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)
  70474. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70475. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70476. * * 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
  70477. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70478. * @param name defines the name of the mesh
  70479. * @param options defines the options used to create the mesh
  70480. * @param scene defines the hosting scene
  70481. * @returns the box mesh
  70482. */
  70483. static CreateTiledBox(name: string, options: {
  70484. pattern?: number;
  70485. width?: number;
  70486. height?: number;
  70487. depth?: number;
  70488. tileSize?: number;
  70489. tileWidth?: number;
  70490. tileHeight?: number;
  70491. alignHorizontal?: number;
  70492. alignVertical?: number;
  70493. faceUV?: Vector4[];
  70494. faceColors?: Color4[];
  70495. sideOrientation?: number;
  70496. updatable?: boolean;
  70497. }, scene?: Nullable<Scene>): Mesh;
  70498. }
  70499. }
  70500. declare module BABYLON {
  70501. /**
  70502. * Class containing static functions to help procedurally build meshes
  70503. */
  70504. export class TorusKnotBuilder {
  70505. /**
  70506. * Creates a torus knot mesh
  70507. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  70508. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  70509. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  70510. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  70511. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70512. * * 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
  70513. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70514. * @param name defines the name of the mesh
  70515. * @param options defines the options used to create the mesh
  70516. * @param scene defines the hosting scene
  70517. * @returns the torus knot mesh
  70518. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  70519. */
  70520. static CreateTorusKnot(name: string, options: {
  70521. radius?: number;
  70522. tube?: number;
  70523. radialSegments?: number;
  70524. tubularSegments?: number;
  70525. p?: number;
  70526. q?: number;
  70527. updatable?: boolean;
  70528. sideOrientation?: number;
  70529. frontUVs?: Vector4;
  70530. backUVs?: Vector4;
  70531. }, scene: any): Mesh;
  70532. }
  70533. }
  70534. declare module BABYLON {
  70535. /**
  70536. * Polygon
  70537. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  70538. */
  70539. export class Polygon {
  70540. /**
  70541. * Creates a rectangle
  70542. * @param xmin bottom X coord
  70543. * @param ymin bottom Y coord
  70544. * @param xmax top X coord
  70545. * @param ymax top Y coord
  70546. * @returns points that make the resulting rectangle
  70547. */
  70548. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  70549. /**
  70550. * Creates a circle
  70551. * @param radius radius of circle
  70552. * @param cx scale in x
  70553. * @param cy scale in y
  70554. * @param numberOfSides number of sides that make up the circle
  70555. * @returns points that make the resulting circle
  70556. */
  70557. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  70558. /**
  70559. * Creates a polygon from input string
  70560. * @param input Input polygon data
  70561. * @returns the parsed points
  70562. */
  70563. static Parse(input: string): Vector2[];
  70564. /**
  70565. * Starts building a polygon from x and y coordinates
  70566. * @param x x coordinate
  70567. * @param y y coordinate
  70568. * @returns the started path2
  70569. */
  70570. static StartingAt(x: number, y: number): Path2;
  70571. }
  70572. /**
  70573. * Builds a polygon
  70574. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  70575. */
  70576. export class PolygonMeshBuilder {
  70577. private _points;
  70578. private _outlinepoints;
  70579. private _holes;
  70580. private _name;
  70581. private _scene;
  70582. private _epoints;
  70583. private _eholes;
  70584. private _addToepoint;
  70585. /**
  70586. * Babylon reference to the earcut plugin.
  70587. */
  70588. bjsEarcut: any;
  70589. /**
  70590. * Creates a PolygonMeshBuilder
  70591. * @param name name of the builder
  70592. * @param contours Path of the polygon
  70593. * @param scene scene to add to when creating the mesh
  70594. * @param earcutInjection can be used to inject your own earcut reference
  70595. */
  70596. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  70597. /**
  70598. * Adds a hole within the polygon
  70599. * @param hole Array of points defining the hole
  70600. * @returns this
  70601. */
  70602. addHole(hole: Vector2[]): PolygonMeshBuilder;
  70603. /**
  70604. * Creates the polygon
  70605. * @param updatable If the mesh should be updatable
  70606. * @param depth The depth of the mesh created
  70607. * @param smoothingThreshold Dot product threshold for smoothed normals
  70608. * @returns the created mesh
  70609. */
  70610. build(updatable?: boolean, depth?: number, smoothingThreshold?: number): Mesh;
  70611. /**
  70612. * Creates the polygon
  70613. * @param depth The depth of the mesh created
  70614. * @param smoothingThreshold Dot product threshold for smoothed normals
  70615. * @returns the created VertexData
  70616. */
  70617. buildVertexData(depth?: number, smoothingThreshold?: number): VertexData;
  70618. /**
  70619. * Adds a side to the polygon
  70620. * @param positions points that make the polygon
  70621. * @param normals normals of the polygon
  70622. * @param uvs uvs of the polygon
  70623. * @param indices indices of the polygon
  70624. * @param bounds bounds of the polygon
  70625. * @param points points of the polygon
  70626. * @param depth depth of the polygon
  70627. * @param flip flip of the polygon
  70628. */
  70629. private addSide;
  70630. }
  70631. }
  70632. declare module BABYLON {
  70633. /**
  70634. * Class containing static functions to help procedurally build meshes
  70635. */
  70636. export class PolygonBuilder {
  70637. /**
  70638. * Creates a polygon mesh
  70639. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  70640. * * 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
  70641. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  70642. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70643. * * 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)
  70644. * * Remember you can only change the shape positions, not their number when updating a polygon
  70645. * @param name defines the name of the mesh
  70646. * @param options defines the options used to create the mesh
  70647. * @param scene defines the hosting scene
  70648. * @param earcutInjection can be used to inject your own earcut reference
  70649. * @returns the polygon mesh
  70650. */
  70651. static CreatePolygon(name: string, options: {
  70652. shape: Vector3[];
  70653. holes?: Vector3[][];
  70654. depth?: number;
  70655. smoothingThreshold?: number;
  70656. faceUV?: Vector4[];
  70657. faceColors?: Color4[];
  70658. updatable?: boolean;
  70659. sideOrientation?: number;
  70660. frontUVs?: Vector4;
  70661. backUVs?: Vector4;
  70662. wrap?: boolean;
  70663. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70664. /**
  70665. * Creates an extruded polygon mesh, with depth in the Y direction.
  70666. * * 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)
  70667. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70668. * @param name defines the name of the mesh
  70669. * @param options defines the options used to create the mesh
  70670. * @param scene defines the hosting scene
  70671. * @param earcutInjection can be used to inject your own earcut reference
  70672. * @returns the polygon mesh
  70673. */
  70674. static ExtrudePolygon(name: string, options: {
  70675. shape: Vector3[];
  70676. holes?: Vector3[][];
  70677. depth?: number;
  70678. faceUV?: Vector4[];
  70679. faceColors?: Color4[];
  70680. updatable?: boolean;
  70681. sideOrientation?: number;
  70682. frontUVs?: Vector4;
  70683. backUVs?: Vector4;
  70684. wrap?: boolean;
  70685. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70686. }
  70687. }
  70688. declare module BABYLON {
  70689. /**
  70690. * Class containing static functions to help procedurally build meshes
  70691. */
  70692. export class LatheBuilder {
  70693. /**
  70694. * Creates lathe mesh.
  70695. * The lathe is a shape with a symmetry axis : a 2D model shape is rotated around this axis to design the lathe
  70696. * * 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
  70697. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  70698. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  70699. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  70700. * * 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
  70701. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  70702. * * 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
  70703. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70704. * * 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
  70705. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70706. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70707. * @param name defines the name of the mesh
  70708. * @param options defines the options used to create the mesh
  70709. * @param scene defines the hosting scene
  70710. * @returns the lathe mesh
  70711. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  70712. */
  70713. static CreateLathe(name: string, options: {
  70714. shape: Vector3[];
  70715. radius?: number;
  70716. tessellation?: number;
  70717. clip?: number;
  70718. arc?: number;
  70719. closed?: boolean;
  70720. updatable?: boolean;
  70721. sideOrientation?: number;
  70722. frontUVs?: Vector4;
  70723. backUVs?: Vector4;
  70724. cap?: number;
  70725. invertUV?: boolean;
  70726. }, scene?: Nullable<Scene>): Mesh;
  70727. }
  70728. }
  70729. declare module BABYLON {
  70730. /**
  70731. * Class containing static functions to help procedurally build meshes
  70732. */
  70733. export class TiledPlaneBuilder {
  70734. /**
  70735. * Creates a tiled plane mesh
  70736. * * The parameter `pattern` will, depending on value, do nothing or
  70737. * * * flip (reflect about central vertical) alternate tiles across and up
  70738. * * * flip every tile on alternate rows
  70739. * * * rotate (180 degs) alternate tiles across and up
  70740. * * * rotate every tile on alternate rows
  70741. * * * flip and rotate alternate tiles across and up
  70742. * * * flip and rotate every tile on alternate rows
  70743. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  70744. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  70745. * * 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
  70746. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  70747. * * 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)
  70748. * * 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)
  70749. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  70750. * @param name defines the name of the mesh
  70751. * @param options defines the options used to create the mesh
  70752. * @param scene defines the hosting scene
  70753. * @returns the box mesh
  70754. */
  70755. static CreateTiledPlane(name: string, options: {
  70756. pattern?: number;
  70757. tileSize?: number;
  70758. tileWidth?: number;
  70759. tileHeight?: number;
  70760. size?: number;
  70761. width?: number;
  70762. height?: number;
  70763. alignHorizontal?: number;
  70764. alignVertical?: number;
  70765. sideOrientation?: number;
  70766. frontUVs?: Vector4;
  70767. backUVs?: Vector4;
  70768. updatable?: boolean;
  70769. }, scene?: Nullable<Scene>): Mesh;
  70770. }
  70771. }
  70772. declare module BABYLON {
  70773. /**
  70774. * Class containing static functions to help procedurally build meshes
  70775. */
  70776. export class TubeBuilder {
  70777. /**
  70778. * Creates a tube mesh.
  70779. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  70780. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  70781. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  70782. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  70783. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overrides the parameter `radius`
  70784. * * 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)
  70785. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  70786. * * 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
  70787. * * 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
  70788. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70789. * * 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
  70790. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70791. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70792. * @param name defines the name of the mesh
  70793. * @param options defines the options used to create the mesh
  70794. * @param scene defines the hosting scene
  70795. * @returns the tube mesh
  70796. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70797. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  70798. */
  70799. static CreateTube(name: string, options: {
  70800. path: Vector3[];
  70801. radius?: number;
  70802. tessellation?: number;
  70803. radiusFunction?: {
  70804. (i: number, distance: number): number;
  70805. };
  70806. cap?: number;
  70807. arc?: number;
  70808. updatable?: boolean;
  70809. sideOrientation?: number;
  70810. frontUVs?: Vector4;
  70811. backUVs?: Vector4;
  70812. instance?: Mesh;
  70813. invertUV?: boolean;
  70814. }, scene?: Nullable<Scene>): Mesh;
  70815. }
  70816. }
  70817. declare module BABYLON {
  70818. /**
  70819. * Class containing static functions to help procedurally build meshes
  70820. */
  70821. export class IcoSphereBuilder {
  70822. /**
  70823. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  70824. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  70825. * * 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`)
  70826. * * The parameter `subdivisions` sets the number of subdivisions (positive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  70827. * * 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
  70828. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70829. * * 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
  70830. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70831. * @param name defines the name of the mesh
  70832. * @param options defines the options used to create the mesh
  70833. * @param scene defines the hosting scene
  70834. * @returns the icosahedron mesh
  70835. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  70836. */
  70837. static CreateIcoSphere(name: string, options: {
  70838. radius?: number;
  70839. radiusX?: number;
  70840. radiusY?: number;
  70841. radiusZ?: number;
  70842. flat?: boolean;
  70843. subdivisions?: number;
  70844. sideOrientation?: number;
  70845. frontUVs?: Vector4;
  70846. backUVs?: Vector4;
  70847. updatable?: boolean;
  70848. }, scene?: Nullable<Scene>): Mesh;
  70849. }
  70850. }
  70851. declare module BABYLON {
  70852. /**
  70853. * Class containing static functions to help procedurally build meshes
  70854. */
  70855. export class DecalBuilder {
  70856. /**
  70857. * Creates a decal mesh.
  70858. * 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
  70859. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  70860. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  70861. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  70862. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  70863. * @param name defines the name of the mesh
  70864. * @param sourceMesh defines the mesh where the decal must be applied
  70865. * @param options defines the options used to create the mesh
  70866. * @param scene defines the hosting scene
  70867. * @returns the decal mesh
  70868. * @see https://doc.babylonjs.com/how_to/decals
  70869. */
  70870. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  70871. position?: Vector3;
  70872. normal?: Vector3;
  70873. size?: Vector3;
  70874. angle?: number;
  70875. }): Mesh;
  70876. }
  70877. }
  70878. declare module BABYLON {
  70879. /**
  70880. * Class containing static functions to help procedurally build meshes
  70881. */
  70882. export class MeshBuilder {
  70883. /**
  70884. * Creates a box mesh
  70885. * * The parameter `size` sets the size (float) of each box side (default 1)
  70886. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  70887. * * 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)
  70888. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70889. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70890. * * 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
  70891. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70892. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  70893. * @param name defines the name of the mesh
  70894. * @param options defines the options used to create the mesh
  70895. * @param scene defines the hosting scene
  70896. * @returns the box mesh
  70897. */
  70898. static CreateBox(name: string, options: {
  70899. size?: number;
  70900. width?: number;
  70901. height?: number;
  70902. depth?: number;
  70903. faceUV?: Vector4[];
  70904. faceColors?: Color4[];
  70905. sideOrientation?: number;
  70906. frontUVs?: Vector4;
  70907. backUVs?: Vector4;
  70908. wrap?: boolean;
  70909. topBaseAt?: number;
  70910. bottomBaseAt?: number;
  70911. updatable?: boolean;
  70912. }, scene?: Nullable<Scene>): Mesh;
  70913. /**
  70914. * Creates a tiled box mesh
  70915. * * faceTiles sets the pattern, tile size and number of tiles for a face
  70916. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70917. * @param name defines the name of the mesh
  70918. * @param options defines the options used to create the mesh
  70919. * @param scene defines the hosting scene
  70920. * @returns the tiled box mesh
  70921. */
  70922. static CreateTiledBox(name: string, options: {
  70923. pattern?: number;
  70924. size?: number;
  70925. width?: number;
  70926. height?: number;
  70927. depth: number;
  70928. tileSize?: number;
  70929. tileWidth?: number;
  70930. tileHeight?: number;
  70931. faceUV?: Vector4[];
  70932. faceColors?: Color4[];
  70933. alignHorizontal?: number;
  70934. alignVertical?: number;
  70935. sideOrientation?: number;
  70936. updatable?: boolean;
  70937. }, scene?: Nullable<Scene>): Mesh;
  70938. /**
  70939. * Creates a sphere mesh
  70940. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  70941. * * 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`)
  70942. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  70943. * * 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
  70944. * * 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)
  70945. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70946. * * 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
  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. * @param name defines the name of the mesh
  70949. * @param options defines the options used to create the mesh
  70950. * @param scene defines the hosting scene
  70951. * @returns the sphere mesh
  70952. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  70953. */
  70954. static CreateSphere(name: string, options: {
  70955. segments?: number;
  70956. diameter?: number;
  70957. diameterX?: number;
  70958. diameterY?: number;
  70959. diameterZ?: number;
  70960. arc?: number;
  70961. slice?: number;
  70962. sideOrientation?: number;
  70963. frontUVs?: Vector4;
  70964. backUVs?: Vector4;
  70965. updatable?: boolean;
  70966. }, scene?: Nullable<Scene>): Mesh;
  70967. /**
  70968. * Creates a plane polygonal mesh. By default, this is a disc
  70969. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  70970. * * 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
  70971. * * 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
  70972. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70973. * * 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
  70974. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70975. * @param name defines the name of the mesh
  70976. * @param options defines the options used to create the mesh
  70977. * @param scene defines the hosting scene
  70978. * @returns the plane polygonal mesh
  70979. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  70980. */
  70981. static CreateDisc(name: string, options: {
  70982. radius?: number;
  70983. tessellation?: number;
  70984. arc?: number;
  70985. updatable?: boolean;
  70986. sideOrientation?: number;
  70987. frontUVs?: Vector4;
  70988. backUVs?: Vector4;
  70989. }, scene?: Nullable<Scene>): Mesh;
  70990. /**
  70991. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  70992. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  70993. * * 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`)
  70994. * * The parameter `subdivisions` sets the number of subdivisions (positive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  70995. * * 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
  70996. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70997. * * 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
  70998. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70999. * @param name defines the name of the mesh
  71000. * @param options defines the options used to create the mesh
  71001. * @param scene defines the hosting scene
  71002. * @returns the icosahedron mesh
  71003. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  71004. */
  71005. static CreateIcoSphere(name: string, options: {
  71006. radius?: number;
  71007. radiusX?: number;
  71008. radiusY?: number;
  71009. radiusZ?: number;
  71010. flat?: boolean;
  71011. subdivisions?: number;
  71012. sideOrientation?: number;
  71013. frontUVs?: Vector4;
  71014. backUVs?: Vector4;
  71015. updatable?: boolean;
  71016. }, scene?: Nullable<Scene>): Mesh;
  71017. /**
  71018. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  71019. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  71020. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  71021. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  71022. * * 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
  71023. * * 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
  71024. * * 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
  71025. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71026. * * 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
  71027. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  71028. * * 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
  71029. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  71030. * * 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
  71031. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  71032. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71033. * @param name defines the name of the mesh
  71034. * @param options defines the options used to create the mesh
  71035. * @param scene defines the hosting scene
  71036. * @returns the ribbon mesh
  71037. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  71038. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  71039. */
  71040. static CreateRibbon(name: string, options: {
  71041. pathArray: Vector3[][];
  71042. closeArray?: boolean;
  71043. closePath?: boolean;
  71044. offset?: number;
  71045. updatable?: boolean;
  71046. sideOrientation?: number;
  71047. frontUVs?: Vector4;
  71048. backUVs?: Vector4;
  71049. instance?: Mesh;
  71050. invertUV?: boolean;
  71051. uvs?: Vector2[];
  71052. colors?: Color4[];
  71053. }, scene?: Nullable<Scene>): Mesh;
  71054. /**
  71055. * Creates a cylinder or a cone mesh
  71056. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  71057. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  71058. * * 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.
  71059. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  71060. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  71061. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  71062. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  71063. * * 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).
  71064. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  71065. * * 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).
  71066. * * 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
  71067. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  71068. * * 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
  71069. * * 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.
  71070. * * If `enclose` is false, a ring surface is one element.
  71071. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  71072. * * 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
  71073. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71074. * * 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
  71075. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  71076. * @param name defines the name of the mesh
  71077. * @param options defines the options used to create the mesh
  71078. * @param scene defines the hosting scene
  71079. * @returns the cylinder mesh
  71080. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  71081. */
  71082. static CreateCylinder(name: string, options: {
  71083. height?: number;
  71084. diameterTop?: number;
  71085. diameterBottom?: number;
  71086. diameter?: number;
  71087. tessellation?: number;
  71088. subdivisions?: number;
  71089. arc?: number;
  71090. faceColors?: Color4[];
  71091. faceUV?: Vector4[];
  71092. updatable?: boolean;
  71093. hasRings?: boolean;
  71094. enclose?: boolean;
  71095. cap?: number;
  71096. sideOrientation?: number;
  71097. frontUVs?: Vector4;
  71098. backUVs?: Vector4;
  71099. }, scene?: Nullable<Scene>): Mesh;
  71100. /**
  71101. * Creates a torus mesh
  71102. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  71103. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  71104. * * The parameter `tessellation` sets the number of torus sides (positive integer, default 16)
  71105. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71106. * * 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
  71107. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  71108. * @param name defines the name of the mesh
  71109. * @param options defines the options used to create the mesh
  71110. * @param scene defines the hosting scene
  71111. * @returns the torus mesh
  71112. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  71113. */
  71114. static CreateTorus(name: string, options: {
  71115. diameter?: number;
  71116. thickness?: number;
  71117. tessellation?: number;
  71118. updatable?: boolean;
  71119. sideOrientation?: number;
  71120. frontUVs?: Vector4;
  71121. backUVs?: Vector4;
  71122. }, scene?: Nullable<Scene>): Mesh;
  71123. /**
  71124. * Creates a torus knot mesh
  71125. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  71126. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  71127. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  71128. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  71129. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71130. * * 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
  71131. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  71132. * @param name defines the name of the mesh
  71133. * @param options defines the options used to create the mesh
  71134. * @param scene defines the hosting scene
  71135. * @returns the torus knot mesh
  71136. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  71137. */
  71138. static CreateTorusKnot(name: string, options: {
  71139. radius?: number;
  71140. tube?: number;
  71141. radialSegments?: number;
  71142. tubularSegments?: number;
  71143. p?: number;
  71144. q?: number;
  71145. updatable?: boolean;
  71146. sideOrientation?: number;
  71147. frontUVs?: Vector4;
  71148. backUVs?: Vector4;
  71149. }, scene?: Nullable<Scene>): Mesh;
  71150. /**
  71151. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  71152. * * 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
  71153. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  71154. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  71155. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  71156. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  71157. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  71158. * * 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
  71159. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  71160. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71161. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  71162. * @param name defines the name of the new line system
  71163. * @param options defines the options used to create the line system
  71164. * @param scene defines the hosting scene
  71165. * @returns a new line system mesh
  71166. */
  71167. static CreateLineSystem(name: string, options: {
  71168. lines: Vector3[][];
  71169. updatable?: boolean;
  71170. instance?: Nullable<LinesMesh>;
  71171. colors?: Nullable<Color4[][]>;
  71172. useVertexAlpha?: boolean;
  71173. }, scene: Nullable<Scene>): LinesMesh;
  71174. /**
  71175. * Creates a line mesh
  71176. * 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
  71177. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  71178. * * The parameter `points` is an array successive Vector3
  71179. * * 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
  71180. * * The optional parameter `colors` is an array of successive Color4, one per line point
  71181. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  71182. * * When updating an instance, remember that only point positions can change, not the number of points
  71183. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71184. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  71185. * @param name defines the name of the new line system
  71186. * @param options defines the options used to create the line system
  71187. * @param scene defines the hosting scene
  71188. * @returns a new line mesh
  71189. */
  71190. static CreateLines(name: string, options: {
  71191. points: Vector3[];
  71192. updatable?: boolean;
  71193. instance?: Nullable<LinesMesh>;
  71194. colors?: Color4[];
  71195. useVertexAlpha?: boolean;
  71196. }, scene?: Nullable<Scene>): LinesMesh;
  71197. /**
  71198. * Creates a dashed line mesh
  71199. * * 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
  71200. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  71201. * * The parameter `points` is an array successive Vector3
  71202. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  71203. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  71204. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  71205. * * 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
  71206. * * When updating an instance, remember that only point positions can change, not the number of points
  71207. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71208. * @param name defines the name of the mesh
  71209. * @param options defines the options used to create the mesh
  71210. * @param scene defines the hosting scene
  71211. * @returns the dashed line mesh
  71212. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  71213. */
  71214. static CreateDashedLines(name: string, options: {
  71215. points: Vector3[];
  71216. dashSize?: number;
  71217. gapSize?: number;
  71218. dashNb?: number;
  71219. updatable?: boolean;
  71220. instance?: LinesMesh;
  71221. }, scene?: Nullable<Scene>): LinesMesh;
  71222. /**
  71223. * 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.
  71224. * * 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.
  71225. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  71226. * * 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.
  71227. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  71228. * * 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
  71229. * * 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
  71230. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  71231. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71232. * * 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
  71233. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  71234. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  71235. * @param name defines the name of the mesh
  71236. * @param options defines the options used to create the mesh
  71237. * @param scene defines the hosting scene
  71238. * @returns the extruded shape mesh
  71239. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  71240. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  71241. */
  71242. static ExtrudeShape(name: string, options: {
  71243. shape: Vector3[];
  71244. path: Vector3[];
  71245. scale?: number;
  71246. rotation?: number;
  71247. cap?: number;
  71248. updatable?: boolean;
  71249. sideOrientation?: number;
  71250. frontUVs?: Vector4;
  71251. backUVs?: Vector4;
  71252. instance?: Mesh;
  71253. invertUV?: boolean;
  71254. }, scene?: Nullable<Scene>): Mesh;
  71255. /**
  71256. * Creates an custom extruded shape mesh.
  71257. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  71258. * * 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.
  71259. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  71260. * * 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
  71261. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  71262. * * 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
  71263. * * It must returns a float value that will be the scale value applied to the shape on each path point
  71264. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  71265. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  71266. * * 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
  71267. * * 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
  71268. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  71269. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71270. * * 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
  71271. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  71272. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71273. * @param name defines the name of the mesh
  71274. * @param options defines the options used to create the mesh
  71275. * @param scene defines the hosting scene
  71276. * @returns the custom extruded shape mesh
  71277. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  71278. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  71279. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  71280. */
  71281. static ExtrudeShapeCustom(name: string, options: {
  71282. shape: Vector3[];
  71283. path: Vector3[];
  71284. scaleFunction?: any;
  71285. rotationFunction?: any;
  71286. ribbonCloseArray?: boolean;
  71287. ribbonClosePath?: boolean;
  71288. cap?: number;
  71289. updatable?: boolean;
  71290. sideOrientation?: number;
  71291. frontUVs?: Vector4;
  71292. backUVs?: Vector4;
  71293. instance?: Mesh;
  71294. invertUV?: boolean;
  71295. }, scene?: Nullable<Scene>): Mesh;
  71296. /**
  71297. * Creates lathe mesh.
  71298. * The lathe is a shape with a symmetry axis : a 2D model shape is rotated around this axis to design the lathe
  71299. * * 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
  71300. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  71301. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  71302. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  71303. * * 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
  71304. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  71305. * * 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
  71306. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71307. * * 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
  71308. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  71309. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71310. * @param name defines the name of the mesh
  71311. * @param options defines the options used to create the mesh
  71312. * @param scene defines the hosting scene
  71313. * @returns the lathe mesh
  71314. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  71315. */
  71316. static CreateLathe(name: string, options: {
  71317. shape: Vector3[];
  71318. radius?: number;
  71319. tessellation?: number;
  71320. clip?: number;
  71321. arc?: number;
  71322. closed?: boolean;
  71323. updatable?: boolean;
  71324. sideOrientation?: number;
  71325. frontUVs?: Vector4;
  71326. backUVs?: Vector4;
  71327. cap?: number;
  71328. invertUV?: boolean;
  71329. }, scene?: Nullable<Scene>): Mesh;
  71330. /**
  71331. * Creates a tiled plane mesh
  71332. * * You can set a limited pattern arrangement with the tiles
  71333. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71334. * * 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
  71335. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71336. * @param name defines the name of the mesh
  71337. * @param options defines the options used to create the mesh
  71338. * @param scene defines the hosting scene
  71339. * @returns the plane mesh
  71340. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  71341. */
  71342. static CreateTiledPlane(name: string, options: {
  71343. pattern?: number;
  71344. tileSize?: number;
  71345. tileWidth?: number;
  71346. tileHeight?: number;
  71347. size?: number;
  71348. width?: number;
  71349. height?: number;
  71350. alignHorizontal?: number;
  71351. alignVertical?: number;
  71352. sideOrientation?: number;
  71353. frontUVs?: Vector4;
  71354. backUVs?: Vector4;
  71355. updatable?: boolean;
  71356. }, scene?: Nullable<Scene>): Mesh;
  71357. /**
  71358. * Creates a plane mesh
  71359. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  71360. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  71361. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  71362. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71363. * * 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
  71364. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71365. * @param name defines the name of the mesh
  71366. * @param options defines the options used to create the mesh
  71367. * @param scene defines the hosting scene
  71368. * @returns the plane mesh
  71369. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  71370. */
  71371. static CreatePlane(name: string, options: {
  71372. size?: number;
  71373. width?: number;
  71374. height?: number;
  71375. sideOrientation?: number;
  71376. frontUVs?: Vector4;
  71377. backUVs?: Vector4;
  71378. updatable?: boolean;
  71379. sourcePlane?: Plane;
  71380. }, scene?: Nullable<Scene>): Mesh;
  71381. /**
  71382. * Creates a ground mesh
  71383. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  71384. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  71385. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71386. * @param name defines the name of the mesh
  71387. * @param options defines the options used to create the mesh
  71388. * @param scene defines the hosting scene
  71389. * @returns the ground mesh
  71390. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  71391. */
  71392. static CreateGround(name: string, options: {
  71393. width?: number;
  71394. height?: number;
  71395. subdivisions?: number;
  71396. subdivisionsX?: number;
  71397. subdivisionsY?: number;
  71398. updatable?: boolean;
  71399. }, scene?: Nullable<Scene>): Mesh;
  71400. /**
  71401. * Creates a tiled ground mesh
  71402. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  71403. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  71404. * * 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
  71405. * * 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
  71406. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  71407. * @param name defines the name of the mesh
  71408. * @param options defines the options used to create the mesh
  71409. * @param scene defines the hosting scene
  71410. * @returns the tiled ground mesh
  71411. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  71412. */
  71413. static CreateTiledGround(name: string, options: {
  71414. xmin: number;
  71415. zmin: number;
  71416. xmax: number;
  71417. zmax: number;
  71418. subdivisions?: {
  71419. w: number;
  71420. h: number;
  71421. };
  71422. precision?: {
  71423. w: number;
  71424. h: number;
  71425. };
  71426. updatable?: boolean;
  71427. }, scene?: Nullable<Scene>): Mesh;
  71428. /**
  71429. * Creates a ground mesh from a height map
  71430. * * The parameter `url` sets the URL of the height map image resource.
  71431. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  71432. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  71433. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  71434. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  71435. * * 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.
  71436. * * 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).
  71437. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  71438. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  71439. * @param name defines the name of the mesh
  71440. * @param url defines the url to the height map
  71441. * @param options defines the options used to create the mesh
  71442. * @param scene defines the hosting scene
  71443. * @returns the ground mesh
  71444. * @see https://doc.babylonjs.com/babylon101/height_map
  71445. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  71446. */
  71447. static CreateGroundFromHeightMap(name: string, url: string, options: {
  71448. width?: number;
  71449. height?: number;
  71450. subdivisions?: number;
  71451. minHeight?: number;
  71452. maxHeight?: number;
  71453. colorFilter?: Color3;
  71454. alphaFilter?: number;
  71455. updatable?: boolean;
  71456. onReady?: (mesh: GroundMesh) => void;
  71457. }, scene?: Nullable<Scene>): GroundMesh;
  71458. /**
  71459. * Creates a polygon mesh
  71460. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  71461. * * 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
  71462. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  71463. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71464. * * 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)
  71465. * * Remember you can only change the shape positions, not their number when updating a polygon
  71466. * @param name defines the name of the mesh
  71467. * @param options defines the options used to create the mesh
  71468. * @param scene defines the hosting scene
  71469. * @param earcutInjection can be used to inject your own earcut reference
  71470. * @returns the polygon mesh
  71471. */
  71472. static CreatePolygon(name: string, options: {
  71473. shape: Vector3[];
  71474. holes?: Vector3[][];
  71475. depth?: number;
  71476. faceUV?: Vector4[];
  71477. faceColors?: Color4[];
  71478. updatable?: boolean;
  71479. sideOrientation?: number;
  71480. frontUVs?: Vector4;
  71481. backUVs?: Vector4;
  71482. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  71483. /**
  71484. * Creates an extruded polygon mesh, with depth in the Y direction.
  71485. * * 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)
  71486. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  71487. * @param name defines the name of the mesh
  71488. * @param options defines the options used to create the mesh
  71489. * @param scene defines the hosting scene
  71490. * @param earcutInjection can be used to inject your own earcut reference
  71491. * @returns the polygon mesh
  71492. */
  71493. static ExtrudePolygon(name: string, options: {
  71494. shape: Vector3[];
  71495. holes?: Vector3[][];
  71496. depth?: number;
  71497. faceUV?: Vector4[];
  71498. faceColors?: Color4[];
  71499. updatable?: boolean;
  71500. sideOrientation?: number;
  71501. frontUVs?: Vector4;
  71502. backUVs?: Vector4;
  71503. wrap?: boolean;
  71504. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  71505. /**
  71506. * Creates a tube mesh.
  71507. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  71508. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  71509. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  71510. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  71511. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overrides the parameter `radius`
  71512. * * 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)
  71513. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  71514. * * 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
  71515. * * 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
  71516. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71517. * * 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
  71518. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  71519. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71520. * @param name defines the name of the mesh
  71521. * @param options defines the options used to create the mesh
  71522. * @param scene defines the hosting scene
  71523. * @returns the tube mesh
  71524. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  71525. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  71526. */
  71527. static CreateTube(name: string, options: {
  71528. path: Vector3[];
  71529. radius?: number;
  71530. tessellation?: number;
  71531. radiusFunction?: {
  71532. (i: number, distance: number): number;
  71533. };
  71534. cap?: number;
  71535. arc?: number;
  71536. updatable?: boolean;
  71537. sideOrientation?: number;
  71538. frontUVs?: Vector4;
  71539. backUVs?: Vector4;
  71540. instance?: Mesh;
  71541. invertUV?: boolean;
  71542. }, scene?: Nullable<Scene>): Mesh;
  71543. /**
  71544. * Creates a polyhedron mesh
  71545. * * 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
  71546. * * The parameter `size` (positive float, default 1) sets the polygon size
  71547. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  71548. * * 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`
  71549. * * 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
  71550. * * 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)`)
  71551. * * 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
  71552. * * 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
  71553. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71554. * * 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
  71555. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71556. * @param name defines the name of the mesh
  71557. * @param options defines the options used to create the mesh
  71558. * @param scene defines the hosting scene
  71559. * @returns the polyhedron mesh
  71560. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  71561. */
  71562. static CreatePolyhedron(name: string, options: {
  71563. type?: number;
  71564. size?: number;
  71565. sizeX?: number;
  71566. sizeY?: number;
  71567. sizeZ?: number;
  71568. custom?: any;
  71569. faceUV?: Vector4[];
  71570. faceColors?: Color4[];
  71571. flat?: boolean;
  71572. updatable?: boolean;
  71573. sideOrientation?: number;
  71574. frontUVs?: Vector4;
  71575. backUVs?: Vector4;
  71576. }, scene?: Nullable<Scene>): Mesh;
  71577. /**
  71578. * Creates a decal mesh.
  71579. * 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
  71580. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  71581. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  71582. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  71583. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  71584. * @param name defines the name of the mesh
  71585. * @param sourceMesh defines the mesh where the decal must be applied
  71586. * @param options defines the options used to create the mesh
  71587. * @param scene defines the hosting scene
  71588. * @returns the decal mesh
  71589. * @see https://doc.babylonjs.com/how_to/decals
  71590. */
  71591. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  71592. position?: Vector3;
  71593. normal?: Vector3;
  71594. size?: Vector3;
  71595. angle?: number;
  71596. }): Mesh;
  71597. /**
  71598. * Creates a Capsule Mesh
  71599. * @param name defines the name of the mesh.
  71600. * @param options the constructors options used to shape the mesh.
  71601. * @param scene defines the scene the mesh is scoped to.
  71602. * @returns the capsule mesh
  71603. * @see https://doc.babylonjs.com/how_to/capsule_shape
  71604. */
  71605. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  71606. }
  71607. }
  71608. declare module BABYLON {
  71609. /**
  71610. * A simplifier interface for future simplification implementations
  71611. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71612. */
  71613. export interface ISimplifier {
  71614. /**
  71615. * Simplification of a given mesh according to the given settings.
  71616. * Since this requires computation, it is assumed that the function runs async.
  71617. * @param settings The settings of the simplification, including quality and distance
  71618. * @param successCallback A callback that will be called after the mesh was simplified.
  71619. * @param errorCallback in case of an error, this callback will be called. optional.
  71620. */
  71621. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  71622. }
  71623. /**
  71624. * Expected simplification settings.
  71625. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  71626. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71627. */
  71628. export interface ISimplificationSettings {
  71629. /**
  71630. * Gets or sets the expected quality
  71631. */
  71632. quality: number;
  71633. /**
  71634. * Gets or sets the distance when this optimized version should be used
  71635. */
  71636. distance: number;
  71637. /**
  71638. * Gets an already optimized mesh
  71639. */
  71640. optimizeMesh?: boolean;
  71641. }
  71642. /**
  71643. * Class used to specify simplification options
  71644. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71645. */
  71646. export class SimplificationSettings implements ISimplificationSettings {
  71647. /** expected quality */
  71648. quality: number;
  71649. /** distance when this optimized version should be used */
  71650. distance: number;
  71651. /** already optimized mesh */
  71652. optimizeMesh?: boolean | undefined;
  71653. /**
  71654. * Creates a SimplificationSettings
  71655. * @param quality expected quality
  71656. * @param distance distance when this optimized version should be used
  71657. * @param optimizeMesh already optimized mesh
  71658. */
  71659. constructor(
  71660. /** expected quality */
  71661. quality: number,
  71662. /** distance when this optimized version should be used */
  71663. distance: number,
  71664. /** already optimized mesh */
  71665. optimizeMesh?: boolean | undefined);
  71666. }
  71667. /**
  71668. * Interface used to define a simplification task
  71669. */
  71670. export interface ISimplificationTask {
  71671. /**
  71672. * Array of settings
  71673. */
  71674. settings: Array<ISimplificationSettings>;
  71675. /**
  71676. * Simplification type
  71677. */
  71678. simplificationType: SimplificationType;
  71679. /**
  71680. * Mesh to simplify
  71681. */
  71682. mesh: Mesh;
  71683. /**
  71684. * Callback called on success
  71685. */
  71686. successCallback?: () => void;
  71687. /**
  71688. * Defines if parallel processing can be used
  71689. */
  71690. parallelProcessing: boolean;
  71691. }
  71692. /**
  71693. * Queue used to order the simplification tasks
  71694. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71695. */
  71696. export class SimplificationQueue {
  71697. private _simplificationArray;
  71698. /**
  71699. * Gets a boolean indicating that the process is still running
  71700. */
  71701. running: boolean;
  71702. /**
  71703. * Creates a new queue
  71704. */
  71705. constructor();
  71706. /**
  71707. * Adds a new simplification task
  71708. * @param task defines a task to add
  71709. */
  71710. addTask(task: ISimplificationTask): void;
  71711. /**
  71712. * Execute next task
  71713. */
  71714. executeNext(): void;
  71715. /**
  71716. * Execute a simplification task
  71717. * @param task defines the task to run
  71718. */
  71719. runSimplification(task: ISimplificationTask): void;
  71720. private getSimplifier;
  71721. }
  71722. /**
  71723. * The implemented types of simplification
  71724. * At the moment only Quadratic Error Decimation is implemented
  71725. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71726. */
  71727. export enum SimplificationType {
  71728. /** Quadratic error decimation */
  71729. QUADRATIC = 0
  71730. }
  71731. /**
  71732. * An implementation of the Quadratic Error simplification algorithm.
  71733. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  71734. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  71735. * @author RaananW
  71736. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71737. */
  71738. export class QuadraticErrorSimplification implements ISimplifier {
  71739. private _mesh;
  71740. private triangles;
  71741. private vertices;
  71742. private references;
  71743. private _reconstructedMesh;
  71744. /** Gets or sets the number pf sync iterations */
  71745. syncIterations: number;
  71746. /** Gets or sets the aggressiveness of the simplifier */
  71747. aggressiveness: number;
  71748. /** Gets or sets the number of allowed iterations for decimation */
  71749. decimationIterations: number;
  71750. /** Gets or sets the espilon to use for bounding box computation */
  71751. boundingBoxEpsilon: number;
  71752. /**
  71753. * Creates a new QuadraticErrorSimplification
  71754. * @param _mesh defines the target mesh
  71755. */
  71756. constructor(_mesh: Mesh);
  71757. /**
  71758. * Simplification of a given mesh according to the given settings.
  71759. * Since this requires computation, it is assumed that the function runs async.
  71760. * @param settings The settings of the simplification, including quality and distance
  71761. * @param successCallback A callback that will be called after the mesh was simplified.
  71762. */
  71763. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  71764. private runDecimation;
  71765. private initWithMesh;
  71766. private init;
  71767. private reconstructMesh;
  71768. private initDecimatedMesh;
  71769. private isFlipped;
  71770. private updateTriangles;
  71771. private identifyBorder;
  71772. private updateMesh;
  71773. private vertexError;
  71774. private calculateError;
  71775. }
  71776. }
  71777. declare module BABYLON {
  71778. interface Scene {
  71779. /** @hidden (Backing field) */
  71780. _simplificationQueue: SimplificationQueue;
  71781. /**
  71782. * Gets or sets the simplification queue attached to the scene
  71783. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71784. */
  71785. simplificationQueue: SimplificationQueue;
  71786. }
  71787. interface Mesh {
  71788. /**
  71789. * Simplify the mesh according to the given array of settings.
  71790. * Function will return immediately and will simplify async
  71791. * @param settings a collection of simplification settings
  71792. * @param parallelProcessing should all levels calculate parallel or one after the other
  71793. * @param simplificationType the type of simplification to run
  71794. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  71795. * @returns the current mesh
  71796. */
  71797. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  71798. }
  71799. /**
  71800. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  71801. * created in a scene
  71802. */
  71803. export class SimplicationQueueSceneComponent implements ISceneComponent {
  71804. /**
  71805. * The component name helpfull to identify the component in the list of scene components.
  71806. */
  71807. readonly name: string;
  71808. /**
  71809. * The scene the component belongs to.
  71810. */
  71811. scene: Scene;
  71812. /**
  71813. * Creates a new instance of the component for the given scene
  71814. * @param scene Defines the scene to register the component in
  71815. */
  71816. constructor(scene: Scene);
  71817. /**
  71818. * Registers the component in a given scene
  71819. */
  71820. register(): void;
  71821. /**
  71822. * Rebuilds the elements related to this component in case of
  71823. * context lost for instance.
  71824. */
  71825. rebuild(): void;
  71826. /**
  71827. * Disposes the component and the associated resources
  71828. */
  71829. dispose(): void;
  71830. private _beforeCameraUpdate;
  71831. }
  71832. }
  71833. declare module BABYLON {
  71834. interface Mesh {
  71835. /**
  71836. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  71837. */
  71838. thinInstanceEnablePicking: boolean;
  71839. /**
  71840. * Creates a new thin instance
  71841. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  71842. * @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
  71843. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  71844. */
  71845. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  71846. /**
  71847. * Adds the transformation (matrix) of the current mesh as a thin instance
  71848. * @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
  71849. * @returns the thin instance index number
  71850. */
  71851. thinInstanceAddSelf(refresh: boolean): number;
  71852. /**
  71853. * Registers a custom attribute to be used with thin instances
  71854. * @param kind name of the attribute
  71855. * @param stride size in floats of the attribute
  71856. */
  71857. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  71858. /**
  71859. * Sets the matrix of a thin instance
  71860. * @param index index of the thin instance
  71861. * @param matrix matrix to set
  71862. * @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
  71863. */
  71864. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  71865. /**
  71866. * Sets the value of a custom attribute for a thin instance
  71867. * @param kind name of the attribute
  71868. * @param index index of the thin instance
  71869. * @param value value to set
  71870. * @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
  71871. */
  71872. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  71873. /**
  71874. * 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.
  71875. */
  71876. thinInstanceCount: number;
  71877. /**
  71878. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  71879. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  71880. * @param buffer buffer to set
  71881. * @param stride size in floats of each value of the buffer
  71882. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  71883. */
  71884. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  71885. /**
  71886. * Gets the list of world matrices
  71887. * @return an array containing all the world matrices from the thin instances
  71888. */
  71889. thinInstanceGetWorldMatrices(): Matrix[];
  71890. /**
  71891. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  71892. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  71893. */
  71894. thinInstanceBufferUpdated(kind: string): void;
  71895. /**
  71896. * Applies a partial update to a buffer directly on the GPU
  71897. * 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
  71898. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  71899. * @param data the data to set in the GPU buffer
  71900. * @param offset the offset in the GPU buffer where to update the data
  71901. */
  71902. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  71903. /**
  71904. * Refreshes the bounding info, taking into account all the thin instances defined
  71905. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  71906. */
  71907. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  71908. /** @hidden */
  71909. _thinInstanceInitializeUserStorage(): void;
  71910. /** @hidden */
  71911. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  71912. /** @hidden */
  71913. _userThinInstanceBuffersStorage: {
  71914. data: {
  71915. [key: string]: Float32Array;
  71916. };
  71917. sizes: {
  71918. [key: string]: number;
  71919. };
  71920. vertexBuffers: {
  71921. [key: string]: Nullable<VertexBuffer>;
  71922. };
  71923. strides: {
  71924. [key: string]: number;
  71925. };
  71926. };
  71927. }
  71928. }
  71929. declare module BABYLON {
  71930. /**
  71931. * Navigation plugin interface to add navigation constrained by a navigation mesh
  71932. */
  71933. export interface INavigationEnginePlugin {
  71934. /**
  71935. * plugin name
  71936. */
  71937. name: string;
  71938. /**
  71939. * Creates a navigation mesh
  71940. * @param meshes array of all the geometry used to compute the navigation mesh
  71941. * @param parameters bunch of parameters used to filter geometry
  71942. */
  71943. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  71944. /**
  71945. * Create a navigation mesh debug mesh
  71946. * @param scene is where the mesh will be added
  71947. * @returns debug display mesh
  71948. */
  71949. createDebugNavMesh(scene: Scene): Mesh;
  71950. /**
  71951. * Get a navigation mesh constrained position, closest to the parameter position
  71952. * @param position world position
  71953. * @returns the closest point to position constrained by the navigation mesh
  71954. */
  71955. getClosestPoint(position: Vector3): Vector3;
  71956. /**
  71957. * Get a navigation mesh constrained position, closest to the parameter position
  71958. * @param position world position
  71959. * @param result output the closest point to position constrained by the navigation mesh
  71960. */
  71961. getClosestPointToRef(position: Vector3, result: Vector3): void;
  71962. /**
  71963. * Get a navigation mesh constrained position, within a particular radius
  71964. * @param position world position
  71965. * @param maxRadius the maximum distance to the constrained world position
  71966. * @returns the closest point to position constrained by the navigation mesh
  71967. */
  71968. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  71969. /**
  71970. * Get a navigation mesh constrained position, within a particular radius
  71971. * @param position world position
  71972. * @param maxRadius the maximum distance to the constrained world position
  71973. * @param result output the closest point to position constrained by the navigation mesh
  71974. */
  71975. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  71976. /**
  71977. * Compute the final position from a segment made of destination-position
  71978. * @param position world position
  71979. * @param destination world position
  71980. * @returns the resulting point along the navmesh
  71981. */
  71982. moveAlong(position: Vector3, destination: Vector3): Vector3;
  71983. /**
  71984. * Compute the final position from a segment made of destination-position
  71985. * @param position world position
  71986. * @param destination world position
  71987. * @param result output the resulting point along the navmesh
  71988. */
  71989. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  71990. /**
  71991. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  71992. * @param start world position
  71993. * @param end world position
  71994. * @returns array containing world position composing the path
  71995. */
  71996. computePath(start: Vector3, end: Vector3): Vector3[];
  71997. /**
  71998. * If this plugin is supported
  71999. * @returns true if plugin is supported
  72000. */
  72001. isSupported(): boolean;
  72002. /**
  72003. * Create a new Crowd so you can add agents
  72004. * @param maxAgents the maximum agent count in the crowd
  72005. * @param maxAgentRadius the maximum radius an agent can have
  72006. * @param scene to attach the crowd to
  72007. * @returns the crowd you can add agents to
  72008. */
  72009. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  72010. /**
  72011. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  72012. * The queries will try to find a solution within those bounds
  72013. * default is (1,1,1)
  72014. * @param extent x,y,z value that define the extent around the queries point of reference
  72015. */
  72016. setDefaultQueryExtent(extent: Vector3): void;
  72017. /**
  72018. * Get the Bounding box extent specified by setDefaultQueryExtent
  72019. * @returns the box extent values
  72020. */
  72021. getDefaultQueryExtent(): Vector3;
  72022. /**
  72023. * build the navmesh from a previously saved state using getNavmeshData
  72024. * @param data the Uint8Array returned by getNavmeshData
  72025. */
  72026. buildFromNavmeshData(data: Uint8Array): void;
  72027. /**
  72028. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  72029. * @returns data the Uint8Array that can be saved and reused
  72030. */
  72031. getNavmeshData(): Uint8Array;
  72032. /**
  72033. * Get the Bounding box extent result specified by setDefaultQueryExtent
  72034. * @param result output the box extent values
  72035. */
  72036. getDefaultQueryExtentToRef(result: Vector3): void;
  72037. /**
  72038. * Set the time step of the navigation tick update.
  72039. * Default is 1/60.
  72040. * A value of 0 will disable fixed time update
  72041. * @param newTimeStep the new timestep to apply to this world.
  72042. */
  72043. setTimeStep(newTimeStep: number): void;
  72044. /**
  72045. * Get the time step of the navigation tick update.
  72046. * @returns the current time step
  72047. */
  72048. getTimeStep(): number;
  72049. /**
  72050. * If delta time in navigation tick update is greater than the time step
  72051. * a number of sub iterations are done. If more iterations are need to reach deltatime
  72052. * they will be discarded.
  72053. * A value of 0 will set to no maximum and update will use as many substeps as needed
  72054. * @param newStepCount the maximum number of iterations
  72055. */
  72056. setMaximumSubStepCount(newStepCount: number): void;
  72057. /**
  72058. * Get the maximum number of iterations per navigation tick update
  72059. * @returns the maximum number of iterations
  72060. */
  72061. getMaximumSubStepCount(): number;
  72062. /**
  72063. * Release all resources
  72064. */
  72065. dispose(): void;
  72066. }
  72067. /**
  72068. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  72069. */
  72070. export interface ICrowd {
  72071. /**
  72072. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  72073. * You can attach anything to that node. The node position is updated in the scene update tick.
  72074. * @param pos world position that will be constrained by the navigation mesh
  72075. * @param parameters agent parameters
  72076. * @param transform hooked to the agent that will be update by the scene
  72077. * @returns agent index
  72078. */
  72079. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  72080. /**
  72081. * Returns the agent position in world space
  72082. * @param index agent index returned by addAgent
  72083. * @returns world space position
  72084. */
  72085. getAgentPosition(index: number): Vector3;
  72086. /**
  72087. * Gets the agent position result in world space
  72088. * @param index agent index returned by addAgent
  72089. * @param result output world space position
  72090. */
  72091. getAgentPositionToRef(index: number, result: Vector3): void;
  72092. /**
  72093. * Gets the agent velocity in world space
  72094. * @param index agent index returned by addAgent
  72095. * @returns world space velocity
  72096. */
  72097. getAgentVelocity(index: number): Vector3;
  72098. /**
  72099. * Gets the agent velocity result in world space
  72100. * @param index agent index returned by addAgent
  72101. * @param result output world space velocity
  72102. */
  72103. getAgentVelocityToRef(index: number, result: Vector3): void;
  72104. /**
  72105. * Gets the agent next target point on the path
  72106. * @param index agent index returned by addAgent
  72107. * @returns world space position
  72108. */
  72109. getAgentNextTargetPath(index: number): Vector3;
  72110. /**
  72111. * Gets the agent state
  72112. * @param index agent index returned by addAgent
  72113. * @returns agent state
  72114. */
  72115. getAgentState(index: number): number;
  72116. /**
  72117. * returns true if the agent in over an off mesh link connection
  72118. * @param index agent index returned by addAgent
  72119. * @returns true if over an off mesh link connection
  72120. */
  72121. overOffmeshConnection(index: number): boolean;
  72122. /**
  72123. * Gets the agent next target point on the path
  72124. * @param index agent index returned by addAgent
  72125. * @param result output world space position
  72126. */
  72127. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  72128. /**
  72129. * remove a particular agent previously created
  72130. * @param index agent index returned by addAgent
  72131. */
  72132. removeAgent(index: number): void;
  72133. /**
  72134. * get the list of all agents attached to this crowd
  72135. * @returns list of agent indices
  72136. */
  72137. getAgents(): number[];
  72138. /**
  72139. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  72140. * @param deltaTime in seconds
  72141. */
  72142. update(deltaTime: number): void;
  72143. /**
  72144. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  72145. * @param index agent index returned by addAgent
  72146. * @param destination targeted world position
  72147. */
  72148. agentGoto(index: number, destination: Vector3): void;
  72149. /**
  72150. * Teleport the agent to a new position
  72151. * @param index agent index returned by addAgent
  72152. * @param destination targeted world position
  72153. */
  72154. agentTeleport(index: number, destination: Vector3): void;
  72155. /**
  72156. * Update agent parameters
  72157. * @param index agent index returned by addAgent
  72158. * @param parameters agent parameters
  72159. */
  72160. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  72161. /**
  72162. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  72163. * The queries will try to find a solution within those bounds
  72164. * default is (1,1,1)
  72165. * @param extent x,y,z value that define the extent around the queries point of reference
  72166. */
  72167. setDefaultQueryExtent(extent: Vector3): void;
  72168. /**
  72169. * Get the Bounding box extent specified by setDefaultQueryExtent
  72170. * @returns the box extent values
  72171. */
  72172. getDefaultQueryExtent(): Vector3;
  72173. /**
  72174. * Get the Bounding box extent result specified by setDefaultQueryExtent
  72175. * @param result output the box extent values
  72176. */
  72177. getDefaultQueryExtentToRef(result: Vector3): void;
  72178. /**
  72179. * Release all resources
  72180. */
  72181. dispose(): void;
  72182. }
  72183. /**
  72184. * Configures an agent
  72185. */
  72186. export interface IAgentParameters {
  72187. /**
  72188. * Agent radius. [Limit: >= 0]
  72189. */
  72190. radius: number;
  72191. /**
  72192. * Agent height. [Limit: > 0]
  72193. */
  72194. height: number;
  72195. /**
  72196. * Maximum allowed acceleration. [Limit: >= 0]
  72197. */
  72198. maxAcceleration: number;
  72199. /**
  72200. * Maximum allowed speed. [Limit: >= 0]
  72201. */
  72202. maxSpeed: number;
  72203. /**
  72204. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  72205. */
  72206. collisionQueryRange: number;
  72207. /**
  72208. * The path visibility optimization range. [Limit: > 0]
  72209. */
  72210. pathOptimizationRange: number;
  72211. /**
  72212. * How aggressive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  72213. */
  72214. separationWeight: number;
  72215. }
  72216. /**
  72217. * Configures the navigation mesh creation
  72218. */
  72219. export interface INavMeshParameters {
  72220. /**
  72221. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  72222. */
  72223. cs: number;
  72224. /**
  72225. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  72226. */
  72227. ch: number;
  72228. /**
  72229. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  72230. */
  72231. walkableSlopeAngle: number;
  72232. /**
  72233. * Minimum floor to 'ceiling' height that will still allow the floor area to
  72234. * be considered walkable. [Limit: >= 3] [Units: vx]
  72235. */
  72236. walkableHeight: number;
  72237. /**
  72238. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  72239. */
  72240. walkableClimb: number;
  72241. /**
  72242. * The distance to erode/shrink the walkable area of the heightfield away from
  72243. * obstructions. [Limit: >=0] [Units: vx]
  72244. */
  72245. walkableRadius: number;
  72246. /**
  72247. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  72248. */
  72249. maxEdgeLen: number;
  72250. /**
  72251. * The maximum distance a simplified contour's border edges should deviate
  72252. * the original raw contour. [Limit: >=0] [Units: vx]
  72253. */
  72254. maxSimplificationError: number;
  72255. /**
  72256. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  72257. */
  72258. minRegionArea: number;
  72259. /**
  72260. * Any regions with a span count smaller than this value will, if possible,
  72261. * be merged with larger regions. [Limit: >=0] [Units: vx]
  72262. */
  72263. mergeRegionArea: number;
  72264. /**
  72265. * The maximum number of vertices allowed for polygons generated during the
  72266. * contour to polygon conversion process. [Limit: >= 3]
  72267. */
  72268. maxVertsPerPoly: number;
  72269. /**
  72270. * Sets the sampling distance to use when generating the detail mesh.
  72271. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  72272. */
  72273. detailSampleDist: number;
  72274. /**
  72275. * The maximum distance the detail mesh surface should deviate from heightfield
  72276. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  72277. */
  72278. detailSampleMaxError: number;
  72279. }
  72280. }
  72281. declare module BABYLON {
  72282. /**
  72283. * RecastJS navigation plugin
  72284. */
  72285. export class RecastJSPlugin implements INavigationEnginePlugin {
  72286. /**
  72287. * Reference to the Recast library
  72288. */
  72289. bjsRECAST: any;
  72290. /**
  72291. * plugin name
  72292. */
  72293. name: string;
  72294. /**
  72295. * the first navmesh created. We might extend this to support multiple navmeshes
  72296. */
  72297. navMesh: any;
  72298. private _maximumSubStepCount;
  72299. private _timeStep;
  72300. /**
  72301. * Initializes the recastJS plugin
  72302. * @param recastInjection can be used to inject your own recast reference
  72303. */
  72304. constructor(recastInjection?: any);
  72305. /**
  72306. * Set the time step of the navigation tick update.
  72307. * Default is 1/60.
  72308. * A value of 0 will disable fixed time update
  72309. * @param newTimeStep the new timestep to apply to this world.
  72310. */
  72311. setTimeStep(newTimeStep?: number): void;
  72312. /**
  72313. * Get the time step of the navigation tick update.
  72314. * @returns the current time step
  72315. */
  72316. getTimeStep(): number;
  72317. /**
  72318. * If delta time in navigation tick update is greater than the time step
  72319. * a number of sub iterations are done. If more iterations are need to reach deltatime
  72320. * they will be discarded.
  72321. * A value of 0 will set to no maximum and update will use as many substeps as needed
  72322. * @param newStepCount the maximum number of iterations
  72323. */
  72324. setMaximumSubStepCount(newStepCount?: number): void;
  72325. /**
  72326. * Get the maximum number of iterations per navigation tick update
  72327. * @returns the maximum number of iterations
  72328. */
  72329. getMaximumSubStepCount(): number;
  72330. /**
  72331. * Creates a navigation mesh
  72332. * @param meshes array of all the geometry used to compute the navigation mesh
  72333. * @param parameters bunch of parameters used to filter geometry
  72334. */
  72335. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  72336. /**
  72337. * Create a navigation mesh debug mesh
  72338. * @param scene is where the mesh will be added
  72339. * @returns debug display mesh
  72340. */
  72341. createDebugNavMesh(scene: Scene): Mesh;
  72342. /**
  72343. * Get a navigation mesh constrained position, closest to the parameter position
  72344. * @param position world position
  72345. * @returns the closest point to position constrained by the navigation mesh
  72346. */
  72347. getClosestPoint(position: Vector3): Vector3;
  72348. /**
  72349. * Get a navigation mesh constrained position, closest to the parameter position
  72350. * @param position world position
  72351. * @param result output the closest point to position constrained by the navigation mesh
  72352. */
  72353. getClosestPointToRef(position: Vector3, result: Vector3): void;
  72354. /**
  72355. * Get a navigation mesh constrained position, within a particular radius
  72356. * @param position world position
  72357. * @param maxRadius the maximum distance to the constrained world position
  72358. * @returns the closest point to position constrained by the navigation mesh
  72359. */
  72360. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  72361. /**
  72362. * Get a navigation mesh constrained position, within a particular radius
  72363. * @param position world position
  72364. * @param maxRadius the maximum distance to the constrained world position
  72365. * @param result output the closest point to position constrained by the navigation mesh
  72366. */
  72367. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  72368. /**
  72369. * Compute the final position from a segment made of destination-position
  72370. * @param position world position
  72371. * @param destination world position
  72372. * @returns the resulting point along the navmesh
  72373. */
  72374. moveAlong(position: Vector3, destination: Vector3): Vector3;
  72375. /**
  72376. * Compute the final position from a segment made of destination-position
  72377. * @param position world position
  72378. * @param destination world position
  72379. * @param result output the resulting point along the navmesh
  72380. */
  72381. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  72382. /**
  72383. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  72384. * @param start world position
  72385. * @param end world position
  72386. * @returns array containing world position composing the path
  72387. */
  72388. computePath(start: Vector3, end: Vector3): Vector3[];
  72389. /**
  72390. * Create a new Crowd so you can add agents
  72391. * @param maxAgents the maximum agent count in the crowd
  72392. * @param maxAgentRadius the maximum radius an agent can have
  72393. * @param scene to attach the crowd to
  72394. * @returns the crowd you can add agents to
  72395. */
  72396. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  72397. /**
  72398. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  72399. * The queries will try to find a solution within those bounds
  72400. * default is (1,1,1)
  72401. * @param extent x,y,z value that define the extent around the queries point of reference
  72402. */
  72403. setDefaultQueryExtent(extent: Vector3): void;
  72404. /**
  72405. * Get the Bounding box extent specified by setDefaultQueryExtent
  72406. * @returns the box extent values
  72407. */
  72408. getDefaultQueryExtent(): Vector3;
  72409. /**
  72410. * build the navmesh from a previously saved state using getNavmeshData
  72411. * @param data the Uint8Array returned by getNavmeshData
  72412. */
  72413. buildFromNavmeshData(data: Uint8Array): void;
  72414. /**
  72415. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  72416. * @returns data the Uint8Array that can be saved and reused
  72417. */
  72418. getNavmeshData(): Uint8Array;
  72419. /**
  72420. * Get the Bounding box extent result specified by setDefaultQueryExtent
  72421. * @param result output the box extent values
  72422. */
  72423. getDefaultQueryExtentToRef(result: Vector3): void;
  72424. /**
  72425. * Disposes
  72426. */
  72427. dispose(): void;
  72428. /**
  72429. * If this plugin is supported
  72430. * @returns true if plugin is supported
  72431. */
  72432. isSupported(): boolean;
  72433. }
  72434. /**
  72435. * Recast detour crowd implementation
  72436. */
  72437. export class RecastJSCrowd implements ICrowd {
  72438. /**
  72439. * Recast/detour plugin
  72440. */
  72441. bjsRECASTPlugin: RecastJSPlugin;
  72442. /**
  72443. * Link to the detour crowd
  72444. */
  72445. recastCrowd: any;
  72446. /**
  72447. * One transform per agent
  72448. */
  72449. transforms: TransformNode[];
  72450. /**
  72451. * All agents created
  72452. */
  72453. agents: number[];
  72454. /**
  72455. * Link to the scene is kept to unregister the crowd from the scene
  72456. */
  72457. private _scene;
  72458. /**
  72459. * Observer for crowd updates
  72460. */
  72461. private _onBeforeAnimationsObserver;
  72462. /**
  72463. * Constructor
  72464. * @param plugin recastJS plugin
  72465. * @param maxAgents the maximum agent count in the crowd
  72466. * @param maxAgentRadius the maximum radius an agent can have
  72467. * @param scene to attach the crowd to
  72468. * @returns the crowd you can add agents to
  72469. */
  72470. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  72471. /**
  72472. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  72473. * You can attach anything to that node. The node position is updated in the scene update tick.
  72474. * @param pos world position that will be constrained by the navigation mesh
  72475. * @param parameters agent parameters
  72476. * @param transform hooked to the agent that will be update by the scene
  72477. * @returns agent index
  72478. */
  72479. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  72480. /**
  72481. * Returns the agent position in world space
  72482. * @param index agent index returned by addAgent
  72483. * @returns world space position
  72484. */
  72485. getAgentPosition(index: number): Vector3;
  72486. /**
  72487. * Returns the agent position result in world space
  72488. * @param index agent index returned by addAgent
  72489. * @param result output world space position
  72490. */
  72491. getAgentPositionToRef(index: number, result: Vector3): void;
  72492. /**
  72493. * Returns the agent velocity in world space
  72494. * @param index agent index returned by addAgent
  72495. * @returns world space velocity
  72496. */
  72497. getAgentVelocity(index: number): Vector3;
  72498. /**
  72499. * Returns the agent velocity result in world space
  72500. * @param index agent index returned by addAgent
  72501. * @param result output world space velocity
  72502. */
  72503. getAgentVelocityToRef(index: number, result: Vector3): void;
  72504. /**
  72505. * Returns the agent next target point on the path
  72506. * @param index agent index returned by addAgent
  72507. * @returns world space position
  72508. */
  72509. getAgentNextTargetPath(index: number): Vector3;
  72510. /**
  72511. * Returns the agent next target point on the path
  72512. * @param index agent index returned by addAgent
  72513. * @param result output world space position
  72514. */
  72515. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  72516. /**
  72517. * Gets the agent state
  72518. * @param index agent index returned by addAgent
  72519. * @returns agent state
  72520. */
  72521. getAgentState(index: number): number;
  72522. /**
  72523. * returns true if the agent in over an off mesh link connection
  72524. * @param index agent index returned by addAgent
  72525. * @returns true if over an off mesh link connection
  72526. */
  72527. overOffmeshConnection(index: number): boolean;
  72528. /**
  72529. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  72530. * @param index agent index returned by addAgent
  72531. * @param destination targeted world position
  72532. */
  72533. agentGoto(index: number, destination: Vector3): void;
  72534. /**
  72535. * Teleport the agent to a new position
  72536. * @param index agent index returned by addAgent
  72537. * @param destination targeted world position
  72538. */
  72539. agentTeleport(index: number, destination: Vector3): void;
  72540. /**
  72541. * Update agent parameters
  72542. * @param index agent index returned by addAgent
  72543. * @param parameters agent parameters
  72544. */
  72545. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  72546. /**
  72547. * remove a particular agent previously created
  72548. * @param index agent index returned by addAgent
  72549. */
  72550. removeAgent(index: number): void;
  72551. /**
  72552. * get the list of all agents attached to this crowd
  72553. * @returns list of agent indices
  72554. */
  72555. getAgents(): number[];
  72556. /**
  72557. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  72558. * @param deltaTime in seconds
  72559. */
  72560. update(deltaTime: number): void;
  72561. /**
  72562. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  72563. * The queries will try to find a solution within those bounds
  72564. * default is (1,1,1)
  72565. * @param extent x,y,z value that define the extent around the queries point of reference
  72566. */
  72567. setDefaultQueryExtent(extent: Vector3): void;
  72568. /**
  72569. * Get the Bounding box extent specified by setDefaultQueryExtent
  72570. * @returns the box extent values
  72571. */
  72572. getDefaultQueryExtent(): Vector3;
  72573. /**
  72574. * Get the Bounding box extent result specified by setDefaultQueryExtent
  72575. * @param result output the box extent values
  72576. */
  72577. getDefaultQueryExtentToRef(result: Vector3): void;
  72578. /**
  72579. * Release all resources
  72580. */
  72581. dispose(): void;
  72582. }
  72583. }
  72584. declare module BABYLON {
  72585. /**
  72586. * Class used to enable access to IndexedDB
  72587. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  72588. */
  72589. export class Database implements IOfflineProvider {
  72590. private _callbackManifestChecked;
  72591. private _currentSceneUrl;
  72592. private _db;
  72593. private _enableSceneOffline;
  72594. private _enableTexturesOffline;
  72595. private _manifestVersionFound;
  72596. private _mustUpdateRessources;
  72597. private _hasReachedQuota;
  72598. private _isSupported;
  72599. private _idbFactory;
  72600. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  72601. private static IsUASupportingBlobStorage;
  72602. /**
  72603. * Gets a boolean indicating if Database storage is enabled (off by default)
  72604. */
  72605. static IDBStorageEnabled: boolean;
  72606. /**
  72607. * Gets a boolean indicating if scene must be saved in the database
  72608. */
  72609. get enableSceneOffline(): boolean;
  72610. /**
  72611. * Gets a boolean indicating if textures must be saved in the database
  72612. */
  72613. get enableTexturesOffline(): boolean;
  72614. /**
  72615. * Creates a new Database
  72616. * @param urlToScene defines the url to load the scene
  72617. * @param callbackManifestChecked defines the callback to use when manifest is checked
  72618. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  72619. */
  72620. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  72621. private static _ParseURL;
  72622. private static _ReturnFullUrlLocation;
  72623. private _checkManifestFile;
  72624. /**
  72625. * Open the database and make it available
  72626. * @param successCallback defines the callback to call on success
  72627. * @param errorCallback defines the callback to call on error
  72628. */
  72629. open(successCallback: () => void, errorCallback: () => void): void;
  72630. /**
  72631. * Loads an image from the database
  72632. * @param url defines the url to load from
  72633. * @param image defines the target DOM image
  72634. */
  72635. loadImage(url: string, image: HTMLImageElement): void;
  72636. private _loadImageFromDBAsync;
  72637. private _saveImageIntoDBAsync;
  72638. private _checkVersionFromDB;
  72639. private _loadVersionFromDBAsync;
  72640. private _saveVersionIntoDBAsync;
  72641. /**
  72642. * Loads a file from database
  72643. * @param url defines the URL to load from
  72644. * @param sceneLoaded defines a callback to call on success
  72645. * @param progressCallBack defines a callback to call when progress changed
  72646. * @param errorCallback defines a callback to call on error
  72647. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  72648. */
  72649. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  72650. private _loadFileAsync;
  72651. private _saveFileAsync;
  72652. /**
  72653. * Validates if xhr data is correct
  72654. * @param xhr defines the request to validate
  72655. * @param dataType defines the expected data type
  72656. * @returns true if data is correct
  72657. */
  72658. private static _ValidateXHRData;
  72659. }
  72660. }
  72661. declare module BABYLON {
  72662. /** @hidden */
  72663. export var gpuUpdateParticlesPixelShader: {
  72664. name: string;
  72665. shader: string;
  72666. };
  72667. }
  72668. declare module BABYLON {
  72669. /** @hidden */
  72670. export var gpuUpdateParticlesVertexShader: {
  72671. name: string;
  72672. shader: string;
  72673. };
  72674. }
  72675. declare module BABYLON {
  72676. /** @hidden */
  72677. export var clipPlaneFragmentDeclaration2: {
  72678. name: string;
  72679. shader: string;
  72680. };
  72681. }
  72682. declare module BABYLON {
  72683. /** @hidden */
  72684. export var gpuRenderParticlesPixelShader: {
  72685. name: string;
  72686. shader: string;
  72687. };
  72688. }
  72689. declare module BABYLON {
  72690. /** @hidden */
  72691. export var clipPlaneVertexDeclaration2: {
  72692. name: string;
  72693. shader: string;
  72694. };
  72695. }
  72696. declare module BABYLON {
  72697. /** @hidden */
  72698. export var gpuRenderParticlesVertexShader: {
  72699. name: string;
  72700. shader: string;
  72701. };
  72702. }
  72703. declare module BABYLON {
  72704. /**
  72705. * This represents a GPU particle system in Babylon
  72706. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  72707. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  72708. */
  72709. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  72710. /**
  72711. * The layer mask we are rendering the particles through.
  72712. */
  72713. layerMask: number;
  72714. private _capacity;
  72715. private _activeCount;
  72716. private _currentActiveCount;
  72717. private _accumulatedCount;
  72718. private _renderEffect;
  72719. private _updateEffect;
  72720. private _buffer0;
  72721. private _buffer1;
  72722. private _spriteBuffer;
  72723. private _updateVAO;
  72724. private _renderVAO;
  72725. private _targetIndex;
  72726. private _sourceBuffer;
  72727. private _targetBuffer;
  72728. private _currentRenderId;
  72729. private _started;
  72730. private _stopped;
  72731. private _timeDelta;
  72732. private _randomTexture;
  72733. private _randomTexture2;
  72734. private _attributesStrideSize;
  72735. private _updateEffectOptions;
  72736. private _randomTextureSize;
  72737. private _actualFrame;
  72738. private _customEffect;
  72739. private readonly _rawTextureWidth;
  72740. /**
  72741. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  72742. */
  72743. static get IsSupported(): boolean;
  72744. /**
  72745. * An event triggered when the system is disposed.
  72746. */
  72747. onDisposeObservable: Observable<IParticleSystem>;
  72748. /**
  72749. * An event triggered when the system is stopped
  72750. */
  72751. onStoppedObservable: Observable<IParticleSystem>;
  72752. /**
  72753. * Gets the maximum number of particles active at the same time.
  72754. * @returns The max number of active particles.
  72755. */
  72756. getCapacity(): number;
  72757. /**
  72758. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  72759. * to override the particles.
  72760. */
  72761. forceDepthWrite: boolean;
  72762. /**
  72763. * Gets or set the number of active particles
  72764. */
  72765. get activeParticleCount(): number;
  72766. set activeParticleCount(value: number);
  72767. private _preWarmDone;
  72768. /**
  72769. * Specifies if the particles are updated in emitter local space or world space.
  72770. */
  72771. isLocal: boolean;
  72772. /** Gets or sets a matrix to use to compute projection */
  72773. defaultProjectionMatrix: Matrix;
  72774. /**
  72775. * Is this system ready to be used/rendered
  72776. * @return true if the system is ready
  72777. */
  72778. isReady(): boolean;
  72779. /**
  72780. * Gets if the system has been started. (Note: this will still be true after stop is called)
  72781. * @returns True if it has been started, otherwise false.
  72782. */
  72783. isStarted(): boolean;
  72784. /**
  72785. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  72786. * @returns True if it has been stopped, otherwise false.
  72787. */
  72788. isStopped(): boolean;
  72789. /**
  72790. * Gets a boolean indicating that the system is stopping
  72791. * @returns true if the system is currently stopping
  72792. */
  72793. isStopping(): boolean;
  72794. /**
  72795. * Gets the number of particles active at the same time.
  72796. * @returns The number of active particles.
  72797. */
  72798. getActiveCount(): number;
  72799. /**
  72800. * Starts the particle system and begins to emit
  72801. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  72802. */
  72803. start(delay?: number): void;
  72804. /**
  72805. * Stops the particle system.
  72806. */
  72807. stop(): void;
  72808. /**
  72809. * Remove all active particles
  72810. */
  72811. reset(): void;
  72812. /**
  72813. * Returns the string "GPUParticleSystem"
  72814. * @returns a string containing the class name
  72815. */
  72816. getClassName(): string;
  72817. /**
  72818. * Gets the custom effect used to render the particles
  72819. * @param blendMode Blend mode for which the effect should be retrieved
  72820. * @returns The effect
  72821. */
  72822. getCustomEffect(blendMode?: number): Nullable<Effect>;
  72823. /**
  72824. * Sets the custom effect used to render the particles
  72825. * @param effect The effect to set
  72826. * @param blendMode Blend mode for which the effect should be set
  72827. */
  72828. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  72829. /** @hidden */
  72830. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  72831. /**
  72832. * Observable that will be called just before the particles are drawn
  72833. */
  72834. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  72835. /**
  72836. * Gets the name of the particle vertex shader
  72837. */
  72838. get vertexShaderName(): string;
  72839. private _colorGradientsTexture;
  72840. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  72841. /**
  72842. * Adds a new color gradient
  72843. * @param gradient defines the gradient to use (between 0 and 1)
  72844. * @param color1 defines the color to affect to the specified gradient
  72845. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  72846. * @returns the current particle system
  72847. */
  72848. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  72849. private _refreshColorGradient;
  72850. /** Force the system to rebuild all gradients that need to be resync */
  72851. forceRefreshGradients(): void;
  72852. /**
  72853. * Remove a specific color gradient
  72854. * @param gradient defines the gradient to remove
  72855. * @returns the current particle system
  72856. */
  72857. removeColorGradient(gradient: number): GPUParticleSystem;
  72858. private _angularSpeedGradientsTexture;
  72859. private _sizeGradientsTexture;
  72860. private _velocityGradientsTexture;
  72861. private _limitVelocityGradientsTexture;
  72862. private _dragGradientsTexture;
  72863. private _addFactorGradient;
  72864. /**
  72865. * Adds a new size gradient
  72866. * @param gradient defines the gradient to use (between 0 and 1)
  72867. * @param factor defines the size factor to affect to the specified gradient
  72868. * @returns the current particle system
  72869. */
  72870. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  72871. /**
  72872. * Remove a specific size gradient
  72873. * @param gradient defines the gradient to remove
  72874. * @returns the current particle system
  72875. */
  72876. removeSizeGradient(gradient: number): GPUParticleSystem;
  72877. private _refreshFactorGradient;
  72878. /**
  72879. * Adds a new angular speed gradient
  72880. * @param gradient defines the gradient to use (between 0 and 1)
  72881. * @param factor defines the angular speed to affect to the specified gradient
  72882. * @returns the current particle system
  72883. */
  72884. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  72885. /**
  72886. * Remove a specific angular speed gradient
  72887. * @param gradient defines the gradient to remove
  72888. * @returns the current particle system
  72889. */
  72890. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  72891. /**
  72892. * Adds a new velocity gradient
  72893. * @param gradient defines the gradient to use (between 0 and 1)
  72894. * @param factor defines the velocity to affect to the specified gradient
  72895. * @returns the current particle system
  72896. */
  72897. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  72898. /**
  72899. * Remove a specific velocity gradient
  72900. * @param gradient defines the gradient to remove
  72901. * @returns the current particle system
  72902. */
  72903. removeVelocityGradient(gradient: number): GPUParticleSystem;
  72904. /**
  72905. * Adds a new limit velocity gradient
  72906. * @param gradient defines the gradient to use (between 0 and 1)
  72907. * @param factor defines the limit velocity value to affect to the specified gradient
  72908. * @returns the current particle system
  72909. */
  72910. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  72911. /**
  72912. * Remove a specific limit velocity gradient
  72913. * @param gradient defines the gradient to remove
  72914. * @returns the current particle system
  72915. */
  72916. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  72917. /**
  72918. * Adds a new drag gradient
  72919. * @param gradient defines the gradient to use (between 0 and 1)
  72920. * @param factor defines the drag value to affect to the specified gradient
  72921. * @returns the current particle system
  72922. */
  72923. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  72924. /**
  72925. * Remove a specific drag gradient
  72926. * @param gradient defines the gradient to remove
  72927. * @returns the current particle system
  72928. */
  72929. removeDragGradient(gradient: number): GPUParticleSystem;
  72930. /**
  72931. * Not supported by GPUParticleSystem
  72932. * @param gradient defines the gradient to use (between 0 and 1)
  72933. * @param factor defines the emit rate value to affect to the specified gradient
  72934. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72935. * @returns the current particle system
  72936. */
  72937. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72938. /**
  72939. * Not supported by GPUParticleSystem
  72940. * @param gradient defines the gradient to remove
  72941. * @returns the current particle system
  72942. */
  72943. removeEmitRateGradient(gradient: number): IParticleSystem;
  72944. /**
  72945. * Not supported by GPUParticleSystem
  72946. * @param gradient defines the gradient to use (between 0 and 1)
  72947. * @param factor defines the start size value to affect to the specified gradient
  72948. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72949. * @returns the current particle system
  72950. */
  72951. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72952. /**
  72953. * Not supported by GPUParticleSystem
  72954. * @param gradient defines the gradient to remove
  72955. * @returns the current particle system
  72956. */
  72957. removeStartSizeGradient(gradient: number): IParticleSystem;
  72958. /**
  72959. * Not supported by GPUParticleSystem
  72960. * @param gradient defines the gradient to use (between 0 and 1)
  72961. * @param min defines the color remap minimal range
  72962. * @param max defines the color remap maximal range
  72963. * @returns the current particle system
  72964. */
  72965. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72966. /**
  72967. * Not supported by GPUParticleSystem
  72968. * @param gradient defines the gradient to remove
  72969. * @returns the current particle system
  72970. */
  72971. removeColorRemapGradient(): IParticleSystem;
  72972. /**
  72973. * Not supported by GPUParticleSystem
  72974. * @param gradient defines the gradient to use (between 0 and 1)
  72975. * @param min defines the alpha remap minimal range
  72976. * @param max defines the alpha remap maximal range
  72977. * @returns the current particle system
  72978. */
  72979. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72980. /**
  72981. * Not supported by GPUParticleSystem
  72982. * @param gradient defines the gradient to remove
  72983. * @returns the current particle system
  72984. */
  72985. removeAlphaRemapGradient(): IParticleSystem;
  72986. /**
  72987. * Not supported by GPUParticleSystem
  72988. * @param gradient defines the gradient to use (between 0 and 1)
  72989. * @param color defines the color to affect to the specified gradient
  72990. * @returns the current particle system
  72991. */
  72992. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  72993. /**
  72994. * Not supported by GPUParticleSystem
  72995. * @param gradient defines the gradient to remove
  72996. * @returns the current particle system
  72997. */
  72998. removeRampGradient(): IParticleSystem;
  72999. /**
  73000. * Not supported by GPUParticleSystem
  73001. * @returns the list of ramp gradients
  73002. */
  73003. getRampGradients(): Nullable<Array<Color3Gradient>>;
  73004. /**
  73005. * Not supported by GPUParticleSystem
  73006. * Gets or sets a boolean indicating that ramp gradients must be used
  73007. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  73008. */
  73009. get useRampGradients(): boolean;
  73010. set useRampGradients(value: boolean);
  73011. /**
  73012. * Not supported by GPUParticleSystem
  73013. * @param gradient defines the gradient to use (between 0 and 1)
  73014. * @param factor defines the life time factor to affect to the specified gradient
  73015. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73016. * @returns the current particle system
  73017. */
  73018. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73019. /**
  73020. * Not supported by GPUParticleSystem
  73021. * @param gradient defines the gradient to remove
  73022. * @returns the current particle system
  73023. */
  73024. removeLifeTimeGradient(gradient: number): IParticleSystem;
  73025. /**
  73026. * Instantiates a GPU particle system.
  73027. * 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.
  73028. * @param name The name of the particle system
  73029. * @param options The options used to create the system
  73030. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  73031. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  73032. * @param customEffect a custom effect used to change the way particles are rendered by default
  73033. */
  73034. constructor(name: string, options: Partial<{
  73035. capacity: number;
  73036. randomTextureSize: number;
  73037. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  73038. protected _reset(): void;
  73039. private _createUpdateVAO;
  73040. private _createRenderVAO;
  73041. private _initialize;
  73042. /** @hidden */
  73043. _recreateUpdateEffect(): void;
  73044. private _getEffect;
  73045. /**
  73046. * Fill the defines array according to the current settings of the particle system
  73047. * @param defines Array to be updated
  73048. * @param blendMode blend mode to take into account when updating the array
  73049. */
  73050. fillDefines(defines: Array<string>, blendMode?: number): void;
  73051. /**
  73052. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  73053. * @param uniforms Uniforms array to fill
  73054. * @param attributes Attributes array to fill
  73055. * @param samplers Samplers array to fill
  73056. */
  73057. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  73058. /** @hidden */
  73059. _recreateRenderEffect(): Effect;
  73060. /**
  73061. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  73062. * @param preWarm defines if we are in the pre-warmimg phase
  73063. */
  73064. animate(preWarm?: boolean): void;
  73065. private _createFactorGradientTexture;
  73066. private _createSizeGradientTexture;
  73067. private _createAngularSpeedGradientTexture;
  73068. private _createVelocityGradientTexture;
  73069. private _createLimitVelocityGradientTexture;
  73070. private _createDragGradientTexture;
  73071. private _createColorGradientTexture;
  73072. /**
  73073. * Renders the particle system in its current state
  73074. * @param preWarm defines if the system should only update the particles but not render them
  73075. * @returns the current number of particles
  73076. */
  73077. render(preWarm?: boolean): number;
  73078. /**
  73079. * Rebuilds the particle system
  73080. */
  73081. rebuild(): void;
  73082. private _releaseBuffers;
  73083. private _releaseVAOs;
  73084. /**
  73085. * Disposes the particle system and free the associated resources
  73086. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  73087. */
  73088. dispose(disposeTexture?: boolean): void;
  73089. /**
  73090. * Clones the particle system.
  73091. * @param name The name of the cloned object
  73092. * @param newEmitter The new emitter to use
  73093. * @returns the cloned particle system
  73094. */
  73095. clone(name: string, newEmitter: any): GPUParticleSystem;
  73096. /**
  73097. * Serializes the particle system to a JSON object
  73098. * @param serializeTexture defines if the texture must be serialized as well
  73099. * @returns the JSON object
  73100. */
  73101. serialize(serializeTexture?: boolean): any;
  73102. /**
  73103. * Parses a JSON object to create a GPU particle system.
  73104. * @param parsedParticleSystem The JSON object to parse
  73105. * @param sceneOrEngine The scene or the engine to create the particle system in
  73106. * @param rootUrl The root url to use to load external dependencies like texture
  73107. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  73108. * @returns the parsed GPU particle system
  73109. */
  73110. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  73111. }
  73112. }
  73113. declare module BABYLON {
  73114. /**
  73115. * Represents a set of particle systems working together to create a specific effect
  73116. */
  73117. export class ParticleSystemSet implements IDisposable {
  73118. /**
  73119. * Gets or sets base Assets URL
  73120. */
  73121. static BaseAssetsUrl: string;
  73122. private _emitterCreationOptions;
  73123. private _emitterNode;
  73124. /**
  73125. * Gets the particle system list
  73126. */
  73127. systems: IParticleSystem[];
  73128. /**
  73129. * Gets the emitter node used with this set
  73130. */
  73131. get emitterNode(): Nullable<TransformNode>;
  73132. /**
  73133. * Creates a new emitter mesh as a sphere
  73134. * @param options defines the options used to create the sphere
  73135. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  73136. * @param scene defines the hosting scene
  73137. */
  73138. setEmitterAsSphere(options: {
  73139. diameter: number;
  73140. segments: number;
  73141. color: Color3;
  73142. }, renderingGroupId: number, scene: Scene): void;
  73143. /**
  73144. * Starts all particle systems of the set
  73145. * @param emitter defines an optional mesh to use as emitter for the particle systems
  73146. */
  73147. start(emitter?: AbstractMesh): void;
  73148. /**
  73149. * Release all associated resources
  73150. */
  73151. dispose(): void;
  73152. /**
  73153. * Serialize the set into a JSON compatible object
  73154. * @param serializeTexture defines if the texture must be serialized as well
  73155. * @returns a JSON compatible representation of the set
  73156. */
  73157. serialize(serializeTexture?: boolean): any;
  73158. /**
  73159. * Parse a new ParticleSystemSet from a serialized source
  73160. * @param data defines a JSON compatible representation of the set
  73161. * @param scene defines the hosting scene
  73162. * @param gpu defines if we want GPU particles or CPU particles
  73163. * @returns a new ParticleSystemSet
  73164. */
  73165. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  73166. }
  73167. }
  73168. declare module BABYLON {
  73169. /**
  73170. * This class is made for on one-liner static method to help creating particle system set.
  73171. */
  73172. export class ParticleHelper {
  73173. /**
  73174. * Gets or sets base Assets URL
  73175. */
  73176. static BaseAssetsUrl: string;
  73177. /** Define the Url to load snippets */
  73178. static SnippetUrl: string;
  73179. /**
  73180. * Create a default particle system that you can tweak
  73181. * @param emitter defines the emitter to use
  73182. * @param capacity defines the system capacity (default is 500 particles)
  73183. * @param scene defines the hosting scene
  73184. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  73185. * @returns the new Particle system
  73186. */
  73187. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  73188. /**
  73189. * This is the main static method (one-liner) of this helper to create different particle systems
  73190. * @param type This string represents the type to the particle system to create
  73191. * @param scene The scene where the particle system should live
  73192. * @param gpu If the system will use gpu
  73193. * @returns the ParticleSystemSet created
  73194. */
  73195. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  73196. /**
  73197. * Static function used to export a particle system to a ParticleSystemSet variable.
  73198. * Please note that the emitter shape is not exported
  73199. * @param systems defines the particle systems to export
  73200. * @returns the created particle system set
  73201. */
  73202. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  73203. /**
  73204. * Creates a particle system from a snippet saved in a remote file
  73205. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  73206. * @param url defines the url to load from
  73207. * @param scene defines the hosting scene
  73208. * @param gpu If the system will use gpu
  73209. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  73210. * @returns a promise that will resolve to the new particle system
  73211. */
  73212. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  73213. /**
  73214. * Creates a particle system from a snippet saved by the particle system editor
  73215. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  73216. * @param scene defines the hosting scene
  73217. * @param gpu If the system will use gpu
  73218. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  73219. * @returns a promise that will resolve to the new particle system
  73220. */
  73221. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  73222. }
  73223. }
  73224. declare module BABYLON {
  73225. interface Engine {
  73226. /**
  73227. * Create an effect to use with particle systems.
  73228. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  73229. * the particle system for which you want to create a custom effect in the last parameter
  73230. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  73231. * @param uniformsNames defines a list of attribute names
  73232. * @param samplers defines an array of string used to represent textures
  73233. * @param defines defines the string containing the defines to use to compile the shaders
  73234. * @param fallbacks defines the list of potential fallbacks to use if shader compilation fails
  73235. * @param onCompiled defines a function to call when the effect creation is successful
  73236. * @param onError defines a function to call when the effect creation has failed
  73237. * @param particleSystem the particle system you want to create the effect for
  73238. * @returns the new Effect
  73239. */
  73240. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  73241. }
  73242. interface Mesh {
  73243. /**
  73244. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  73245. * @returns an array of IParticleSystem
  73246. */
  73247. getEmittedParticleSystems(): IParticleSystem[];
  73248. /**
  73249. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  73250. * @returns an array of IParticleSystem
  73251. */
  73252. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  73253. }
  73254. }
  73255. declare module BABYLON {
  73256. /** Defines the 4 color options */
  73257. export enum PointColor {
  73258. /** color value */
  73259. Color = 2,
  73260. /** uv value */
  73261. UV = 1,
  73262. /** random value */
  73263. Random = 0,
  73264. /** stated value */
  73265. Stated = 3
  73266. }
  73267. /**
  73268. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  73269. * 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.
  73270. * The PointCloudSystem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  73271. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  73272. *
  73273. * Full documentation here : TO BE ENTERED
  73274. */
  73275. export class PointsCloudSystem implements IDisposable {
  73276. /**
  73277. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  73278. * Example : var p = SPS.particles[i];
  73279. */
  73280. particles: CloudPoint[];
  73281. /**
  73282. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  73283. */
  73284. nbParticles: number;
  73285. /**
  73286. * This a counter for your own usage. It's not set by any SPS functions.
  73287. */
  73288. counter: number;
  73289. /**
  73290. * The PCS name. This name is also given to the underlying mesh.
  73291. */
  73292. name: string;
  73293. /**
  73294. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are available.
  73295. */
  73296. mesh: Mesh;
  73297. /**
  73298. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  73299. * Please read :
  73300. */
  73301. vars: any;
  73302. /**
  73303. * @hidden
  73304. */
  73305. _size: number;
  73306. private _scene;
  73307. private _promises;
  73308. private _positions;
  73309. private _indices;
  73310. private _normals;
  73311. private _colors;
  73312. private _uvs;
  73313. private _indices32;
  73314. private _positions32;
  73315. private _colors32;
  73316. private _uvs32;
  73317. private _updatable;
  73318. private _isVisibilityBoxLocked;
  73319. private _alwaysVisible;
  73320. private _groups;
  73321. private _groupCounter;
  73322. private _computeParticleColor;
  73323. private _computeParticleTexture;
  73324. private _computeParticleRotation;
  73325. private _computeBoundingBox;
  73326. private _isReady;
  73327. /**
  73328. * Creates a PCS (Points Cloud System) object
  73329. * @param name (String) is the PCS name, this will be the underlying mesh name
  73330. * @param pointSize (number) is the size for each point
  73331. * @param scene (Scene) is the scene in which the PCS is added
  73332. * @param options defines the options of the PCS e.g.
  73333. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  73334. */
  73335. constructor(name: string, pointSize: number, scene: Scene, options?: {
  73336. updatable?: boolean;
  73337. });
  73338. /**
  73339. * Builds the PCS underlying mesh. Returns a standard Mesh.
  73340. * If no points were added to the PCS, the returned mesh is just a single point.
  73341. * @returns a promise for the created mesh
  73342. */
  73343. buildMeshAsync(): Promise<Mesh>;
  73344. /**
  73345. * @hidden
  73346. */
  73347. private _buildMesh;
  73348. private _addParticle;
  73349. private _randomUnitVector;
  73350. private _getColorIndicesForCoord;
  73351. private _setPointsColorOrUV;
  73352. private _colorFromTexture;
  73353. private _calculateDensity;
  73354. /**
  73355. * Adds points to the PCS in random positions within a unit sphere
  73356. * @param nb (positive integer) the number of particles to be created from this model
  73357. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  73358. * @returns the number of groups in the system
  73359. */
  73360. addPoints(nb: number, pointFunction?: any): number;
  73361. /**
  73362. * Adds points to the PCS from the surface of the model shape
  73363. * @param mesh is any Mesh object that will be used as a surface model for the points
  73364. * @param nb (positive integer) the number of particles to be created from this model
  73365. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  73366. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  73367. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  73368. * @returns the number of groups in the system
  73369. */
  73370. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  73371. /**
  73372. * Adds points to the PCS inside the model shape
  73373. * @param mesh is any Mesh object that will be used as a surface model for the points
  73374. * @param nb (positive integer) the number of particles to be created from this model
  73375. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  73376. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  73377. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  73378. * @returns the number of groups in the system
  73379. */
  73380. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  73381. /**
  73382. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  73383. * This method calls `updateParticle()` for each particle of the SPS.
  73384. * For an animated SPS, it is usually called within the render loop.
  73385. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  73386. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  73387. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  73388. * @returns the PCS.
  73389. */
  73390. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  73391. /**
  73392. * Disposes the PCS.
  73393. */
  73394. dispose(): void;
  73395. /**
  73396. * Visibility helper : Recomputes the visible size according to the mesh bounding box
  73397. * doc :
  73398. * @returns the PCS.
  73399. */
  73400. refreshVisibleSize(): PointsCloudSystem;
  73401. /**
  73402. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  73403. * @param size the size (float) of the visibility box
  73404. * note : this doesn't lock the PCS mesh bounding box.
  73405. * doc :
  73406. */
  73407. setVisibilityBox(size: number): void;
  73408. /**
  73409. * Gets whether the PCS is always visible or not
  73410. * doc :
  73411. */
  73412. get isAlwaysVisible(): boolean;
  73413. /**
  73414. * Sets the PCS as always visible or not
  73415. * doc :
  73416. */
  73417. set isAlwaysVisible(val: boolean);
  73418. /**
  73419. * Tells to `setParticles()` to compute the particle rotations or not
  73420. * Default value : false. The PCS is faster when it's set to false
  73421. * Note : particle rotations are only applied to parent particles
  73422. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  73423. */
  73424. set computeParticleRotation(val: boolean);
  73425. /**
  73426. * Tells to `setParticles()` to compute the particle colors or not.
  73427. * Default value : true. The PCS is faster when it's set to false.
  73428. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  73429. */
  73430. set computeParticleColor(val: boolean);
  73431. set computeParticleTexture(val: boolean);
  73432. /**
  73433. * Gets if `setParticles()` computes the particle colors or not.
  73434. * Default value : false. The PCS is faster when it's set to false.
  73435. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  73436. */
  73437. get computeParticleColor(): boolean;
  73438. /**
  73439. * Gets if `setParticles()` computes the particle textures or not.
  73440. * Default value : false. The PCS is faster when it's set to false.
  73441. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  73442. */
  73443. get computeParticleTexture(): boolean;
  73444. /**
  73445. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  73446. */
  73447. set computeBoundingBox(val: boolean);
  73448. /**
  73449. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  73450. */
  73451. get computeBoundingBox(): boolean;
  73452. /**
  73453. * This function does nothing. It may be overwritten to set all the particle first values.
  73454. * The PCS doesn't call this function, you may have to call it by your own.
  73455. * doc :
  73456. */
  73457. initParticles(): void;
  73458. /**
  73459. * This function does nothing. It may be overwritten to recycle a particle
  73460. * The PCS doesn't call this function, you can to call it
  73461. * doc :
  73462. * @param particle The particle to recycle
  73463. * @returns the recycled particle
  73464. */
  73465. recycleParticle(particle: CloudPoint): CloudPoint;
  73466. /**
  73467. * Updates a particle : this function should be overwritten by the user.
  73468. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  73469. * doc :
  73470. * @example : just set a particle position or velocity and recycle conditions
  73471. * @param particle The particle to update
  73472. * @returns the updated particle
  73473. */
  73474. updateParticle(particle: CloudPoint): CloudPoint;
  73475. /**
  73476. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  73477. * This does nothing and may be overwritten by the user.
  73478. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  73479. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  73480. * @param update the boolean update value actually passed to setParticles()
  73481. */
  73482. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  73483. /**
  73484. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  73485. * This will be passed three parameters.
  73486. * This does nothing and may be overwritten by the user.
  73487. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  73488. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  73489. * @param update the boolean update value actually passed to setParticles()
  73490. */
  73491. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  73492. }
  73493. }
  73494. declare module BABYLON {
  73495. /**
  73496. * Represents one particle of a points cloud system.
  73497. */
  73498. export class CloudPoint {
  73499. /**
  73500. * particle global index
  73501. */
  73502. idx: number;
  73503. /**
  73504. * The color of the particle
  73505. */
  73506. color: Nullable<Color4>;
  73507. /**
  73508. * The world space position of the particle.
  73509. */
  73510. position: Vector3;
  73511. /**
  73512. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  73513. */
  73514. rotation: Vector3;
  73515. /**
  73516. * The world space rotation quaternion of the particle.
  73517. */
  73518. rotationQuaternion: Nullable<Quaternion>;
  73519. /**
  73520. * The uv of the particle.
  73521. */
  73522. uv: Nullable<Vector2>;
  73523. /**
  73524. * The current speed of the particle.
  73525. */
  73526. velocity: Vector3;
  73527. /**
  73528. * The pivot point in the particle local space.
  73529. */
  73530. pivot: Vector3;
  73531. /**
  73532. * Must the particle be translated from its pivot point in its local space ?
  73533. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  73534. * Default : false
  73535. */
  73536. translateFromPivot: boolean;
  73537. /**
  73538. * Index of this particle in the global "positions" array (Internal use)
  73539. * @hidden
  73540. */
  73541. _pos: number;
  73542. /**
  73543. * @hidden Index of this particle in the global "indices" array (Internal use)
  73544. */
  73545. _ind: number;
  73546. /**
  73547. * Group this particle belongs to
  73548. */
  73549. _group: PointsGroup;
  73550. /**
  73551. * Group id of this particle
  73552. */
  73553. groupId: number;
  73554. /**
  73555. * Index of the particle in its group id (Internal use)
  73556. */
  73557. idxInGroup: number;
  73558. /**
  73559. * @hidden Particle BoundingInfo object (Internal use)
  73560. */
  73561. _boundingInfo: BoundingInfo;
  73562. /**
  73563. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  73564. */
  73565. _pcs: PointsCloudSystem;
  73566. /**
  73567. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  73568. */
  73569. _stillInvisible: boolean;
  73570. /**
  73571. * @hidden Last computed particle rotation matrix
  73572. */
  73573. _rotationMatrix: number[];
  73574. /**
  73575. * Parent particle Id, if any.
  73576. * Default null.
  73577. */
  73578. parentId: Nullable<number>;
  73579. /**
  73580. * @hidden Internal global position in the PCS.
  73581. */
  73582. _globalPosition: Vector3;
  73583. /**
  73584. * Creates a Point Cloud object.
  73585. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  73586. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  73587. * @param group (PointsGroup) is the group the particle belongs to
  73588. * @param groupId (integer) is the group identifier in the PCS.
  73589. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  73590. * @param pcs defines the PCS it is associated to
  73591. */
  73592. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  73593. /**
  73594. * get point size
  73595. */
  73596. get size(): Vector3;
  73597. /**
  73598. * Set point size
  73599. */
  73600. set size(scale: Vector3);
  73601. /**
  73602. * Legacy support, changed quaternion to rotationQuaternion
  73603. */
  73604. get quaternion(): Nullable<Quaternion>;
  73605. /**
  73606. * Legacy support, changed quaternion to rotationQuaternion
  73607. */
  73608. set quaternion(q: Nullable<Quaternion>);
  73609. /**
  73610. * Returns a boolean. True if the particle intersects a mesh, else false
  73611. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  73612. * @param target is the object (point or mesh) what the intersection is computed against
  73613. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bounding sphere is used
  73614. * @returns true if it intersects
  73615. */
  73616. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  73617. /**
  73618. * get the rotation matrix of the particle
  73619. * @hidden
  73620. */
  73621. getRotationMatrix(m: Matrix): void;
  73622. }
  73623. /**
  73624. * Represents a group of points in a points cloud system
  73625. * * PCS internal tool, don't use it manually.
  73626. */
  73627. export class PointsGroup {
  73628. /**
  73629. * The group id
  73630. * @hidden
  73631. */
  73632. groupID: number;
  73633. /**
  73634. * image data for group (internal use)
  73635. * @hidden
  73636. */
  73637. _groupImageData: Nullable<ArrayBufferView>;
  73638. /**
  73639. * Image Width (internal use)
  73640. * @hidden
  73641. */
  73642. _groupImgWidth: number;
  73643. /**
  73644. * Image Height (internal use)
  73645. * @hidden
  73646. */
  73647. _groupImgHeight: number;
  73648. /**
  73649. * Custom position function (internal use)
  73650. * @hidden
  73651. */
  73652. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  73653. /**
  73654. * density per facet for surface points
  73655. * @hidden
  73656. */
  73657. _groupDensity: number[];
  73658. /**
  73659. * Only when points are colored by texture carries pointer to texture list array
  73660. * @hidden
  73661. */
  73662. _textureNb: number;
  73663. /**
  73664. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  73665. * PCS internal tool, don't use it manually.
  73666. * @hidden
  73667. */
  73668. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  73669. }
  73670. }
  73671. declare module BABYLON {
  73672. interface Scene {
  73673. /** @hidden (Backing field) */
  73674. _physicsEngine: Nullable<IPhysicsEngine>;
  73675. /** @hidden */
  73676. _physicsTimeAccumulator: number;
  73677. /**
  73678. * Gets the current physics engine
  73679. * @returns a IPhysicsEngine or null if none attached
  73680. */
  73681. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  73682. /**
  73683. * Enables physics to the current scene
  73684. * @param gravity defines the scene's gravity for the physics engine
  73685. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  73686. * @return a boolean indicating if the physics engine was initialized
  73687. */
  73688. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  73689. /**
  73690. * Disables and disposes the physics engine associated with the scene
  73691. */
  73692. disablePhysicsEngine(): void;
  73693. /**
  73694. * Gets a boolean indicating if there is an active physics engine
  73695. * @returns a boolean indicating if there is an active physics engine
  73696. */
  73697. isPhysicsEnabled(): boolean;
  73698. /**
  73699. * Deletes a physics compound impostor
  73700. * @param compound defines the compound to delete
  73701. */
  73702. deleteCompoundImpostor(compound: any): void;
  73703. /**
  73704. * An event triggered when physic simulation is about to be run
  73705. */
  73706. onBeforePhysicsObservable: Observable<Scene>;
  73707. /**
  73708. * An event triggered when physic simulation has been done
  73709. */
  73710. onAfterPhysicsObservable: Observable<Scene>;
  73711. }
  73712. interface AbstractMesh {
  73713. /** @hidden */
  73714. _physicsImpostor: Nullable<PhysicsImpostor>;
  73715. /**
  73716. * Gets or sets impostor used for physic simulation
  73717. * @see https://doc.babylonjs.com/features/physics_engine
  73718. */
  73719. physicsImpostor: Nullable<PhysicsImpostor>;
  73720. /**
  73721. * Gets the current physics impostor
  73722. * @see https://doc.babylonjs.com/features/physics_engine
  73723. * @returns a physics impostor or null
  73724. */
  73725. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  73726. /** Apply a physic impulse to the mesh
  73727. * @param force defines the force to apply
  73728. * @param contactPoint defines where to apply the force
  73729. * @returns the current mesh
  73730. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  73731. */
  73732. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  73733. /**
  73734. * Creates a physic joint between two meshes
  73735. * @param otherMesh defines the other mesh to use
  73736. * @param pivot1 defines the pivot to use on this mesh
  73737. * @param pivot2 defines the pivot to use on the other mesh
  73738. * @param options defines additional options (can be plugin dependent)
  73739. * @returns the current mesh
  73740. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  73741. */
  73742. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  73743. /** @hidden */
  73744. _disposePhysicsObserver: Nullable<Observer<Node>>;
  73745. }
  73746. /**
  73747. * Defines the physics engine scene component responsible to manage a physics engine
  73748. */
  73749. export class PhysicsEngineSceneComponent implements ISceneComponent {
  73750. /**
  73751. * The component name helpful to identify the component in the list of scene components.
  73752. */
  73753. readonly name: string;
  73754. /**
  73755. * The scene the component belongs to.
  73756. */
  73757. scene: Scene;
  73758. /**
  73759. * Creates a new instance of the component for the given scene
  73760. * @param scene Defines the scene to register the component in
  73761. */
  73762. constructor(scene: Scene);
  73763. /**
  73764. * Registers the component in a given scene
  73765. */
  73766. register(): void;
  73767. /**
  73768. * Rebuilds the elements related to this component in case of
  73769. * context lost for instance.
  73770. */
  73771. rebuild(): void;
  73772. /**
  73773. * Disposes the component and the associated resources
  73774. */
  73775. dispose(): void;
  73776. }
  73777. }
  73778. declare module BABYLON {
  73779. /**
  73780. * A helper for physics simulations
  73781. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73782. */
  73783. export class PhysicsHelper {
  73784. private _scene;
  73785. private _physicsEngine;
  73786. /**
  73787. * Initializes the Physics helper
  73788. * @param scene Babylon.js scene
  73789. */
  73790. constructor(scene: Scene);
  73791. /**
  73792. * Applies a radial explosion impulse
  73793. * @param origin the origin of the explosion
  73794. * @param radiusOrEventOptions the radius or the options of radial explosion
  73795. * @param strength the explosion strength
  73796. * @param falloff possible options: Constant & Linear. Defaults to Constant
  73797. * @returns A physics radial explosion event, or null
  73798. */
  73799. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  73800. /**
  73801. * Applies a radial explosion force
  73802. * @param origin the origin of the explosion
  73803. * @param radiusOrEventOptions the radius or the options of radial explosion
  73804. * @param strength the explosion strength
  73805. * @param falloff possible options: Constant & Linear. Defaults to Constant
  73806. * @returns A physics radial explosion event, or null
  73807. */
  73808. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  73809. /**
  73810. * Creates a gravitational field
  73811. * @param origin the origin of the explosion
  73812. * @param radiusOrEventOptions the radius or the options of radial explosion
  73813. * @param strength the explosion strength
  73814. * @param falloff possible options: Constant & Linear. Defaults to Constant
  73815. * @returns A physics gravitational field event, or null
  73816. */
  73817. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  73818. /**
  73819. * Creates a physics updraft event
  73820. * @param origin the origin of the updraft
  73821. * @param radiusOrEventOptions the radius or the options of the updraft
  73822. * @param strength the strength of the updraft
  73823. * @param height the height of the updraft
  73824. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  73825. * @returns A physics updraft event, or null
  73826. */
  73827. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  73828. /**
  73829. * Creates a physics vortex event
  73830. * @param origin the of the vortex
  73831. * @param radiusOrEventOptions the radius or the options of the vortex
  73832. * @param strength the strength of the vortex
  73833. * @param height the height of the vortex
  73834. * @returns a Physics vortex event, or null
  73835. * A physics vortex event or null
  73836. */
  73837. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  73838. }
  73839. /**
  73840. * Represents a physics radial explosion event
  73841. */
  73842. class PhysicsRadialExplosionEvent {
  73843. private _scene;
  73844. private _options;
  73845. private _sphere;
  73846. private _dataFetched;
  73847. /**
  73848. * Initializes a radial explosion event
  73849. * @param _scene BabylonJS scene
  73850. * @param _options The options for the vortex event
  73851. */
  73852. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  73853. /**
  73854. * Returns the data related to the radial explosion event (sphere).
  73855. * @returns The radial explosion event data
  73856. */
  73857. getData(): PhysicsRadialExplosionEventData;
  73858. /**
  73859. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  73860. * @param impostor A physics imposter
  73861. * @param origin the origin of the explosion
  73862. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  73863. */
  73864. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  73865. /**
  73866. * Triggers affected impostors callbacks
  73867. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  73868. */
  73869. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  73870. /**
  73871. * Disposes the sphere.
  73872. * @param force Specifies if the sphere should be disposed by force
  73873. */
  73874. dispose(force?: boolean): void;
  73875. /*** Helpers ***/
  73876. private _prepareSphere;
  73877. private _intersectsWithSphere;
  73878. }
  73879. /**
  73880. * Represents a gravitational field event
  73881. */
  73882. class PhysicsGravitationalFieldEvent {
  73883. private _physicsHelper;
  73884. private _scene;
  73885. private _origin;
  73886. private _options;
  73887. private _tickCallback;
  73888. private _sphere;
  73889. private _dataFetched;
  73890. /**
  73891. * Initializes the physics gravitational field event
  73892. * @param _physicsHelper A physics helper
  73893. * @param _scene BabylonJS scene
  73894. * @param _origin The origin position of the gravitational field event
  73895. * @param _options The options for the vortex event
  73896. */
  73897. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  73898. /**
  73899. * Returns the data related to the gravitational field event (sphere).
  73900. * @returns A gravitational field event
  73901. */
  73902. getData(): PhysicsGravitationalFieldEventData;
  73903. /**
  73904. * Enables the gravitational field.
  73905. */
  73906. enable(): void;
  73907. /**
  73908. * Disables the gravitational field.
  73909. */
  73910. disable(): void;
  73911. /**
  73912. * Disposes the sphere.
  73913. * @param force The force to dispose from the gravitational field event
  73914. */
  73915. dispose(force?: boolean): void;
  73916. private _tick;
  73917. }
  73918. /**
  73919. * Represents a physics updraft event
  73920. */
  73921. class PhysicsUpdraftEvent {
  73922. private _scene;
  73923. private _origin;
  73924. private _options;
  73925. private _physicsEngine;
  73926. private _originTop;
  73927. private _originDirection;
  73928. private _tickCallback;
  73929. private _cylinder;
  73930. private _cylinderPosition;
  73931. private _dataFetched;
  73932. /**
  73933. * Initializes the physics updraft event
  73934. * @param _scene BabylonJS scene
  73935. * @param _origin The origin position of the updraft
  73936. * @param _options The options for the updraft event
  73937. */
  73938. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  73939. /**
  73940. * Returns the data related to the updraft event (cylinder).
  73941. * @returns A physics updraft event
  73942. */
  73943. getData(): PhysicsUpdraftEventData;
  73944. /**
  73945. * Enables the updraft.
  73946. */
  73947. enable(): void;
  73948. /**
  73949. * Disables the updraft.
  73950. */
  73951. disable(): void;
  73952. /**
  73953. * Disposes the cylinder.
  73954. * @param force Specifies if the updraft should be disposed by force
  73955. */
  73956. dispose(force?: boolean): void;
  73957. private getImpostorHitData;
  73958. private _tick;
  73959. /*** Helpers ***/
  73960. private _prepareCylinder;
  73961. private _intersectsWithCylinder;
  73962. }
  73963. /**
  73964. * Represents a physics vortex event
  73965. */
  73966. class PhysicsVortexEvent {
  73967. private _scene;
  73968. private _origin;
  73969. private _options;
  73970. private _physicsEngine;
  73971. private _originTop;
  73972. private _tickCallback;
  73973. private _cylinder;
  73974. private _cylinderPosition;
  73975. private _dataFetched;
  73976. /**
  73977. * Initializes the physics vortex event
  73978. * @param _scene The BabylonJS scene
  73979. * @param _origin The origin position of the vortex
  73980. * @param _options The options for the vortex event
  73981. */
  73982. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  73983. /**
  73984. * Returns the data related to the vortex event (cylinder).
  73985. * @returns The physics vortex event data
  73986. */
  73987. getData(): PhysicsVortexEventData;
  73988. /**
  73989. * Enables the vortex.
  73990. */
  73991. enable(): void;
  73992. /**
  73993. * Disables the cortex.
  73994. */
  73995. disable(): void;
  73996. /**
  73997. * Disposes the sphere.
  73998. * @param force
  73999. */
  74000. dispose(force?: boolean): void;
  74001. private getImpostorHitData;
  74002. private _tick;
  74003. /*** Helpers ***/
  74004. private _prepareCylinder;
  74005. private _intersectsWithCylinder;
  74006. }
  74007. /**
  74008. * Options fot the radial explosion event
  74009. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  74010. */
  74011. export class PhysicsRadialExplosionEventOptions {
  74012. /**
  74013. * The radius of the sphere for the radial explosion.
  74014. */
  74015. radius: number;
  74016. /**
  74017. * The strength of the explosion.
  74018. */
  74019. strength: number;
  74020. /**
  74021. * The strength of the force in correspondence to the distance of the affected object
  74022. */
  74023. falloff: PhysicsRadialImpulseFalloff;
  74024. /**
  74025. * Sphere options for the radial explosion.
  74026. */
  74027. sphere: {
  74028. segments: number;
  74029. diameter: number;
  74030. };
  74031. /**
  74032. * Sphere options for the radial explosion.
  74033. */
  74034. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  74035. }
  74036. /**
  74037. * Options fot the updraft event
  74038. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  74039. */
  74040. export class PhysicsUpdraftEventOptions {
  74041. /**
  74042. * The radius of the cylinder for the vortex
  74043. */
  74044. radius: number;
  74045. /**
  74046. * The strength of the updraft.
  74047. */
  74048. strength: number;
  74049. /**
  74050. * The height of the cylinder for the updraft.
  74051. */
  74052. height: number;
  74053. /**
  74054. * The mode for the the updraft.
  74055. */
  74056. updraftMode: PhysicsUpdraftMode;
  74057. }
  74058. /**
  74059. * Options fot the vortex event
  74060. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  74061. */
  74062. export class PhysicsVortexEventOptions {
  74063. /**
  74064. * The radius of the cylinder for the vortex
  74065. */
  74066. radius: number;
  74067. /**
  74068. * The strength of the vortex.
  74069. */
  74070. strength: number;
  74071. /**
  74072. * The height of the cylinder for the vortex.
  74073. */
  74074. height: number;
  74075. /**
  74076. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  74077. */
  74078. centripetalForceThreshold: number;
  74079. /**
  74080. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the threshold.
  74081. */
  74082. centripetalForceMultiplier: number;
  74083. /**
  74084. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the threshold.
  74085. */
  74086. centrifugalForceMultiplier: number;
  74087. /**
  74088. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  74089. */
  74090. updraftForceMultiplier: number;
  74091. }
  74092. /**
  74093. * The strength of the force in correspondence to the distance of the affected object
  74094. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  74095. */
  74096. export enum PhysicsRadialImpulseFalloff {
  74097. /** Defines that impulse is constant in strength across it's whole radius */
  74098. Constant = 0,
  74099. /** Defines that impulse gets weaker if it's further from the origin */
  74100. Linear = 1
  74101. }
  74102. /**
  74103. * The strength of the force in correspondence to the distance of the affected object
  74104. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  74105. */
  74106. export enum PhysicsUpdraftMode {
  74107. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  74108. Center = 0,
  74109. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  74110. Perpendicular = 1
  74111. }
  74112. /**
  74113. * Interface for a physics hit data
  74114. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  74115. */
  74116. export interface PhysicsHitData {
  74117. /**
  74118. * The force applied at the contact point
  74119. */
  74120. force: Vector3;
  74121. /**
  74122. * The contact point
  74123. */
  74124. contactPoint: Vector3;
  74125. /**
  74126. * The distance from the origin to the contact point
  74127. */
  74128. distanceFromOrigin: number;
  74129. }
  74130. /**
  74131. * Interface for radial explosion event data
  74132. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  74133. */
  74134. export interface PhysicsRadialExplosionEventData {
  74135. /**
  74136. * A sphere used for the radial explosion event
  74137. */
  74138. sphere: Mesh;
  74139. }
  74140. /**
  74141. * Interface for gravitational field event data
  74142. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  74143. */
  74144. export interface PhysicsGravitationalFieldEventData {
  74145. /**
  74146. * A sphere mesh used for the gravitational field event
  74147. */
  74148. sphere: Mesh;
  74149. }
  74150. /**
  74151. * Interface for updraft event data
  74152. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  74153. */
  74154. export interface PhysicsUpdraftEventData {
  74155. /**
  74156. * A cylinder used for the updraft event
  74157. */
  74158. cylinder: Mesh;
  74159. }
  74160. /**
  74161. * Interface for vortex event data
  74162. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  74163. */
  74164. export interface PhysicsVortexEventData {
  74165. /**
  74166. * A cylinder used for the vortex event
  74167. */
  74168. cylinder: Mesh;
  74169. }
  74170. /**
  74171. * Interface for an affected physics impostor
  74172. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  74173. */
  74174. export interface PhysicsAffectedImpostorWithData {
  74175. /**
  74176. * The impostor affected by the effect
  74177. */
  74178. impostor: PhysicsImpostor;
  74179. /**
  74180. * The data about the hit/force from the explosion
  74181. */
  74182. hitData: PhysicsHitData;
  74183. }
  74184. }
  74185. declare module BABYLON {
  74186. /** @hidden */
  74187. export var blackAndWhitePixelShader: {
  74188. name: string;
  74189. shader: string;
  74190. };
  74191. }
  74192. declare module BABYLON {
  74193. /**
  74194. * Post process used to render in black and white
  74195. */
  74196. export class BlackAndWhitePostProcess extends PostProcess {
  74197. /**
  74198. * Linear about to convert he result to black and white (default: 1)
  74199. */
  74200. degree: number;
  74201. /**
  74202. * Gets a string identifying the name of the class
  74203. * @returns "BlackAndWhitePostProcess" string
  74204. */
  74205. getClassName(): string;
  74206. /**
  74207. * Creates a black and white post process
  74208. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  74209. * @param name The name of the effect.
  74210. * @param options The required width/height ratio to downsize to before computing the render pass.
  74211. * @param camera The camera to apply the render pass to.
  74212. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74213. * @param engine The engine which the post process will be applied. (default: current engine)
  74214. * @param reusable If the post process can be reused on the same frame. (default: false)
  74215. */
  74216. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74217. /** @hidden */
  74218. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  74219. }
  74220. }
  74221. declare module BABYLON {
  74222. /**
  74223. * This represents a set of one or more post processes in Babylon.
  74224. * A post process can be used to apply a shader to a texture after it is rendered.
  74225. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74226. */
  74227. export class PostProcessRenderEffect {
  74228. private _postProcesses;
  74229. private _getPostProcesses;
  74230. private _singleInstance;
  74231. private _cameras;
  74232. private _indicesForCamera;
  74233. /**
  74234. * Name of the effect
  74235. * @hidden
  74236. */
  74237. _name: string;
  74238. /**
  74239. * Instantiates a post process render effect.
  74240. * A post process can be used to apply a shader to a texture after it is rendered.
  74241. * @param engine The engine the effect is tied to
  74242. * @param name The name of the effect
  74243. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  74244. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  74245. */
  74246. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  74247. /**
  74248. * Checks if all the post processes in the effect are supported.
  74249. */
  74250. get isSupported(): boolean;
  74251. /**
  74252. * Updates the current state of the effect
  74253. * @hidden
  74254. */
  74255. _update(): void;
  74256. /**
  74257. * Attaches the effect on cameras
  74258. * @param cameras The camera to attach to.
  74259. * @hidden
  74260. */
  74261. _attachCameras(cameras: Camera): void;
  74262. /**
  74263. * Attaches the effect on cameras
  74264. * @param cameras The camera to attach to.
  74265. * @hidden
  74266. */
  74267. _attachCameras(cameras: Camera[]): void;
  74268. /**
  74269. * Detaches the effect on cameras
  74270. * @param cameras The camera to detach from.
  74271. * @hidden
  74272. */
  74273. _detachCameras(cameras: Camera): void;
  74274. /**
  74275. * Detaches the effect on cameras
  74276. * @param cameras The camera to detach from.
  74277. * @hidden
  74278. */
  74279. _detachCameras(cameras: Camera[]): void;
  74280. /**
  74281. * Enables the effect on given cameras
  74282. * @param cameras The camera to enable.
  74283. * @hidden
  74284. */
  74285. _enable(cameras: Camera): void;
  74286. /**
  74287. * Enables the effect on given cameras
  74288. * @param cameras The camera to enable.
  74289. * @hidden
  74290. */
  74291. _enable(cameras: Nullable<Camera[]>): void;
  74292. /**
  74293. * Disables the effect on the given cameras
  74294. * @param cameras The camera to disable.
  74295. * @hidden
  74296. */
  74297. _disable(cameras: Camera): void;
  74298. /**
  74299. * Disables the effect on the given cameras
  74300. * @param cameras The camera to disable.
  74301. * @hidden
  74302. */
  74303. _disable(cameras: Nullable<Camera[]>): void;
  74304. /**
  74305. * Gets a list of the post processes contained in the effect.
  74306. * @param camera The camera to get the post processes on.
  74307. * @returns The list of the post processes in the effect.
  74308. */
  74309. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  74310. }
  74311. }
  74312. declare module BABYLON {
  74313. /** @hidden */
  74314. export var extractHighlightsPixelShader: {
  74315. name: string;
  74316. shader: string;
  74317. };
  74318. }
  74319. declare module BABYLON {
  74320. /**
  74321. * 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.
  74322. */
  74323. export class ExtractHighlightsPostProcess extends PostProcess {
  74324. /**
  74325. * The luminance threshold, pixels below this value will be set to black.
  74326. */
  74327. threshold: number;
  74328. /** @hidden */
  74329. _exposure: number;
  74330. /**
  74331. * Post process which has the input texture to be used when performing highlight extraction
  74332. * @hidden
  74333. */
  74334. _inputPostProcess: Nullable<PostProcess>;
  74335. /**
  74336. * Gets a string identifying the name of the class
  74337. * @returns "ExtractHighlightsPostProcess" string
  74338. */
  74339. getClassName(): string;
  74340. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74341. }
  74342. }
  74343. declare module BABYLON {
  74344. /** @hidden */
  74345. export var bloomMergePixelShader: {
  74346. name: string;
  74347. shader: string;
  74348. };
  74349. }
  74350. declare module BABYLON {
  74351. /**
  74352. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  74353. */
  74354. export class BloomMergePostProcess extends PostProcess {
  74355. /** Weight of the bloom to be added to the original input. */
  74356. weight: number;
  74357. /**
  74358. * Gets a string identifying the name of the class
  74359. * @returns "BloomMergePostProcess" string
  74360. */
  74361. getClassName(): string;
  74362. /**
  74363. * Creates a new instance of @see BloomMergePostProcess
  74364. * @param name The name of the effect.
  74365. * @param originalFromInput Post process which's input will be used for the merge.
  74366. * @param blurred Blurred highlights post process which's output will be used.
  74367. * @param weight Weight of the bloom to be added to the original input.
  74368. * @param options The required width/height ratio to downsize to before computing the render pass.
  74369. * @param camera The camera to apply the render pass to.
  74370. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74371. * @param engine The engine which the post process will be applied. (default: current engine)
  74372. * @param reusable If the post process can be reused on the same frame. (default: false)
  74373. * @param textureType Type of textures used when performing the post process. (default: 0)
  74374. * @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)
  74375. */
  74376. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  74377. /** Weight of the bloom to be added to the original input. */
  74378. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74379. }
  74380. }
  74381. declare module BABYLON {
  74382. /**
  74383. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  74384. */
  74385. export class BloomEffect extends PostProcessRenderEffect {
  74386. private bloomScale;
  74387. /**
  74388. * @hidden Internal
  74389. */
  74390. _effects: Array<PostProcess>;
  74391. /**
  74392. * @hidden Internal
  74393. */
  74394. _downscale: ExtractHighlightsPostProcess;
  74395. private _blurX;
  74396. private _blurY;
  74397. private _merge;
  74398. /**
  74399. * The luminance threshold to find bright areas of the image to bloom.
  74400. */
  74401. get threshold(): number;
  74402. set threshold(value: number);
  74403. /**
  74404. * The strength of the bloom.
  74405. */
  74406. get weight(): number;
  74407. set weight(value: number);
  74408. /**
  74409. * Specifies the size of the bloom blur kernel, relative to the final output size
  74410. */
  74411. get kernel(): number;
  74412. set kernel(value: number);
  74413. /**
  74414. * Creates a new instance of @see BloomEffect
  74415. * @param scene The scene the effect belongs to.
  74416. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  74417. * @param bloomKernel The size of the kernel to be used when applying the blur.
  74418. * @param bloomWeight The the strength of bloom.
  74419. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  74420. * @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)
  74421. */
  74422. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  74423. /**
  74424. * Disposes each of the internal effects for a given camera.
  74425. * @param camera The camera to dispose the effect on.
  74426. */
  74427. disposeEffects(camera: Camera): void;
  74428. /**
  74429. * @hidden Internal
  74430. */
  74431. _updateEffects(): void;
  74432. /**
  74433. * Internal
  74434. * @returns if all the contained post processes are ready.
  74435. * @hidden
  74436. */
  74437. _isReady(): boolean;
  74438. }
  74439. }
  74440. declare module BABYLON {
  74441. /** @hidden */
  74442. export var chromaticAberrationPixelShader: {
  74443. name: string;
  74444. shader: string;
  74445. };
  74446. }
  74447. declare module BABYLON {
  74448. /**
  74449. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  74450. */
  74451. export class ChromaticAberrationPostProcess extends PostProcess {
  74452. /**
  74453. * The amount of separation of rgb channels (default: 30)
  74454. */
  74455. aberrationAmount: number;
  74456. /**
  74457. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  74458. */
  74459. radialIntensity: number;
  74460. /**
  74461. * 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))
  74462. */
  74463. direction: Vector2;
  74464. /**
  74465. * 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))
  74466. */
  74467. centerPosition: Vector2;
  74468. /** The width of the screen to apply the effect on */
  74469. screenWidth: number;
  74470. /** The height of the screen to apply the effect on */
  74471. screenHeight: number;
  74472. /**
  74473. * Gets a string identifying the name of the class
  74474. * @returns "ChromaticAberrationPostProcess" string
  74475. */
  74476. getClassName(): string;
  74477. /**
  74478. * Creates a new instance ChromaticAberrationPostProcess
  74479. * @param name The name of the effect.
  74480. * @param screenWidth The width of the screen to apply the effect on.
  74481. * @param screenHeight The height of the screen to apply the effect on.
  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 textures used when performing the post process. (default: 0)
  74488. * @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)
  74489. */
  74490. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74491. /** @hidden */
  74492. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  74493. }
  74494. }
  74495. declare module BABYLON {
  74496. /** @hidden */
  74497. export var circleOfConfusionPixelShader: {
  74498. name: string;
  74499. shader: string;
  74500. };
  74501. }
  74502. declare module BABYLON {
  74503. /**
  74504. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  74505. */
  74506. export class CircleOfConfusionPostProcess extends PostProcess {
  74507. /**
  74508. * 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.
  74509. */
  74510. lensSize: number;
  74511. /**
  74512. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  74513. */
  74514. fStop: number;
  74515. /**
  74516. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  74517. */
  74518. focusDistance: number;
  74519. /**
  74520. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  74521. */
  74522. focalLength: number;
  74523. /**
  74524. * Gets a string identifying the name of the class
  74525. * @returns "CircleOfConfusionPostProcess" string
  74526. */
  74527. getClassName(): string;
  74528. private _depthTexture;
  74529. /**
  74530. * Creates a new instance CircleOfConfusionPostProcess
  74531. * @param name The name of the effect.
  74532. * @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.
  74533. * @param options The required width/height ratio to downsize to before computing the render pass.
  74534. * @param camera The camera to apply the render pass to.
  74535. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74536. * @param engine The engine which the post process will be applied. (default: current engine)
  74537. * @param reusable If the post process can be reused on the same frame. (default: false)
  74538. * @param textureType Type of textures used when performing the post process. (default: 0)
  74539. * @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)
  74540. */
  74541. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74542. /**
  74543. * 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.
  74544. */
  74545. set depthTexture(value: RenderTargetTexture);
  74546. }
  74547. }
  74548. declare module BABYLON {
  74549. /** @hidden */
  74550. export var colorCorrectionPixelShader: {
  74551. name: string;
  74552. shader: string;
  74553. };
  74554. }
  74555. declare module BABYLON {
  74556. /**
  74557. *
  74558. * This post-process allows the modification of rendered colors by using
  74559. * a 'look-up table' (LUT). This effect is also called Color Grading.
  74560. *
  74561. * The object needs to be provided an url to a texture containing the color
  74562. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  74563. * Use an image editing software to tweak the LUT to match your needs.
  74564. *
  74565. * For an example of a color LUT, see here:
  74566. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  74567. * For explanations on color grading, see here:
  74568. * @see http://udn.epicgames.com/Three/ColorGrading.html
  74569. *
  74570. */
  74571. export class ColorCorrectionPostProcess extends PostProcess {
  74572. private _colorTableTexture;
  74573. /**
  74574. * Gets the color table url used to create the LUT texture
  74575. */
  74576. colorTableUrl: string;
  74577. /**
  74578. * Gets a string identifying the name of the class
  74579. * @returns "ColorCorrectionPostProcess" string
  74580. */
  74581. getClassName(): string;
  74582. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74583. /** @hidden */
  74584. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  74585. }
  74586. }
  74587. declare module BABYLON {
  74588. /** @hidden */
  74589. export var convolutionPixelShader: {
  74590. name: string;
  74591. shader: string;
  74592. };
  74593. }
  74594. declare module BABYLON {
  74595. /**
  74596. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  74597. * input texture to perform effects such as edge detection or sharpening
  74598. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  74599. */
  74600. export class ConvolutionPostProcess extends PostProcess {
  74601. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  74602. kernel: number[];
  74603. /**
  74604. * Gets a string identifying the name of the class
  74605. * @returns "ConvolutionPostProcess" string
  74606. */
  74607. getClassName(): string;
  74608. /**
  74609. * Creates a new instance ConvolutionPostProcess
  74610. * @param name The name of the effect.
  74611. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  74612. * @param options The required width/height ratio to downsize to before computing the render pass.
  74613. * @param camera The camera to apply the render pass to.
  74614. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74615. * @param engine The engine which the post process will be applied. (default: current engine)
  74616. * @param reusable If the post process can be reused on the same frame. (default: false)
  74617. * @param textureType Type of textures used when performing the post process. (default: 0)
  74618. */
  74619. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  74620. /** @hidden */
  74621. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  74622. /**
  74623. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74624. */
  74625. static EdgeDetect0Kernel: number[];
  74626. /**
  74627. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74628. */
  74629. static EdgeDetect1Kernel: number[];
  74630. /**
  74631. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74632. */
  74633. static EdgeDetect2Kernel: number[];
  74634. /**
  74635. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74636. */
  74637. static SharpenKernel: number[];
  74638. /**
  74639. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74640. */
  74641. static EmbossKernel: number[];
  74642. /**
  74643. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74644. */
  74645. static GaussianKernel: number[];
  74646. }
  74647. }
  74648. declare module BABYLON {
  74649. /**
  74650. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  74651. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  74652. * based on samples that have a large difference in distance than the center pixel.
  74653. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  74654. */
  74655. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  74656. /**
  74657. * The direction the blur should be applied
  74658. */
  74659. direction: Vector2;
  74660. /**
  74661. * Gets a string identifying the name of the class
  74662. * @returns "DepthOfFieldBlurPostProcess" string
  74663. */
  74664. getClassName(): string;
  74665. /**
  74666. * Creates a new instance CircleOfConfusionPostProcess
  74667. * @param name The name of the effect.
  74668. * @param scene The scene the effect belongs to.
  74669. * @param direction The direction the blur should be applied.
  74670. * @param kernel The size of the kernel used to blur.
  74671. * @param options The required width/height ratio to downsize to before computing the render pass.
  74672. * @param camera The camera to apply the render pass to.
  74673. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring across edges
  74674. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  74675. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74676. * @param engine The engine which the post process will be applied. (default: current engine)
  74677. * @param reusable If the post process can be reused on the same frame. (default: false)
  74678. * @param textureType Type of textures used when performing the post process. (default: 0)
  74679. * @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)
  74680. */
  74681. 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);
  74682. }
  74683. }
  74684. declare module BABYLON {
  74685. /** @hidden */
  74686. export var depthOfFieldMergePixelShader: {
  74687. name: string;
  74688. shader: string;
  74689. };
  74690. }
  74691. declare module BABYLON {
  74692. /**
  74693. * Options to be set when merging outputs from the default pipeline.
  74694. */
  74695. export class DepthOfFieldMergePostProcessOptions {
  74696. /**
  74697. * The original image to merge on top of
  74698. */
  74699. originalFromInput: PostProcess;
  74700. /**
  74701. * Parameters to perform the merge of the depth of field effect
  74702. */
  74703. depthOfField?: {
  74704. circleOfConfusion: PostProcess;
  74705. blurSteps: Array<PostProcess>;
  74706. };
  74707. /**
  74708. * Parameters to perform the merge of bloom effect
  74709. */
  74710. bloom?: {
  74711. blurred: PostProcess;
  74712. weight: number;
  74713. };
  74714. }
  74715. /**
  74716. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  74717. */
  74718. export class DepthOfFieldMergePostProcess extends PostProcess {
  74719. private blurSteps;
  74720. /**
  74721. * Gets a string identifying the name of the class
  74722. * @returns "DepthOfFieldMergePostProcess" string
  74723. */
  74724. getClassName(): string;
  74725. /**
  74726. * Creates a new instance of DepthOfFieldMergePostProcess
  74727. * @param name The name of the effect.
  74728. * @param originalFromInput Post process which's input will be used for the merge.
  74729. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  74730. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  74731. * @param options The required width/height ratio to downsize to before computing the render pass.
  74732. * @param camera The camera to apply the render pass to.
  74733. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74734. * @param engine The engine which the post process will be applied. (default: current engine)
  74735. * @param reusable If the post process can be reused on the same frame. (default: false)
  74736. * @param textureType Type of textures used when performing the post process. (default: 0)
  74737. * @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)
  74738. */
  74739. 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);
  74740. /**
  74741. * Updates the effect with the current post process compile time values and recompiles the shader.
  74742. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  74743. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  74744. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  74745. * @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
  74746. * @param onCompiled Called when the shader has been compiled.
  74747. * @param onError Called if there is an error when compiling a shader.
  74748. */
  74749. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  74750. }
  74751. }
  74752. declare module BABYLON {
  74753. /**
  74754. * Specifies the level of max blur that should be applied when using the depth of field effect
  74755. */
  74756. export enum DepthOfFieldEffectBlurLevel {
  74757. /**
  74758. * Subtle blur
  74759. */
  74760. Low = 0,
  74761. /**
  74762. * Medium blur
  74763. */
  74764. Medium = 1,
  74765. /**
  74766. * Large blur
  74767. */
  74768. High = 2
  74769. }
  74770. /**
  74771. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  74772. */
  74773. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  74774. private _circleOfConfusion;
  74775. /**
  74776. * @hidden Internal, blurs from high to low
  74777. */
  74778. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  74779. private _depthOfFieldBlurY;
  74780. private _dofMerge;
  74781. /**
  74782. * @hidden Internal post processes in depth of field effect
  74783. */
  74784. _effects: Array<PostProcess>;
  74785. /**
  74786. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  74787. */
  74788. set focalLength(value: number);
  74789. get focalLength(): number;
  74790. /**
  74791. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  74792. */
  74793. set fStop(value: number);
  74794. get fStop(): number;
  74795. /**
  74796. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  74797. */
  74798. set focusDistance(value: number);
  74799. get focusDistance(): number;
  74800. /**
  74801. * 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.
  74802. */
  74803. set lensSize(value: number);
  74804. get lensSize(): number;
  74805. /**
  74806. * Creates a new instance DepthOfFieldEffect
  74807. * @param scene The scene the effect belongs to.
  74808. * @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.
  74809. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  74810. * @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)
  74811. */
  74812. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  74813. /**
  74814. * Get the current class name of the current effect
  74815. * @returns "DepthOfFieldEffect"
  74816. */
  74817. getClassName(): string;
  74818. /**
  74819. * 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.
  74820. */
  74821. set depthTexture(value: RenderTargetTexture);
  74822. /**
  74823. * Disposes each of the internal effects for a given camera.
  74824. * @param camera The camera to dispose the effect on.
  74825. */
  74826. disposeEffects(camera: Camera): void;
  74827. /**
  74828. * @hidden Internal
  74829. */
  74830. _updateEffects(): void;
  74831. /**
  74832. * Internal
  74833. * @returns if all the contained post processes are ready.
  74834. * @hidden
  74835. */
  74836. _isReady(): boolean;
  74837. }
  74838. }
  74839. declare module BABYLON {
  74840. /** @hidden */
  74841. export var displayPassPixelShader: {
  74842. name: string;
  74843. shader: string;
  74844. };
  74845. }
  74846. declare module BABYLON {
  74847. /**
  74848. * DisplayPassPostProcess which produces an output the same as it's input
  74849. */
  74850. export class DisplayPassPostProcess extends PostProcess {
  74851. /**
  74852. * Gets a string identifying the name of the class
  74853. * @returns "DisplayPassPostProcess" string
  74854. */
  74855. getClassName(): string;
  74856. /**
  74857. * Creates the DisplayPassPostProcess
  74858. * @param name The name of the effect.
  74859. * @param options The required width/height ratio to downsize to before computing the render pass.
  74860. * @param camera The camera to apply the render pass to.
  74861. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74862. * @param engine The engine which the post process will be applied. (default: current engine)
  74863. * @param reusable If the post process can be reused on the same frame. (default: false)
  74864. */
  74865. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74866. /** @hidden */
  74867. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  74868. }
  74869. }
  74870. declare module BABYLON {
  74871. /** @hidden */
  74872. export var filterPixelShader: {
  74873. name: string;
  74874. shader: string;
  74875. };
  74876. }
  74877. declare module BABYLON {
  74878. /**
  74879. * Applies a kernel filter to the image
  74880. */
  74881. export class FilterPostProcess extends PostProcess {
  74882. /** The matrix to be applied to the image */
  74883. kernelMatrix: Matrix;
  74884. /**
  74885. * Gets a string identifying the name of the class
  74886. * @returns "FilterPostProcess" string
  74887. */
  74888. getClassName(): string;
  74889. /**
  74890. *
  74891. * @param name The name of the effect.
  74892. * @param kernelMatrix The matrix to be applied to the image
  74893. * @param options The required width/height ratio to downsize to before computing the render pass.
  74894. * @param camera The camera to apply the render pass to.
  74895. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74896. * @param engine The engine which the post process will be applied. (default: current engine)
  74897. * @param reusable If the post process can be reused on the same frame. (default: false)
  74898. */
  74899. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74900. /** @hidden */
  74901. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  74902. }
  74903. }
  74904. declare module BABYLON {
  74905. /** @hidden */
  74906. export var fxaaPixelShader: {
  74907. name: string;
  74908. shader: string;
  74909. };
  74910. }
  74911. declare module BABYLON {
  74912. /** @hidden */
  74913. export var fxaaVertexShader: {
  74914. name: string;
  74915. shader: string;
  74916. };
  74917. }
  74918. declare module BABYLON {
  74919. /**
  74920. * Fxaa post process
  74921. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  74922. */
  74923. export class FxaaPostProcess extends PostProcess {
  74924. /**
  74925. * Gets a string identifying the name of the class
  74926. * @returns "FxaaPostProcess" string
  74927. */
  74928. getClassName(): string;
  74929. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  74930. private _getDefines;
  74931. /** @hidden */
  74932. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  74933. }
  74934. }
  74935. declare module BABYLON {
  74936. /** @hidden */
  74937. export var grainPixelShader: {
  74938. name: string;
  74939. shader: string;
  74940. };
  74941. }
  74942. declare module BABYLON {
  74943. /**
  74944. * The GrainPostProcess adds noise to the image at mid luminance levels
  74945. */
  74946. export class GrainPostProcess extends PostProcess {
  74947. /**
  74948. * The intensity of the grain added (default: 30)
  74949. */
  74950. intensity: number;
  74951. /**
  74952. * If the grain should be randomized on every frame
  74953. */
  74954. animated: boolean;
  74955. /**
  74956. * Gets a string identifying the name of the class
  74957. * @returns "GrainPostProcess" string
  74958. */
  74959. getClassName(): string;
  74960. /**
  74961. * Creates a new instance of @see GrainPostProcess
  74962. * @param name The name of the effect.
  74963. * @param options The required width/height ratio to downsize to before computing the render pass.
  74964. * @param camera The camera to apply the render pass to.
  74965. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74966. * @param engine The engine which the post process will be applied. (default: current engine)
  74967. * @param reusable If the post process can be reused on the same frame. (default: false)
  74968. * @param textureType Type of textures used when performing the post process. (default: 0)
  74969. * @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)
  74970. */
  74971. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74972. /** @hidden */
  74973. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  74974. }
  74975. }
  74976. declare module BABYLON {
  74977. /** @hidden */
  74978. export var highlightsPixelShader: {
  74979. name: string;
  74980. shader: string;
  74981. };
  74982. }
  74983. declare module BABYLON {
  74984. /**
  74985. * Extracts highlights from the image
  74986. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  74987. */
  74988. export class HighlightsPostProcess extends PostProcess {
  74989. /**
  74990. * Gets a string identifying the name of the class
  74991. * @returns "HighlightsPostProcess" string
  74992. */
  74993. getClassName(): string;
  74994. /**
  74995. * Extracts highlights from the image
  74996. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  74997. * @param name The name of the effect.
  74998. * @param options The required width/height ratio to downsize to before computing the render pass.
  74999. * @param camera The camera to apply the render pass to.
  75000. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75001. * @param engine The engine which the post process will be applied. (default: current engine)
  75002. * @param reusable If the post process can be reused on the same frame. (default: false)
  75003. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  75004. */
  75005. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  75006. }
  75007. }
  75008. declare module BABYLON {
  75009. /**
  75010. * Contains all parameters needed for the prepass to perform
  75011. * motion blur
  75012. */
  75013. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  75014. /**
  75015. * Is motion blur enabled
  75016. */
  75017. enabled: boolean;
  75018. /**
  75019. * Name of the configuration
  75020. */
  75021. name: string;
  75022. /**
  75023. * Textures that should be present in the MRT for this effect to work
  75024. */
  75025. readonly texturesRequired: number[];
  75026. }
  75027. }
  75028. declare module BABYLON {
  75029. interface Scene {
  75030. /** @hidden (Backing field) */
  75031. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  75032. /**
  75033. * Gets or Sets the current geometry buffer associated to the scene.
  75034. */
  75035. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  75036. /**
  75037. * Enables a GeometryBufferRender and associates it with the scene
  75038. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  75039. * @returns the GeometryBufferRenderer
  75040. */
  75041. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  75042. /**
  75043. * Disables the GeometryBufferRender associated with the scene
  75044. */
  75045. disableGeometryBufferRenderer(): void;
  75046. }
  75047. /**
  75048. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  75049. * in several rendering techniques.
  75050. */
  75051. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  75052. /**
  75053. * The component name helpful to identify the component in the list of scene components.
  75054. */
  75055. readonly name: string;
  75056. /**
  75057. * The scene the component belongs to.
  75058. */
  75059. scene: Scene;
  75060. /**
  75061. * Creates a new instance of the component for the given scene
  75062. * @param scene Defines the scene to register the component in
  75063. */
  75064. constructor(scene: Scene);
  75065. /**
  75066. * Registers the component in a given scene
  75067. */
  75068. register(): void;
  75069. /**
  75070. * Rebuilds the elements related to this component in case of
  75071. * context lost for instance.
  75072. */
  75073. rebuild(): void;
  75074. /**
  75075. * Disposes the component and the associated resources
  75076. */
  75077. dispose(): void;
  75078. private _gatherRenderTargets;
  75079. }
  75080. }
  75081. declare module BABYLON {
  75082. /** @hidden */
  75083. export var motionBlurPixelShader: {
  75084. name: string;
  75085. shader: string;
  75086. };
  75087. }
  75088. declare module BABYLON {
  75089. /**
  75090. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  75091. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  75092. * As an example, all you have to do is to create the post-process:
  75093. * var mb = new BABYLON.MotionBlurPostProcess(
  75094. * 'mb', // The name of the effect.
  75095. * scene, // The scene containing the objects to blur according to their velocity.
  75096. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  75097. * camera // The camera to apply the render pass to.
  75098. * );
  75099. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  75100. */
  75101. export class MotionBlurPostProcess extends PostProcess {
  75102. /**
  75103. * Defines how much the image is blurred by the movement. Default value is equal to 1
  75104. */
  75105. motionStrength: number;
  75106. /**
  75107. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  75108. */
  75109. get motionBlurSamples(): number;
  75110. /**
  75111. * Sets the number of iterations to be used for motion blur quality
  75112. */
  75113. set motionBlurSamples(samples: number);
  75114. private _motionBlurSamples;
  75115. /**
  75116. * Gets whether or not the motion blur post-process is in object based mode.
  75117. */
  75118. get isObjectBased(): boolean;
  75119. /**
  75120. * Sets whether or not the motion blur post-process is in object based mode.
  75121. */
  75122. set isObjectBased(value: boolean);
  75123. private _isObjectBased;
  75124. private _forceGeometryBuffer;
  75125. private _geometryBufferRenderer;
  75126. private _prePassRenderer;
  75127. private _invViewProjection;
  75128. private _previousViewProjection;
  75129. /**
  75130. * Gets a string identifying the name of the class
  75131. * @returns "MotionBlurPostProcess" string
  75132. */
  75133. getClassName(): string;
  75134. /**
  75135. * Creates a new instance MotionBlurPostProcess
  75136. * @param name The name of the effect.
  75137. * @param scene The scene containing the objects to blur according to their velocity.
  75138. * @param options The required width/height ratio to downsize to before computing the render pass.
  75139. * @param camera The camera to apply the render pass to.
  75140. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75141. * @param engine The engine which the post process will be applied. (default: current engine)
  75142. * @param reusable If the post process can be reused on the same frame. (default: false)
  75143. * @param textureType Type of textures used when performing the post process. (default: 0)
  75144. * @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)
  75145. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  75146. */
  75147. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  75148. /**
  75149. * Excludes the given skinned mesh from computing bones velocities.
  75150. * 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.
  75151. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  75152. */
  75153. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  75154. /**
  75155. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  75156. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  75157. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  75158. */
  75159. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  75160. /**
  75161. * Disposes the post process.
  75162. * @param camera The camera to dispose the post process on.
  75163. */
  75164. dispose(camera?: Camera): void;
  75165. /**
  75166. * Called on the mode changed (object based or screen based).
  75167. */
  75168. private _applyMode;
  75169. /**
  75170. * Called on the effect is applied when the motion blur post-process is in object based mode.
  75171. */
  75172. private _onApplyObjectBased;
  75173. /**
  75174. * Called on the effect is applied when the motion blur post-process is in screen based mode.
  75175. */
  75176. private _onApplyScreenBased;
  75177. /**
  75178. * Called on the effect must be updated (changed mode, samples count, etc.).
  75179. */
  75180. private _updateEffect;
  75181. /** @hidden */
  75182. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  75183. }
  75184. }
  75185. declare module BABYLON {
  75186. /** @hidden */
  75187. export var refractionPixelShader: {
  75188. name: string;
  75189. shader: string;
  75190. };
  75191. }
  75192. declare module BABYLON {
  75193. /**
  75194. * Post process which applies a refraction texture
  75195. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  75196. */
  75197. export class RefractionPostProcess extends PostProcess {
  75198. private _refTexture;
  75199. private _ownRefractionTexture;
  75200. /** the base color of the refraction (used to taint the rendering) */
  75201. color: Color3;
  75202. /** simulated refraction depth */
  75203. depth: number;
  75204. /** the coefficient of the base color (0 to remove base color tainting) */
  75205. colorLevel: number;
  75206. /** Gets the url used to load the refraction texture */
  75207. refractionTextureUrl: string;
  75208. /**
  75209. * Gets or sets the refraction texture
  75210. * Please note that you are responsible for disposing the texture if you set it manually
  75211. */
  75212. get refractionTexture(): Texture;
  75213. set refractionTexture(value: Texture);
  75214. /**
  75215. * Gets a string identifying the name of the class
  75216. * @returns "RefractionPostProcess" string
  75217. */
  75218. getClassName(): string;
  75219. /**
  75220. * Initializes the RefractionPostProcess
  75221. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  75222. * @param name The name of the effect.
  75223. * @param refractionTextureUrl Url of the refraction texture to use
  75224. * @param color the base color of the refraction (used to taint the rendering)
  75225. * @param depth simulated refraction depth
  75226. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  75227. * @param camera The camera to apply the render pass to.
  75228. * @param options The required width/height ratio to downsize to before computing the render pass.
  75229. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75230. * @param engine The engine which the post process will be applied. (default: current engine)
  75231. * @param reusable If the post process can be reused on the same frame. (default: false)
  75232. */
  75233. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  75234. /**
  75235. * Disposes of the post process
  75236. * @param camera Camera to dispose post process on
  75237. */
  75238. dispose(camera: Camera): void;
  75239. /** @hidden */
  75240. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  75241. }
  75242. }
  75243. declare module BABYLON {
  75244. /** @hidden */
  75245. export var sharpenPixelShader: {
  75246. name: string;
  75247. shader: string;
  75248. };
  75249. }
  75250. declare module BABYLON {
  75251. /**
  75252. * The SharpenPostProcess applies a sharpen kernel to every pixel
  75253. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  75254. */
  75255. export class SharpenPostProcess extends PostProcess {
  75256. /**
  75257. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  75258. */
  75259. colorAmount: number;
  75260. /**
  75261. * How much sharpness should be applied (default: 0.3)
  75262. */
  75263. edgeAmount: number;
  75264. /**
  75265. * Gets a string identifying the name of the class
  75266. * @returns "SharpenPostProcess" string
  75267. */
  75268. getClassName(): string;
  75269. /**
  75270. * Creates a new instance ConvolutionPostProcess
  75271. * @param name The name of the effect.
  75272. * @param options The required width/height ratio to downsize to before computing the render pass.
  75273. * @param camera The camera to apply the render pass to.
  75274. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75275. * @param engine The engine which the post process will be applied. (default: current engine)
  75276. * @param reusable If the post process can be reused on the same frame. (default: false)
  75277. * @param textureType Type of textures used when performing the post process. (default: 0)
  75278. * @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)
  75279. */
  75280. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  75281. /** @hidden */
  75282. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  75283. }
  75284. }
  75285. declare module BABYLON {
  75286. /**
  75287. * PostProcessRenderPipeline
  75288. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  75289. */
  75290. export class PostProcessRenderPipeline {
  75291. private engine;
  75292. private _renderEffects;
  75293. private _renderEffectsForIsolatedPass;
  75294. /**
  75295. * List of inspectable custom properties (used by the Inspector)
  75296. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  75297. */
  75298. inspectableCustomProperties: IInspectable[];
  75299. /**
  75300. * @hidden
  75301. */
  75302. protected _cameras: Camera[];
  75303. /** @hidden */
  75304. _name: string;
  75305. /**
  75306. * Gets pipeline name
  75307. */
  75308. get name(): string;
  75309. /** Gets the list of attached cameras */
  75310. get cameras(): Camera[];
  75311. /**
  75312. * Initializes a PostProcessRenderPipeline
  75313. * @param engine engine to add the pipeline to
  75314. * @param name name of the pipeline
  75315. */
  75316. constructor(engine: Engine, name: string);
  75317. /**
  75318. * Gets the class name
  75319. * @returns "PostProcessRenderPipeline"
  75320. */
  75321. getClassName(): string;
  75322. /**
  75323. * If all the render effects in the pipeline are supported
  75324. */
  75325. get isSupported(): boolean;
  75326. /**
  75327. * Adds an effect to the pipeline
  75328. * @param renderEffect the effect to add
  75329. */
  75330. addEffect(renderEffect: PostProcessRenderEffect): void;
  75331. /** @hidden */
  75332. _rebuild(): void;
  75333. /** @hidden */
  75334. _enableEffect(renderEffectName: string, cameras: Camera): void;
  75335. /** @hidden */
  75336. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  75337. /** @hidden */
  75338. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  75339. /** @hidden */
  75340. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  75341. /** @hidden */
  75342. _attachCameras(cameras: Camera, unique: boolean): void;
  75343. /** @hidden */
  75344. _attachCameras(cameras: Camera[], unique: boolean): void;
  75345. /** @hidden */
  75346. _detachCameras(cameras: Camera): void;
  75347. /** @hidden */
  75348. _detachCameras(cameras: Nullable<Camera[]>): void;
  75349. /** @hidden */
  75350. _update(): void;
  75351. /** @hidden */
  75352. _reset(): void;
  75353. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  75354. /**
  75355. * Sets the required values to the prepass renderer.
  75356. * @param prePassRenderer defines the prepass renderer to setup.
  75357. * @returns true if the pre pass is needed.
  75358. */
  75359. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  75360. /**
  75361. * Disposes of the pipeline
  75362. */
  75363. dispose(): void;
  75364. }
  75365. }
  75366. declare module BABYLON {
  75367. /**
  75368. * PostProcessRenderPipelineManager class
  75369. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  75370. */
  75371. export class PostProcessRenderPipelineManager {
  75372. private _renderPipelines;
  75373. /**
  75374. * Initializes a PostProcessRenderPipelineManager
  75375. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  75376. */
  75377. constructor();
  75378. /**
  75379. * Gets the list of supported render pipelines
  75380. */
  75381. get supportedPipelines(): PostProcessRenderPipeline[];
  75382. /**
  75383. * Adds a pipeline to the manager
  75384. * @param renderPipeline The pipeline to add
  75385. */
  75386. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  75387. /**
  75388. * Attaches a camera to the pipeline
  75389. * @param renderPipelineName The name of the pipeline to attach to
  75390. * @param cameras the camera to attach
  75391. * @param unique if the camera can be attached multiple times to the pipeline
  75392. */
  75393. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  75394. /**
  75395. * Detaches a camera from the pipeline
  75396. * @param renderPipelineName The name of the pipeline to detach from
  75397. * @param cameras the camera to detach
  75398. */
  75399. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  75400. /**
  75401. * Enables an effect by name on a pipeline
  75402. * @param renderPipelineName the name of the pipeline to enable the effect in
  75403. * @param renderEffectName the name of the effect to enable
  75404. * @param cameras the cameras that the effect should be enabled on
  75405. */
  75406. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  75407. /**
  75408. * Disables an effect by name on a pipeline
  75409. * @param renderPipelineName the name of the pipeline to disable the effect in
  75410. * @param renderEffectName the name of the effect to disable
  75411. * @param cameras the cameras that the effect should be disabled on
  75412. */
  75413. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  75414. /**
  75415. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  75416. */
  75417. update(): void;
  75418. /** @hidden */
  75419. _rebuild(): void;
  75420. /**
  75421. * Disposes of the manager and pipelines
  75422. */
  75423. dispose(): void;
  75424. }
  75425. }
  75426. declare module BABYLON {
  75427. interface Scene {
  75428. /** @hidden (Backing field) */
  75429. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  75430. /**
  75431. * Gets the postprocess render pipeline manager
  75432. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  75433. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  75434. */
  75435. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  75436. }
  75437. /**
  75438. * Defines the Render Pipeline scene component responsible to rendering pipelines
  75439. */
  75440. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  75441. /**
  75442. * The component name helpful to identify the component in the list of scene components.
  75443. */
  75444. readonly name: string;
  75445. /**
  75446. * The scene the component belongs to.
  75447. */
  75448. scene: Scene;
  75449. /**
  75450. * Creates a new instance of the component for the given scene
  75451. * @param scene Defines the scene to register the component in
  75452. */
  75453. constructor(scene: Scene);
  75454. /**
  75455. * Registers the component in a given scene
  75456. */
  75457. register(): void;
  75458. /**
  75459. * Rebuilds the elements related to this component in case of
  75460. * context lost for instance.
  75461. */
  75462. rebuild(): void;
  75463. /**
  75464. * Disposes the component and the associated resources
  75465. */
  75466. dispose(): void;
  75467. private _gatherRenderTargets;
  75468. }
  75469. }
  75470. declare module BABYLON {
  75471. /**
  75472. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  75473. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  75474. */
  75475. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  75476. private _scene;
  75477. private _camerasToBeAttached;
  75478. /**
  75479. * ID of the sharpen post process,
  75480. */
  75481. private readonly SharpenPostProcessId;
  75482. /**
  75483. * @ignore
  75484. * ID of the image processing post process;
  75485. */
  75486. readonly ImageProcessingPostProcessId: string;
  75487. /**
  75488. * @ignore
  75489. * ID of the Fast Approximate Anti-Aliasing post process;
  75490. */
  75491. readonly FxaaPostProcessId: string;
  75492. /**
  75493. * ID of the chromatic aberration post process,
  75494. */
  75495. private readonly ChromaticAberrationPostProcessId;
  75496. /**
  75497. * ID of the grain post process
  75498. */
  75499. private readonly GrainPostProcessId;
  75500. /**
  75501. * Sharpen post process which will apply a sharpen convolution to enhance edges
  75502. */
  75503. sharpen: SharpenPostProcess;
  75504. private _sharpenEffect;
  75505. private bloom;
  75506. /**
  75507. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  75508. */
  75509. depthOfField: DepthOfFieldEffect;
  75510. /**
  75511. * The Fast Approximate Anti-Aliasing post process which attempts to remove aliasing from an image.
  75512. */
  75513. fxaa: FxaaPostProcess;
  75514. /**
  75515. * Image post processing pass used to perform operations such as tone mapping or color grading.
  75516. */
  75517. imageProcessing: ImageProcessingPostProcess;
  75518. /**
  75519. * Chromatic aberration post process which will shift rgb colors in the image
  75520. */
  75521. chromaticAberration: ChromaticAberrationPostProcess;
  75522. private _chromaticAberrationEffect;
  75523. /**
  75524. * Grain post process which add noise to the image
  75525. */
  75526. grain: GrainPostProcess;
  75527. private _grainEffect;
  75528. /**
  75529. * Glow post process which adds a glow to emissive areas of the image
  75530. */
  75531. private _glowLayer;
  75532. /**
  75533. * Animations which can be used to tweak settings over a period of time
  75534. */
  75535. animations: Animation[];
  75536. private _imageProcessingConfigurationObserver;
  75537. private _sharpenEnabled;
  75538. private _bloomEnabled;
  75539. private _depthOfFieldEnabled;
  75540. private _depthOfFieldBlurLevel;
  75541. private _fxaaEnabled;
  75542. private _imageProcessingEnabled;
  75543. private _defaultPipelineTextureType;
  75544. private _bloomScale;
  75545. private _chromaticAberrationEnabled;
  75546. private _grainEnabled;
  75547. private _buildAllowed;
  75548. /**
  75549. * This is triggered each time the pipeline has been built.
  75550. */
  75551. onBuildObservable: Observable<DefaultRenderingPipeline>;
  75552. /**
  75553. * Gets active scene
  75554. */
  75555. get scene(): Scene;
  75556. /**
  75557. * Enable or disable the sharpen process from the pipeline
  75558. */
  75559. set sharpenEnabled(enabled: boolean);
  75560. get sharpenEnabled(): boolean;
  75561. private _resizeObserver;
  75562. private _hardwareScaleLevel;
  75563. private _bloomKernel;
  75564. /**
  75565. * Specifies the size of the bloom blur kernel, relative to the final output size
  75566. */
  75567. get bloomKernel(): number;
  75568. set bloomKernel(value: number);
  75569. /**
  75570. * Specifies the weight of the bloom in the final rendering
  75571. */
  75572. private _bloomWeight;
  75573. /**
  75574. * Specifies the luma threshold for the area that will be blurred by the bloom
  75575. */
  75576. private _bloomThreshold;
  75577. private _hdr;
  75578. /**
  75579. * The strength of the bloom.
  75580. */
  75581. set bloomWeight(value: number);
  75582. get bloomWeight(): number;
  75583. /**
  75584. * The strength of the bloom.
  75585. */
  75586. set bloomThreshold(value: number);
  75587. get bloomThreshold(): number;
  75588. /**
  75589. * The scale of the bloom, lower value will provide better performance.
  75590. */
  75591. set bloomScale(value: number);
  75592. get bloomScale(): number;
  75593. /**
  75594. * Enable or disable the bloom from the pipeline
  75595. */
  75596. set bloomEnabled(enabled: boolean);
  75597. get bloomEnabled(): boolean;
  75598. private _rebuildBloom;
  75599. /**
  75600. * If the depth of field is enabled.
  75601. */
  75602. get depthOfFieldEnabled(): boolean;
  75603. set depthOfFieldEnabled(enabled: boolean);
  75604. /**
  75605. * Blur level of the depth of field effect. (Higher blur will effect performance)
  75606. */
  75607. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  75608. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  75609. /**
  75610. * If the anti aliasing is enabled.
  75611. */
  75612. set fxaaEnabled(enabled: boolean);
  75613. get fxaaEnabled(): boolean;
  75614. private _samples;
  75615. /**
  75616. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  75617. */
  75618. set samples(sampleCount: number);
  75619. get samples(): number;
  75620. /**
  75621. * If image processing is enabled.
  75622. */
  75623. set imageProcessingEnabled(enabled: boolean);
  75624. get imageProcessingEnabled(): boolean;
  75625. /**
  75626. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  75627. */
  75628. set glowLayerEnabled(enabled: boolean);
  75629. get glowLayerEnabled(): boolean;
  75630. /**
  75631. * Gets the glow layer (or null if not defined)
  75632. */
  75633. get glowLayer(): Nullable<GlowLayer>;
  75634. /**
  75635. * Enable or disable the chromaticAberration process from the pipeline
  75636. */
  75637. set chromaticAberrationEnabled(enabled: boolean);
  75638. get chromaticAberrationEnabled(): boolean;
  75639. /**
  75640. * Enable or disable the grain process from the pipeline
  75641. */
  75642. set grainEnabled(enabled: boolean);
  75643. get grainEnabled(): boolean;
  75644. /**
  75645. * @constructor
  75646. * @param name - The rendering pipeline name (default: "")
  75647. * @param hdr - If high dynamic range textures should be used (default: true)
  75648. * @param scene - The scene linked to this pipeline (default: the last created scene)
  75649. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  75650. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  75651. */
  75652. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  75653. /**
  75654. * Get the class name
  75655. * @returns "DefaultRenderingPipeline"
  75656. */
  75657. getClassName(): string;
  75658. /**
  75659. * Force the compilation of the entire pipeline.
  75660. */
  75661. prepare(): void;
  75662. private _hasCleared;
  75663. private _prevPostProcess;
  75664. private _prevPrevPostProcess;
  75665. private _setAutoClearAndTextureSharing;
  75666. private _depthOfFieldSceneObserver;
  75667. private _buildPipeline;
  75668. private _disposePostProcesses;
  75669. /**
  75670. * Adds a camera to the pipeline
  75671. * @param camera the camera to be added
  75672. */
  75673. addCamera(camera: Camera): void;
  75674. /**
  75675. * Removes a camera from the pipeline
  75676. * @param camera the camera to remove
  75677. */
  75678. removeCamera(camera: Camera): void;
  75679. /**
  75680. * Dispose of the pipeline and stop all post processes
  75681. */
  75682. dispose(): void;
  75683. /**
  75684. * Serialize the rendering pipeline (Used when exporting)
  75685. * @returns the serialized object
  75686. */
  75687. serialize(): any;
  75688. /**
  75689. * Parse the serialized pipeline
  75690. * @param source Source pipeline.
  75691. * @param scene The scene to load the pipeline to.
  75692. * @param rootUrl The URL of the serialized pipeline.
  75693. * @returns An instantiated pipeline from the serialized object.
  75694. */
  75695. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  75696. }
  75697. }
  75698. declare module BABYLON {
  75699. /** @hidden */
  75700. export var lensHighlightsPixelShader: {
  75701. name: string;
  75702. shader: string;
  75703. };
  75704. }
  75705. declare module BABYLON {
  75706. /** @hidden */
  75707. export var depthOfFieldPixelShader: {
  75708. name: string;
  75709. shader: string;
  75710. };
  75711. }
  75712. declare module BABYLON {
  75713. /**
  75714. * BABYLON.JS Chromatic Aberration GLSL Shader
  75715. * Author: Olivier Guyot
  75716. * Separates very slightly R, G and B colors on the edges of the screen
  75717. * Inspired by Francois Tarlier & Martins Upitis
  75718. */
  75719. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  75720. /**
  75721. * @ignore
  75722. * The chromatic aberration PostProcess id in the pipeline
  75723. */
  75724. LensChromaticAberrationEffect: string;
  75725. /**
  75726. * @ignore
  75727. * The highlights enhancing PostProcess id in the pipeline
  75728. */
  75729. HighlightsEnhancingEffect: string;
  75730. /**
  75731. * @ignore
  75732. * The depth-of-field PostProcess id in the pipeline
  75733. */
  75734. LensDepthOfFieldEffect: string;
  75735. private _scene;
  75736. private _depthTexture;
  75737. private _grainTexture;
  75738. private _chromaticAberrationPostProcess;
  75739. private _highlightsPostProcess;
  75740. private _depthOfFieldPostProcess;
  75741. private _edgeBlur;
  75742. private _grainAmount;
  75743. private _chromaticAberration;
  75744. private _distortion;
  75745. private _highlightsGain;
  75746. private _highlightsThreshold;
  75747. private _dofDistance;
  75748. private _dofAperture;
  75749. private _dofDarken;
  75750. private _dofPentagon;
  75751. private _blurNoise;
  75752. /**
  75753. * @constructor
  75754. *
  75755. * Effect parameters are as follow:
  75756. * {
  75757. * chromatic_aberration: number; // from 0 to x (1 for realism)
  75758. * edge_blur: number; // from 0 to x (1 for realism)
  75759. * distortion: number; // from 0 to x (1 for realism)
  75760. * grain_amount: number; // from 0 to 1
  75761. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  75762. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  75763. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  75764. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  75765. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  75766. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  75767. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  75768. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  75769. * }
  75770. * Note: if an effect parameter is unset, effect is disabled
  75771. *
  75772. * @param name The rendering pipeline name
  75773. * @param parameters - An object containing all parameters (see above)
  75774. * @param scene The scene linked to this pipeline
  75775. * @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)
  75776. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75777. */
  75778. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  75779. /**
  75780. * Get the class name
  75781. * @returns "LensRenderingPipeline"
  75782. */
  75783. getClassName(): string;
  75784. /**
  75785. * Gets associated scene
  75786. */
  75787. get scene(): Scene;
  75788. /**
  75789. * Gets or sets the edge blur
  75790. */
  75791. get edgeBlur(): number;
  75792. set edgeBlur(value: number);
  75793. /**
  75794. * Gets or sets the grain amount
  75795. */
  75796. get grainAmount(): number;
  75797. set grainAmount(value: number);
  75798. /**
  75799. * Gets or sets the chromatic aberration amount
  75800. */
  75801. get chromaticAberration(): number;
  75802. set chromaticAberration(value: number);
  75803. /**
  75804. * Gets or sets the depth of field aperture
  75805. */
  75806. get dofAperture(): number;
  75807. set dofAperture(value: number);
  75808. /**
  75809. * Gets or sets the edge distortion
  75810. */
  75811. get edgeDistortion(): number;
  75812. set edgeDistortion(value: number);
  75813. /**
  75814. * Gets or sets the depth of field distortion
  75815. */
  75816. get dofDistortion(): number;
  75817. set dofDistortion(value: number);
  75818. /**
  75819. * Gets or sets the darken out of focus amount
  75820. */
  75821. get darkenOutOfFocus(): number;
  75822. set darkenOutOfFocus(value: number);
  75823. /**
  75824. * Gets or sets a boolean indicating if blur noise is enabled
  75825. */
  75826. get blurNoise(): boolean;
  75827. set blurNoise(value: boolean);
  75828. /**
  75829. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  75830. */
  75831. get pentagonBokeh(): boolean;
  75832. set pentagonBokeh(value: boolean);
  75833. /**
  75834. * Gets or sets the highlight grain amount
  75835. */
  75836. get highlightsGain(): number;
  75837. set highlightsGain(value: number);
  75838. /**
  75839. * Gets or sets the highlight threshold
  75840. */
  75841. get highlightsThreshold(): number;
  75842. set highlightsThreshold(value: number);
  75843. /**
  75844. * Sets the amount of blur at the edges
  75845. * @param amount blur amount
  75846. */
  75847. setEdgeBlur(amount: number): void;
  75848. /**
  75849. * Sets edge blur to 0
  75850. */
  75851. disableEdgeBlur(): void;
  75852. /**
  75853. * Sets the amount of grain
  75854. * @param amount Amount of grain
  75855. */
  75856. setGrainAmount(amount: number): void;
  75857. /**
  75858. * Set grain amount to 0
  75859. */
  75860. disableGrain(): void;
  75861. /**
  75862. * Sets the chromatic aberration amount
  75863. * @param amount amount of chromatic aberration
  75864. */
  75865. setChromaticAberration(amount: number): void;
  75866. /**
  75867. * Sets chromatic aberration amount to 0
  75868. */
  75869. disableChromaticAberration(): void;
  75870. /**
  75871. * Sets the EdgeDistortion amount
  75872. * @param amount amount of EdgeDistortion
  75873. */
  75874. setEdgeDistortion(amount: number): void;
  75875. /**
  75876. * Sets edge distortion to 0
  75877. */
  75878. disableEdgeDistortion(): void;
  75879. /**
  75880. * Sets the FocusDistance amount
  75881. * @param amount amount of FocusDistance
  75882. */
  75883. setFocusDistance(amount: number): void;
  75884. /**
  75885. * Disables depth of field
  75886. */
  75887. disableDepthOfField(): void;
  75888. /**
  75889. * Sets the Aperture amount
  75890. * @param amount amount of Aperture
  75891. */
  75892. setAperture(amount: number): void;
  75893. /**
  75894. * Sets the DarkenOutOfFocus amount
  75895. * @param amount amount of DarkenOutOfFocus
  75896. */
  75897. setDarkenOutOfFocus(amount: number): void;
  75898. private _pentagonBokehIsEnabled;
  75899. /**
  75900. * Creates a pentagon bokeh effect
  75901. */
  75902. enablePentagonBokeh(): void;
  75903. /**
  75904. * Disables the pentagon bokeh effect
  75905. */
  75906. disablePentagonBokeh(): void;
  75907. /**
  75908. * Enables noise blur
  75909. */
  75910. enableNoiseBlur(): void;
  75911. /**
  75912. * Disables noise blur
  75913. */
  75914. disableNoiseBlur(): void;
  75915. /**
  75916. * Sets the HighlightsGain amount
  75917. * @param amount amount of HighlightsGain
  75918. */
  75919. setHighlightsGain(amount: number): void;
  75920. /**
  75921. * Sets the HighlightsThreshold amount
  75922. * @param amount amount of HighlightsThreshold
  75923. */
  75924. setHighlightsThreshold(amount: number): void;
  75925. /**
  75926. * Disables highlights
  75927. */
  75928. disableHighlights(): void;
  75929. /**
  75930. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  75931. * @param disableDepthRender If the scene's depth rendering should be disabled (default: false)
  75932. */
  75933. dispose(disableDepthRender?: boolean): void;
  75934. private _createChromaticAberrationPostProcess;
  75935. private _createHighlightsPostProcess;
  75936. private _createDepthOfFieldPostProcess;
  75937. private _createGrainTexture;
  75938. }
  75939. }
  75940. declare module BABYLON {
  75941. /**
  75942. * Contains all parameters needed for the prepass to perform
  75943. * screen space subsurface scattering
  75944. */
  75945. export class SSAO2Configuration implements PrePassEffectConfiguration {
  75946. /**
  75947. * Is subsurface enabled
  75948. */
  75949. enabled: boolean;
  75950. /**
  75951. * Name of the configuration
  75952. */
  75953. name: string;
  75954. /**
  75955. * Textures that should be present in the MRT for this effect to work
  75956. */
  75957. readonly texturesRequired: number[];
  75958. }
  75959. }
  75960. declare module BABYLON {
  75961. /** @hidden */
  75962. export var ssao2PixelShader: {
  75963. name: string;
  75964. shader: string;
  75965. };
  75966. }
  75967. declare module BABYLON {
  75968. /** @hidden */
  75969. export var ssaoCombinePixelShader: {
  75970. name: string;
  75971. shader: string;
  75972. };
  75973. }
  75974. declare module BABYLON {
  75975. /**
  75976. * Render pipeline to produce ssao effect
  75977. */
  75978. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  75979. /**
  75980. * @ignore
  75981. * The PassPostProcess id in the pipeline that contains the original scene color
  75982. */
  75983. SSAOOriginalSceneColorEffect: string;
  75984. /**
  75985. * @ignore
  75986. * The SSAO PostProcess id in the pipeline
  75987. */
  75988. SSAORenderEffect: string;
  75989. /**
  75990. * @ignore
  75991. * The horizontal blur PostProcess id in the pipeline
  75992. */
  75993. SSAOBlurHRenderEffect: string;
  75994. /**
  75995. * @ignore
  75996. * The vertical blur PostProcess id in the pipeline
  75997. */
  75998. SSAOBlurVRenderEffect: string;
  75999. /**
  76000. * @ignore
  76001. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  76002. */
  76003. SSAOCombineRenderEffect: string;
  76004. /**
  76005. * The output strength of the SSAO post-process. Default value is 1.0.
  76006. */
  76007. totalStrength: number;
  76008. /**
  76009. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  76010. */
  76011. maxZ: number;
  76012. /**
  76013. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  76014. */
  76015. minZAspect: number;
  76016. private _samples;
  76017. /**
  76018. * Number of samples used for the SSAO calculations. Default value is 8
  76019. */
  76020. set samples(n: number);
  76021. get samples(): number;
  76022. private _textureSamples;
  76023. /**
  76024. * Number of samples to use for antialiasing
  76025. */
  76026. set textureSamples(n: number);
  76027. get textureSamples(): number;
  76028. /**
  76029. * Force rendering the geometry through geometry buffer
  76030. */
  76031. private _forceGeometryBuffer;
  76032. /**
  76033. * Ratio object used for SSAO ratio and blur ratio
  76034. */
  76035. private _ratio;
  76036. /**
  76037. * Dynamically generated sphere sampler.
  76038. */
  76039. private _sampleSphere;
  76040. /**
  76041. * Blur filter offsets
  76042. */
  76043. private _samplerOffsets;
  76044. private _expensiveBlur;
  76045. /**
  76046. * If bilateral blur should be used
  76047. */
  76048. set expensiveBlur(b: boolean);
  76049. get expensiveBlur(): boolean;
  76050. /**
  76051. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  76052. */
  76053. radius: number;
  76054. /**
  76055. * The base color of the SSAO post-process
  76056. * The final result is "base + ssao" between [0, 1]
  76057. */
  76058. base: number;
  76059. /**
  76060. * Support test.
  76061. */
  76062. static get IsSupported(): boolean;
  76063. private _scene;
  76064. private _randomTexture;
  76065. private _originalColorPostProcess;
  76066. private _ssaoPostProcess;
  76067. private _blurHPostProcess;
  76068. private _blurVPostProcess;
  76069. private _ssaoCombinePostProcess;
  76070. private _prePassRenderer;
  76071. /**
  76072. * Gets active scene
  76073. */
  76074. get scene(): Scene;
  76075. /**
  76076. * @constructor
  76077. * @param name The rendering pipeline name
  76078. * @param scene The scene linked to this pipeline
  76079. * @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 }
  76080. * @param cameras The array of cameras that the rendering pipeline will be attached to
  76081. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  76082. */
  76083. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  76084. /**
  76085. * Get the class name
  76086. * @returns "SSAO2RenderingPipeline"
  76087. */
  76088. getClassName(): string;
  76089. /**
  76090. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  76091. */
  76092. dispose(disableGeometryBufferRenderer?: boolean): void;
  76093. private _createBlurPostProcess;
  76094. /** @hidden */
  76095. _rebuild(): void;
  76096. private _bits;
  76097. private _radicalInverse_VdC;
  76098. private _hammersley;
  76099. private _hemisphereSample_uniform;
  76100. private _generateHemisphere;
  76101. private _getDefinesForSSAO;
  76102. private static readonly ORTHO_DEPTH_PROJECTION;
  76103. private static readonly PERSPECTIVE_DEPTH_PROJECTION;
  76104. private _createSSAOPostProcess;
  76105. private _createSSAOCombinePostProcess;
  76106. private _createRandomTexture;
  76107. /**
  76108. * Serialize the rendering pipeline (Used when exporting)
  76109. * @returns the serialized object
  76110. */
  76111. serialize(): any;
  76112. /**
  76113. * Parse the serialized pipeline
  76114. * @param source Source pipeline.
  76115. * @param scene The scene to load the pipeline to.
  76116. * @param rootUrl The URL of the serialized pipeline.
  76117. * @returns An instantiated pipeline from the serialized object.
  76118. */
  76119. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  76120. }
  76121. }
  76122. declare module BABYLON {
  76123. /** @hidden */
  76124. export var ssaoPixelShader: {
  76125. name: string;
  76126. shader: string;
  76127. };
  76128. }
  76129. declare module BABYLON {
  76130. /**
  76131. * Render pipeline to produce ssao effect
  76132. */
  76133. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  76134. /**
  76135. * @ignore
  76136. * The PassPostProcess id in the pipeline that contains the original scene color
  76137. */
  76138. SSAOOriginalSceneColorEffect: string;
  76139. /**
  76140. * @ignore
  76141. * The SSAO PostProcess id in the pipeline
  76142. */
  76143. SSAORenderEffect: string;
  76144. /**
  76145. * @ignore
  76146. * The horizontal blur PostProcess id in the pipeline
  76147. */
  76148. SSAOBlurHRenderEffect: string;
  76149. /**
  76150. * @ignore
  76151. * The vertical blur PostProcess id in the pipeline
  76152. */
  76153. SSAOBlurVRenderEffect: string;
  76154. /**
  76155. * @ignore
  76156. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  76157. */
  76158. SSAOCombineRenderEffect: string;
  76159. /**
  76160. * The output strength of the SSAO post-process. Default value is 1.0.
  76161. */
  76162. totalStrength: number;
  76163. /**
  76164. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  76165. */
  76166. radius: number;
  76167. /**
  76168. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  76169. * Must not be equal to fallOff and superior to fallOff.
  76170. * Default value is 0.0075
  76171. */
  76172. area: number;
  76173. /**
  76174. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  76175. * Must not be equal to area and inferior to area.
  76176. * Default value is 0.000001
  76177. */
  76178. fallOff: number;
  76179. /**
  76180. * The base color of the SSAO post-process
  76181. * The final result is "base + ssao" between [0, 1]
  76182. */
  76183. base: number;
  76184. private _scene;
  76185. private _depthTexture;
  76186. private _randomTexture;
  76187. private _originalColorPostProcess;
  76188. private _ssaoPostProcess;
  76189. private _blurHPostProcess;
  76190. private _blurVPostProcess;
  76191. private _ssaoCombinePostProcess;
  76192. private _firstUpdate;
  76193. /**
  76194. * Gets active scene
  76195. */
  76196. get scene(): Scene;
  76197. /**
  76198. * @constructor
  76199. * @param name - The rendering pipeline name
  76200. * @param scene - The scene linked to this pipeline
  76201. * @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 }
  76202. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  76203. */
  76204. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  76205. /**
  76206. * Get the class name
  76207. * @returns "SSAORenderingPipeline"
  76208. */
  76209. getClassName(): string;
  76210. /**
  76211. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  76212. */
  76213. dispose(disableDepthRender?: boolean): void;
  76214. private _createBlurPostProcess;
  76215. /** @hidden */
  76216. _rebuild(): void;
  76217. private _createSSAOPostProcess;
  76218. private _createSSAOCombinePostProcess;
  76219. private _createRandomTexture;
  76220. }
  76221. }
  76222. declare module BABYLON {
  76223. /**
  76224. * Contains all parameters needed for the prepass to perform
  76225. * screen space reflections
  76226. */
  76227. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  76228. /**
  76229. * Is ssr enabled
  76230. */
  76231. enabled: boolean;
  76232. /**
  76233. * Name of the configuration
  76234. */
  76235. name: string;
  76236. /**
  76237. * Textures that should be present in the MRT for this effect to work
  76238. */
  76239. readonly texturesRequired: number[];
  76240. }
  76241. }
  76242. declare module BABYLON {
  76243. /** @hidden */
  76244. export var screenSpaceReflectionPixelShader: {
  76245. name: string;
  76246. shader: string;
  76247. };
  76248. }
  76249. declare module BABYLON {
  76250. /**
  76251. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  76252. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  76253. */
  76254. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  76255. /**
  76256. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  76257. */
  76258. threshold: number;
  76259. /**
  76260. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  76261. */
  76262. strength: number;
  76263. /**
  76264. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  76265. */
  76266. reflectionSpecularFalloffExponent: number;
  76267. /**
  76268. * 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]
  76269. */
  76270. step: number;
  76271. /**
  76272. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  76273. */
  76274. roughnessFactor: number;
  76275. private _forceGeometryBuffer;
  76276. private _geometryBufferRenderer;
  76277. private _prePassRenderer;
  76278. private _enableSmoothReflections;
  76279. private _reflectionSamples;
  76280. private _smoothSteps;
  76281. /**
  76282. * Gets a string identifying the name of the class
  76283. * @returns "ScreenSpaceReflectionPostProcess" string
  76284. */
  76285. getClassName(): string;
  76286. /**
  76287. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  76288. * @param name The name of the effect.
  76289. * @param scene The scene containing the objects to calculate reflections.
  76290. * @param options The required width/height ratio to downsize to before computing the render pass.
  76291. * @param camera The camera to apply the render pass to.
  76292. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  76293. * @param engine The engine which the post process will be applied. (default: current engine)
  76294. * @param reusable If the post process can be reused on the same frame. (default: false)
  76295. * @param textureType Type of textures used when performing the post process. (default: 0)
  76296. * @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)
  76297. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  76298. */
  76299. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  76300. /**
  76301. * Gets whether or not smoothing reflections is enabled.
  76302. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  76303. */
  76304. get enableSmoothReflections(): boolean;
  76305. /**
  76306. * Sets whether or not smoothing reflections is enabled.
  76307. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  76308. */
  76309. set enableSmoothReflections(enabled: boolean);
  76310. /**
  76311. * Gets the number of samples taken while computing reflections. More samples count is high,
  76312. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  76313. */
  76314. get reflectionSamples(): number;
  76315. /**
  76316. * Sets the number of samples taken while computing reflections. More samples count is high,
  76317. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  76318. */
  76319. set reflectionSamples(samples: number);
  76320. /**
  76321. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  76322. * more the post-process will require GPU power and can generate a drop in FPS.
  76323. * Default value (5.0) work pretty well in all cases but can be adjusted.
  76324. */
  76325. get smoothSteps(): number;
  76326. set smoothSteps(steps: number);
  76327. private _updateEffectDefines;
  76328. /** @hidden */
  76329. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  76330. }
  76331. }
  76332. declare module BABYLON {
  76333. /** @hidden */
  76334. export var standardPixelShader: {
  76335. name: string;
  76336. shader: string;
  76337. };
  76338. }
  76339. declare module BABYLON {
  76340. /**
  76341. * Standard rendering pipeline
  76342. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  76343. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  76344. */
  76345. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  76346. /**
  76347. * Public members
  76348. */
  76349. /**
  76350. * Post-process which contains the original scene color before the pipeline applies all the effects
  76351. */
  76352. originalPostProcess: Nullable<PostProcess>;
  76353. /**
  76354. * Post-process used to down scale an image x4
  76355. */
  76356. downSampleX4PostProcess: Nullable<PostProcess>;
  76357. /**
  76358. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  76359. */
  76360. brightPassPostProcess: Nullable<PostProcess>;
  76361. /**
  76362. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  76363. */
  76364. blurHPostProcesses: PostProcess[];
  76365. /**
  76366. * Post-process array storing all the vertical blur post-processes used by the pipeline
  76367. */
  76368. blurVPostProcesses: PostProcess[];
  76369. /**
  76370. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  76371. */
  76372. textureAdderPostProcess: Nullable<PostProcess>;
  76373. /**
  76374. * Post-process used to create volumetric lighting effect
  76375. */
  76376. volumetricLightPostProcess: Nullable<PostProcess>;
  76377. /**
  76378. * Post-process used to smooth the previous volumetric light post-process on the X axis
  76379. */
  76380. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  76381. /**
  76382. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  76383. */
  76384. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  76385. /**
  76386. * Post-process used to merge the volumetric light effect and the real scene color
  76387. */
  76388. volumetricLightMergePostProces: Nullable<PostProcess>;
  76389. /**
  76390. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  76391. */
  76392. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  76393. /**
  76394. * Base post-process used to calculate the average luminance of the final image for HDR
  76395. */
  76396. luminancePostProcess: Nullable<PostProcess>;
  76397. /**
  76398. * Post-processes used to create down sample post-processes in order to get
  76399. * the average luminance of the final image for HDR
  76400. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  76401. */
  76402. luminanceDownSamplePostProcesses: PostProcess[];
  76403. /**
  76404. * Post-process used to create a HDR effect (light adaptation)
  76405. */
  76406. hdrPostProcess: Nullable<PostProcess>;
  76407. /**
  76408. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  76409. */
  76410. textureAdderFinalPostProcess: Nullable<PostProcess>;
  76411. /**
  76412. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  76413. */
  76414. lensFlareFinalPostProcess: Nullable<PostProcess>;
  76415. /**
  76416. * Post-process used to merge the final HDR post-process and the real scene color
  76417. */
  76418. hdrFinalPostProcess: Nullable<PostProcess>;
  76419. /**
  76420. * Post-process used to create a lens flare effect
  76421. */
  76422. lensFlarePostProcess: Nullable<PostProcess>;
  76423. /**
  76424. * Post-process that merges the result of the lens flare post-process and the real scene color
  76425. */
  76426. lensFlareComposePostProcess: Nullable<PostProcess>;
  76427. /**
  76428. * Post-process used to create a motion blur effect
  76429. */
  76430. motionBlurPostProcess: Nullable<PostProcess>;
  76431. /**
  76432. * Post-process used to create a depth of field effect
  76433. */
  76434. depthOfFieldPostProcess: Nullable<PostProcess>;
  76435. /**
  76436. * The Fast Approximate Anti-Aliasing post process which attempts to remove aliasing from an image.
  76437. */
  76438. fxaaPostProcess: Nullable<FxaaPostProcess>;
  76439. /**
  76440. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  76441. */
  76442. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  76443. /**
  76444. * Represents the brightness threshold in order to configure the illuminated surfaces
  76445. */
  76446. brightThreshold: number;
  76447. /**
  76448. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  76449. */
  76450. blurWidth: number;
  76451. /**
  76452. * Sets if the blur for highlighted surfaces must be only horizontal
  76453. */
  76454. horizontalBlur: boolean;
  76455. /**
  76456. * Gets the overall exposure used by the pipeline
  76457. */
  76458. get exposure(): number;
  76459. /**
  76460. * Sets the overall exposure used by the pipeline
  76461. */
  76462. set exposure(value: number);
  76463. /**
  76464. * Texture used typically to simulate "dirty" on camera lens
  76465. */
  76466. lensTexture: Nullable<Texture>;
  76467. /**
  76468. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  76469. */
  76470. volumetricLightCoefficient: number;
  76471. /**
  76472. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  76473. */
  76474. volumetricLightPower: number;
  76475. /**
  76476. * Used the set the blur intensity to smooth the volumetric lights
  76477. */
  76478. volumetricLightBlurScale: number;
  76479. /**
  76480. * Light (spot or directional) used to generate the volumetric lights rays
  76481. * The source light must have a shadow generate so the pipeline can get its
  76482. * depth map
  76483. */
  76484. sourceLight: Nullable<SpotLight | DirectionalLight>;
  76485. /**
  76486. * For eye adaptation, represents the minimum luminance the eye can see
  76487. */
  76488. hdrMinimumLuminance: number;
  76489. /**
  76490. * For eye adaptation, represents the decrease luminance speed
  76491. */
  76492. hdrDecreaseRate: number;
  76493. /**
  76494. * For eye adaptation, represents the increase luminance speed
  76495. */
  76496. hdrIncreaseRate: number;
  76497. /**
  76498. * Gets whether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  76499. */
  76500. get hdrAutoExposure(): boolean;
  76501. /**
  76502. * Sets whether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  76503. */
  76504. set hdrAutoExposure(value: boolean);
  76505. /**
  76506. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  76507. */
  76508. lensColorTexture: Nullable<Texture>;
  76509. /**
  76510. * The overall strengh for the lens flare effect
  76511. */
  76512. lensFlareStrength: number;
  76513. /**
  76514. * Dispersion coefficient for lens flare ghosts
  76515. */
  76516. lensFlareGhostDispersal: number;
  76517. /**
  76518. * Main lens flare halo width
  76519. */
  76520. lensFlareHaloWidth: number;
  76521. /**
  76522. * Based on the lens distortion effect, defines how much the lens flare result
  76523. * is distorted
  76524. */
  76525. lensFlareDistortionStrength: number;
  76526. /**
  76527. * Configures the blur intensity used for for lens flare (halo)
  76528. */
  76529. lensFlareBlurWidth: number;
  76530. /**
  76531. * Lens star texture must be used to simulate rays on the flares and is available
  76532. * in the documentation
  76533. */
  76534. lensStarTexture: Nullable<Texture>;
  76535. /**
  76536. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  76537. * flare effect by taking account of the dirt texture
  76538. */
  76539. lensFlareDirtTexture: Nullable<Texture>;
  76540. /**
  76541. * Represents the focal length for the depth of field effect
  76542. */
  76543. depthOfFieldDistance: number;
  76544. /**
  76545. * Represents the blur intensity for the blurred part of the depth of field effect
  76546. */
  76547. depthOfFieldBlurWidth: number;
  76548. /**
  76549. * Gets how much the image is blurred by the movement while using the motion blur post-process
  76550. */
  76551. get motionStrength(): number;
  76552. /**
  76553. * Sets how much the image is blurred by the movement while using the motion blur post-process
  76554. */
  76555. set motionStrength(strength: number);
  76556. /**
  76557. * Gets whether or not the motion blur post-process is object based or screen based.
  76558. */
  76559. get objectBasedMotionBlur(): boolean;
  76560. /**
  76561. * Sets whether or not the motion blur post-process should be object based or screen based
  76562. */
  76563. set objectBasedMotionBlur(value: boolean);
  76564. /**
  76565. * List of animations for the pipeline (IAnimatable implementation)
  76566. */
  76567. animations: Animation[];
  76568. /**
  76569. * Private members
  76570. */
  76571. private _scene;
  76572. private _currentDepthOfFieldSource;
  76573. private _basePostProcess;
  76574. private _fixedExposure;
  76575. private _currentExposure;
  76576. private _hdrAutoExposure;
  76577. private _hdrCurrentLuminance;
  76578. private _motionStrength;
  76579. private _isObjectBasedMotionBlur;
  76580. private _floatTextureType;
  76581. private _camerasToBeAttached;
  76582. private _ratio;
  76583. private _bloomEnabled;
  76584. private _depthOfFieldEnabled;
  76585. private _vlsEnabled;
  76586. private _lensFlareEnabled;
  76587. private _hdrEnabled;
  76588. private _motionBlurEnabled;
  76589. private _fxaaEnabled;
  76590. private _screenSpaceReflectionsEnabled;
  76591. private _motionBlurSamples;
  76592. private _volumetricLightStepsCount;
  76593. private _samples;
  76594. /**
  76595. * @ignore
  76596. * Specifies if the bloom pipeline is enabled
  76597. */
  76598. get BloomEnabled(): boolean;
  76599. set BloomEnabled(enabled: boolean);
  76600. /**
  76601. * @ignore
  76602. * Specifies if the depth of field pipeline is enabled
  76603. */
  76604. get DepthOfFieldEnabled(): boolean;
  76605. set DepthOfFieldEnabled(enabled: boolean);
  76606. /**
  76607. * @ignore
  76608. * Specifies if the lens flare pipeline is enabled
  76609. */
  76610. get LensFlareEnabled(): boolean;
  76611. set LensFlareEnabled(enabled: boolean);
  76612. /**
  76613. * @ignore
  76614. * Specifies if the HDR pipeline is enabled
  76615. */
  76616. get HDREnabled(): boolean;
  76617. set HDREnabled(enabled: boolean);
  76618. /**
  76619. * @ignore
  76620. * Specifies if the volumetric lights scattering effect is enabled
  76621. */
  76622. get VLSEnabled(): boolean;
  76623. set VLSEnabled(enabled: boolean);
  76624. /**
  76625. * @ignore
  76626. * Specifies if the motion blur effect is enabled
  76627. */
  76628. get MotionBlurEnabled(): boolean;
  76629. set MotionBlurEnabled(enabled: boolean);
  76630. /**
  76631. * Specifies if anti-aliasing is enabled
  76632. */
  76633. get fxaaEnabled(): boolean;
  76634. set fxaaEnabled(enabled: boolean);
  76635. /**
  76636. * Specifies if screen space reflections are enabled.
  76637. */
  76638. get screenSpaceReflectionsEnabled(): boolean;
  76639. set screenSpaceReflectionsEnabled(enabled: boolean);
  76640. /**
  76641. * Specifies the number of steps used to calculate the volumetric lights
  76642. * Typically in interval [50, 200]
  76643. */
  76644. get volumetricLightStepsCount(): number;
  76645. set volumetricLightStepsCount(count: number);
  76646. /**
  76647. * Specifies the number of samples used for the motion blur effect
  76648. * Typically in interval [16, 64]
  76649. */
  76650. get motionBlurSamples(): number;
  76651. set motionBlurSamples(samples: number);
  76652. /**
  76653. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  76654. */
  76655. get samples(): number;
  76656. set samples(sampleCount: number);
  76657. /**
  76658. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  76659. * @constructor
  76660. * @param name The rendering pipeline name
  76661. * @param scene The scene linked to this pipeline
  76662. * @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)
  76663. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  76664. * @param cameras The array of cameras that the rendering pipeline will be attached to
  76665. */
  76666. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  76667. private _buildPipeline;
  76668. private _createDownSampleX4PostProcess;
  76669. private _createBrightPassPostProcess;
  76670. private _createBlurPostProcesses;
  76671. private _createTextureAdderPostProcess;
  76672. private _createVolumetricLightPostProcess;
  76673. private _createLuminancePostProcesses;
  76674. private _createHdrPostProcess;
  76675. private _createLensFlarePostProcess;
  76676. private _createDepthOfFieldPostProcess;
  76677. private _createMotionBlurPostProcess;
  76678. private _getDepthTexture;
  76679. private _disposePostProcesses;
  76680. /**
  76681. * Dispose of the pipeline and stop all post processes
  76682. */
  76683. dispose(): void;
  76684. /**
  76685. * Serialize the rendering pipeline (Used when exporting)
  76686. * @returns the serialized object
  76687. */
  76688. serialize(): any;
  76689. /**
  76690. * Parse the serialized pipeline
  76691. * @param source Source pipeline.
  76692. * @param scene The scene to load the pipeline to.
  76693. * @param rootUrl The URL of the serialized pipeline.
  76694. * @returns An instantiated pipeline from the serialized object.
  76695. */
  76696. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  76697. /**
  76698. * Luminance steps
  76699. */
  76700. static LuminanceSteps: number;
  76701. }
  76702. }
  76703. declare module BABYLON {
  76704. /** @hidden */
  76705. export var tonemapPixelShader: {
  76706. name: string;
  76707. shader: string;
  76708. };
  76709. }
  76710. declare module BABYLON {
  76711. /** Defines operator used for tonemapping */
  76712. export enum TonemappingOperator {
  76713. /** Hable */
  76714. Hable = 0,
  76715. /** Reinhard */
  76716. Reinhard = 1,
  76717. /** HejiDawson */
  76718. HejiDawson = 2,
  76719. /** Photographic */
  76720. Photographic = 3
  76721. }
  76722. /**
  76723. * Defines a post process to apply tone mapping
  76724. */
  76725. export class TonemapPostProcess extends PostProcess {
  76726. private _operator;
  76727. /** Defines the required exposure adjustment */
  76728. exposureAdjustment: number;
  76729. /**
  76730. * Gets a string identifying the name of the class
  76731. * @returns "TonemapPostProcess" string
  76732. */
  76733. getClassName(): string;
  76734. /**
  76735. * Creates a new TonemapPostProcess
  76736. * @param name defines the name of the postprocess
  76737. * @param _operator defines the operator to use
  76738. * @param exposureAdjustment defines the required exposure adjustement
  76739. * @param camera defines the camera to use (can be null)
  76740. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  76741. * @param engine defines the hosting engine (can be ignore if camera is set)
  76742. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  76743. */
  76744. constructor(name: string, _operator: TonemappingOperator,
  76745. /** Defines the required exposure adjustment */
  76746. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  76747. }
  76748. }
  76749. declare module BABYLON {
  76750. /** @hidden */
  76751. export var volumetricLightScatteringPixelShader: {
  76752. name: string;
  76753. shader: string;
  76754. };
  76755. }
  76756. declare module BABYLON {
  76757. /** @hidden */
  76758. export var volumetricLightScatteringPassVertexShader: {
  76759. name: string;
  76760. shader: string;
  76761. };
  76762. }
  76763. declare module BABYLON {
  76764. /** @hidden */
  76765. export var volumetricLightScatteringPassPixelShader: {
  76766. name: string;
  76767. shader: string;
  76768. };
  76769. }
  76770. declare module BABYLON {
  76771. /**
  76772. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  76773. */
  76774. export class VolumetricLightScatteringPostProcess extends PostProcess {
  76775. private _volumetricLightScatteringPass;
  76776. private _volumetricLightScatteringRTT;
  76777. private _viewPort;
  76778. private _screenCoordinates;
  76779. private _cachedDefines;
  76780. /**
  76781. * If not undefined, the mesh position is computed from the attached node position
  76782. */
  76783. attachedNode: {
  76784. position: Vector3;
  76785. };
  76786. /**
  76787. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  76788. */
  76789. customMeshPosition: Vector3;
  76790. /**
  76791. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  76792. */
  76793. useCustomMeshPosition: boolean;
  76794. /**
  76795. * If the post-process should inverse the light scattering direction
  76796. */
  76797. invert: boolean;
  76798. /**
  76799. * The internal mesh used by the post-process
  76800. */
  76801. mesh: Mesh;
  76802. /**
  76803. * @hidden
  76804. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  76805. */
  76806. get useDiffuseColor(): boolean;
  76807. set useDiffuseColor(useDiffuseColor: boolean);
  76808. /**
  76809. * Array containing the excluded meshes not rendered in the internal pass
  76810. */
  76811. excludedMeshes: AbstractMesh[];
  76812. /**
  76813. * Controls the overall intensity of the post-process
  76814. */
  76815. exposure: number;
  76816. /**
  76817. * Dissipates each sample's contribution in range [0, 1]
  76818. */
  76819. decay: number;
  76820. /**
  76821. * Controls the overall intensity of each sample
  76822. */
  76823. weight: number;
  76824. /**
  76825. * Controls the density of each sample
  76826. */
  76827. density: number;
  76828. /**
  76829. * @constructor
  76830. * @param name The post-process name
  76831. * @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)
  76832. * @param camera The camera that the post-process will be attached to
  76833. * @param mesh The mesh used to create the light scattering
  76834. * @param samples The post-process quality, default 100
  76835. * @param samplingModeThe post-process filtering mode
  76836. * @param engine The babylon engine
  76837. * @param reusable If the post-process is reusable
  76838. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  76839. */
  76840. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  76841. /**
  76842. * Returns the string "VolumetricLightScatteringPostProcess"
  76843. * @returns "VolumetricLightScatteringPostProcess"
  76844. */
  76845. getClassName(): string;
  76846. private _isReady;
  76847. /**
  76848. * Sets the new light position for light scattering effect
  76849. * @param position The new custom light position
  76850. */
  76851. setCustomMeshPosition(position: Vector3): void;
  76852. /**
  76853. * Returns the light position for light scattering effect
  76854. * @return Vector3 The custom light position
  76855. */
  76856. getCustomMeshPosition(): Vector3;
  76857. /**
  76858. * Disposes the internal assets and detaches the post-process from the camera
  76859. */
  76860. dispose(camera: Camera): void;
  76861. /**
  76862. * Returns the render target texture used by the post-process
  76863. * @return the render target texture used by the post-process
  76864. */
  76865. getPass(): RenderTargetTexture;
  76866. private _meshExcluded;
  76867. private _createPass;
  76868. private _updateMeshScreenCoordinates;
  76869. /**
  76870. * Creates a default mesh for the Volumeric Light Scattering post-process
  76871. * @param name The mesh name
  76872. * @param scene The scene where to create the mesh
  76873. * @return the default mesh
  76874. */
  76875. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  76876. }
  76877. }
  76878. declare module BABYLON {
  76879. /** @hidden */
  76880. export var screenSpaceCurvaturePixelShader: {
  76881. name: string;
  76882. shader: string;
  76883. };
  76884. }
  76885. declare module BABYLON {
  76886. /**
  76887. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  76888. */
  76889. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  76890. /**
  76891. * Defines how much ridge the curvature effect displays.
  76892. */
  76893. ridge: number;
  76894. /**
  76895. * Defines how much valley the curvature effect displays.
  76896. */
  76897. valley: number;
  76898. private _geometryBufferRenderer;
  76899. /**
  76900. * Gets a string identifying the name of the class
  76901. * @returns "ScreenSpaceCurvaturePostProcess" string
  76902. */
  76903. getClassName(): string;
  76904. /**
  76905. * Creates a new instance ScreenSpaceCurvaturePostProcess
  76906. * @param name The name of the effect.
  76907. * @param scene The scene containing the objects to blur according to their velocity.
  76908. * @param options The required width/height ratio to downsize to before computing the render pass.
  76909. * @param camera The camera to apply the render pass to.
  76910. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  76911. * @param engine The engine which the post process will be applied. (default: current engine)
  76912. * @param reusable If the post process can be reused on the same frame. (default: false)
  76913. * @param textureType Type of textures used when performing the post process. (default: 0)
  76914. * @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)
  76915. */
  76916. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  76917. /**
  76918. * Support test.
  76919. */
  76920. static get IsSupported(): boolean;
  76921. /** @hidden */
  76922. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  76923. }
  76924. }
  76925. declare module BABYLON {
  76926. interface Scene {
  76927. /** @hidden (Backing field) */
  76928. _boundingBoxRenderer: BoundingBoxRenderer;
  76929. /** @hidden (Backing field) */
  76930. _forceShowBoundingBoxes: boolean;
  76931. /**
  76932. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  76933. */
  76934. forceShowBoundingBoxes: boolean;
  76935. /**
  76936. * Gets the bounding box renderer associated with the scene
  76937. * @returns a BoundingBoxRenderer
  76938. */
  76939. getBoundingBoxRenderer(): BoundingBoxRenderer;
  76940. }
  76941. interface AbstractMesh {
  76942. /** @hidden (Backing field) */
  76943. _showBoundingBox: boolean;
  76944. /**
  76945. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  76946. */
  76947. showBoundingBox: boolean;
  76948. }
  76949. /**
  76950. * Component responsible of rendering the bounding box of the meshes in a scene.
  76951. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  76952. */
  76953. export class BoundingBoxRenderer implements ISceneComponent {
  76954. /**
  76955. * The component name helpful to identify the component in the list of scene components.
  76956. */
  76957. readonly name: string;
  76958. /**
  76959. * The scene the component belongs to.
  76960. */
  76961. scene: Scene;
  76962. /**
  76963. * Color of the bounding box lines placed in front of an object
  76964. */
  76965. frontColor: Color3;
  76966. /**
  76967. * Color of the bounding box lines placed behind an object
  76968. */
  76969. backColor: Color3;
  76970. /**
  76971. * Defines if the renderer should show the back lines or not
  76972. */
  76973. showBackLines: boolean;
  76974. /**
  76975. * Observable raised before rendering a bounding box
  76976. */
  76977. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  76978. /**
  76979. * Observable raised after rendering a bounding box
  76980. */
  76981. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  76982. /**
  76983. * Observable raised after resources are created
  76984. */
  76985. onResourcesReadyObservable: Observable<BoundingBoxRenderer>;
  76986. /**
  76987. * When false, no bounding boxes will be rendered
  76988. */
  76989. enabled: boolean;
  76990. /**
  76991. * @hidden
  76992. */
  76993. renderList: SmartArray<BoundingBox>;
  76994. private _colorShader;
  76995. private _vertexBuffers;
  76996. private _indexBuffer;
  76997. private _fillIndexBuffer;
  76998. private _fillIndexData;
  76999. /**
  77000. * Instantiates a new bounding box renderer in a scene.
  77001. * @param scene the scene the renderer renders in
  77002. */
  77003. constructor(scene: Scene);
  77004. /**
  77005. * Registers the component in a given scene
  77006. */
  77007. register(): void;
  77008. private _evaluateSubMesh;
  77009. private _preActiveMesh;
  77010. private _prepareResources;
  77011. private _createIndexBuffer;
  77012. /**
  77013. * Rebuilds the elements related to this component in case of
  77014. * context lost for instance.
  77015. */
  77016. rebuild(): void;
  77017. /**
  77018. * @hidden
  77019. */
  77020. reset(): void;
  77021. /**
  77022. * Render the bounding boxes of a specific rendering group
  77023. * @param renderingGroupId defines the rendering group to render
  77024. */
  77025. render(renderingGroupId: number): void;
  77026. /**
  77027. * In case of occlusion queries, we can render the occlusion bounding box through this method
  77028. * @param mesh Define the mesh to render the occlusion bounding box for
  77029. */
  77030. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  77031. /**
  77032. * Dispose and release the resources attached to this renderer.
  77033. */
  77034. dispose(): void;
  77035. }
  77036. }
  77037. declare module BABYLON {
  77038. interface Scene {
  77039. /** @hidden (Backing field) */
  77040. _depthRenderer: {
  77041. [id: string]: DepthRenderer;
  77042. };
  77043. /**
  77044. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  77045. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  77046. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  77047. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  77048. * @returns the created depth renderer
  77049. */
  77050. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  77051. /**
  77052. * Disables a depth renderer for a given camera
  77053. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  77054. */
  77055. disableDepthRenderer(camera?: Nullable<Camera>): void;
  77056. }
  77057. /**
  77058. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  77059. * in several rendering techniques.
  77060. */
  77061. export class DepthRendererSceneComponent implements ISceneComponent {
  77062. /**
  77063. * The component name helpful to identify the component in the list of scene components.
  77064. */
  77065. readonly name: string;
  77066. /**
  77067. * The scene the component belongs to.
  77068. */
  77069. scene: Scene;
  77070. /**
  77071. * Creates a new instance of the component for the given scene
  77072. * @param scene Defines the scene to register the component in
  77073. */
  77074. constructor(scene: Scene);
  77075. /**
  77076. * Registers the component in a given scene
  77077. */
  77078. register(): void;
  77079. /**
  77080. * Rebuilds the elements related to this component in case of
  77081. * context lost for instance.
  77082. */
  77083. rebuild(): void;
  77084. /**
  77085. * Disposes the component and the associated resources
  77086. */
  77087. dispose(): void;
  77088. private _gatherRenderTargets;
  77089. private _gatherActiveCameraRenderTargets;
  77090. }
  77091. }
  77092. declare module BABYLON {
  77093. interface AbstractScene {
  77094. /** @hidden (Backing field) */
  77095. _prePassRenderer: Nullable<PrePassRenderer>;
  77096. /**
  77097. * Gets or Sets the current prepass renderer associated to the scene.
  77098. */
  77099. prePassRenderer: Nullable<PrePassRenderer>;
  77100. /**
  77101. * Enables the prepass and associates it with the scene
  77102. * @returns the PrePassRenderer
  77103. */
  77104. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  77105. /**
  77106. * Disables the prepass associated with the scene
  77107. */
  77108. disablePrePassRenderer(): void;
  77109. }
  77110. interface RenderTargetTexture {
  77111. /** @hidden */
  77112. _prePassRenderTarget: PrePassRenderTarget;
  77113. }
  77114. /**
  77115. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  77116. * in several rendering techniques.
  77117. */
  77118. export class PrePassRendererSceneComponent implements ISceneComponent {
  77119. /**
  77120. * The component name helpful to identify the component in the list of scene components.
  77121. */
  77122. readonly name: string;
  77123. /**
  77124. * The scene the component belongs to.
  77125. */
  77126. scene: Scene;
  77127. /**
  77128. * Creates a new instance of the component for the given scene
  77129. * @param scene Defines the scene to register the component in
  77130. */
  77131. constructor(scene: Scene);
  77132. /**
  77133. * Registers the component in a given scene
  77134. */
  77135. register(): void;
  77136. private _beforeRenderTargetDraw;
  77137. private _afterRenderTargetDraw;
  77138. private _beforeRenderTargetClearStage;
  77139. private _beforeCameraDraw;
  77140. private _afterCameraDraw;
  77141. private _beforeClearStage;
  77142. private _beforeRenderingMeshStage;
  77143. private _afterRenderingMeshStage;
  77144. /**
  77145. * Rebuilds the elements related to this component in case of
  77146. * context lost for instance.
  77147. */
  77148. rebuild(): void;
  77149. /**
  77150. * Disposes the component and the associated resources
  77151. */
  77152. dispose(): void;
  77153. }
  77154. }
  77155. declare module BABYLON {
  77156. /** @hidden */
  77157. export var fibonacci: {
  77158. name: string;
  77159. shader: string;
  77160. };
  77161. }
  77162. declare module BABYLON {
  77163. /** @hidden */
  77164. export var diffusionProfile: {
  77165. name: string;
  77166. shader: string;
  77167. };
  77168. }
  77169. declare module BABYLON {
  77170. /** @hidden */
  77171. export var subSurfaceScatteringPixelShader: {
  77172. name: string;
  77173. shader: string;
  77174. };
  77175. }
  77176. declare module BABYLON {
  77177. /**
  77178. * Sub surface scattering post process
  77179. */
  77180. export class SubSurfaceScatteringPostProcess extends PostProcess {
  77181. /**
  77182. * Gets a string identifying the name of the class
  77183. * @returns "SubSurfaceScatteringPostProcess" string
  77184. */
  77185. getClassName(): string;
  77186. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  77187. }
  77188. }
  77189. declare module BABYLON {
  77190. /**
  77191. * Contains all parameters needed for the prepass to perform
  77192. * screen space subsurface scattering
  77193. */
  77194. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  77195. /** @hidden */
  77196. static _SceneComponentInitialization: (scene: Scene) => void;
  77197. private _ssDiffusionS;
  77198. private _ssFilterRadii;
  77199. private _ssDiffusionD;
  77200. /**
  77201. * Post process to attach for screen space subsurface scattering
  77202. */
  77203. postProcess: SubSurfaceScatteringPostProcess;
  77204. /**
  77205. * Diffusion profile color for subsurface scattering
  77206. */
  77207. get ssDiffusionS(): number[];
  77208. /**
  77209. * Diffusion profile max color channel value for subsurface scattering
  77210. */
  77211. get ssDiffusionD(): number[];
  77212. /**
  77213. * Diffusion profile filter radius for subsurface scattering
  77214. */
  77215. get ssFilterRadii(): number[];
  77216. /**
  77217. * Is subsurface enabled
  77218. */
  77219. enabled: boolean;
  77220. /**
  77221. * Does the output of this prepass need to go through imageprocessing
  77222. */
  77223. needsImageProcessing: boolean;
  77224. /**
  77225. * Name of the configuration
  77226. */
  77227. name: string;
  77228. /**
  77229. * Diffusion profile colors for subsurface scattering
  77230. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  77231. * See ...
  77232. * Note that you can only store up to 5 of them
  77233. */
  77234. ssDiffusionProfileColors: Color3[];
  77235. /**
  77236. * Defines the ratio real world => scene units.
  77237. * Used for subsurface scattering
  77238. */
  77239. metersPerUnit: number;
  77240. /**
  77241. * Textures that should be present in the MRT for this effect to work
  77242. */
  77243. readonly texturesRequired: number[];
  77244. private _scene;
  77245. /**
  77246. * Builds a subsurface configuration object
  77247. * @param scene The scene
  77248. */
  77249. constructor(scene: Scene);
  77250. /**
  77251. * Adds a new diffusion profile.
  77252. * Useful for more realistic subsurface scattering on diverse materials.
  77253. * @param color The color of the diffusion profile. Should be the average color of the material.
  77254. * @return The index of the diffusion profile for the material subsurface configuration
  77255. */
  77256. addDiffusionProfile(color: Color3): number;
  77257. /**
  77258. * Creates the sss post process
  77259. * @return The created post process
  77260. */
  77261. createPostProcess(): SubSurfaceScatteringPostProcess;
  77262. /**
  77263. * Deletes all diffusion profiles.
  77264. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  77265. */
  77266. clearAllDiffusionProfiles(): void;
  77267. /**
  77268. * Disposes this object
  77269. */
  77270. dispose(): void;
  77271. /**
  77272. * @hidden
  77273. * https://zero-radiance.github.io/post/sampling-diffusion/
  77274. *
  77275. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  77276. * ------------------------------------------------------------------------------------
  77277. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  77278. * PDF[r, phi, s] = r * R[r, phi, s]
  77279. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  77280. * ------------------------------------------------------------------------------------
  77281. * We importance sample the color channel with the widest scattering distance.
  77282. */
  77283. getDiffusionProfileParameters(color: Color3): number;
  77284. /**
  77285. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  77286. * 'u' is the random number (the value of the CDF): [0, 1).
  77287. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  77288. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  77289. */
  77290. private _sampleBurleyDiffusionProfile;
  77291. }
  77292. }
  77293. declare module BABYLON {
  77294. interface AbstractScene {
  77295. /** @hidden (Backing field) */
  77296. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  77297. /**
  77298. * Gets or Sets the current prepass renderer associated to the scene.
  77299. */
  77300. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  77301. /**
  77302. * Enables the subsurface effect for prepass
  77303. * @returns the SubSurfaceConfiguration
  77304. */
  77305. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  77306. /**
  77307. * Disables the subsurface effect for prepass
  77308. */
  77309. disableSubSurfaceForPrePass(): void;
  77310. }
  77311. /**
  77312. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  77313. * in several rendering techniques.
  77314. */
  77315. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  77316. /**
  77317. * The component name helpful to identify the component in the list of scene components.
  77318. */
  77319. readonly name: string;
  77320. /**
  77321. * The scene the component belongs to.
  77322. */
  77323. scene: Scene;
  77324. /**
  77325. * Creates a new instance of the component for the given scene
  77326. * @param scene Defines the scene to register the component in
  77327. */
  77328. constructor(scene: Scene);
  77329. /**
  77330. * Registers the component in a given scene
  77331. */
  77332. register(): void;
  77333. /**
  77334. * Serializes the component data to the specified json object
  77335. * @param serializationObject The object to serialize to
  77336. */
  77337. serialize(serializationObject: any): void;
  77338. /**
  77339. * Adds all the elements from the container to the scene
  77340. * @param container the container holding the elements
  77341. */
  77342. addFromContainer(container: AbstractScene): void;
  77343. /**
  77344. * Removes all the elements in the container from the scene
  77345. * @param container contains the elements to remove
  77346. * @param dispose if the removed element should be disposed (default: false)
  77347. */
  77348. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  77349. /**
  77350. * Rebuilds the elements related to this component in case of
  77351. * context lost for instance.
  77352. */
  77353. rebuild(): void;
  77354. /**
  77355. * Disposes the component and the associated resources
  77356. */
  77357. dispose(): void;
  77358. }
  77359. }
  77360. declare module BABYLON {
  77361. /** @hidden */
  77362. export var outlinePixelShader: {
  77363. name: string;
  77364. shader: string;
  77365. };
  77366. }
  77367. declare module BABYLON {
  77368. /** @hidden */
  77369. export var outlineVertexShader: {
  77370. name: string;
  77371. shader: string;
  77372. };
  77373. }
  77374. declare module BABYLON {
  77375. interface Scene {
  77376. /** @hidden */
  77377. _outlineRenderer: OutlineRenderer;
  77378. /**
  77379. * Gets the outline renderer associated with the scene
  77380. * @returns a OutlineRenderer
  77381. */
  77382. getOutlineRenderer(): OutlineRenderer;
  77383. }
  77384. interface AbstractMesh {
  77385. /** @hidden (Backing field) */
  77386. _renderOutline: boolean;
  77387. /**
  77388. * Gets or sets a boolean indicating if the outline must be rendered as well
  77389. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  77390. */
  77391. renderOutline: boolean;
  77392. /** @hidden (Backing field) */
  77393. _renderOverlay: boolean;
  77394. /**
  77395. * Gets or sets a boolean indicating if the overlay must be rendered as well
  77396. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  77397. */
  77398. renderOverlay: boolean;
  77399. }
  77400. /**
  77401. * This class is responsible to draw the outline/overlay of meshes.
  77402. * It should not be used directly but through the available method on mesh.
  77403. */
  77404. export class OutlineRenderer implements ISceneComponent {
  77405. /**
  77406. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  77407. */
  77408. private static _StencilReference;
  77409. /**
  77410. * The name of the component. Each component must have a unique name.
  77411. */
  77412. name: string;
  77413. /**
  77414. * The scene the component belongs to.
  77415. */
  77416. scene: Scene;
  77417. /**
  77418. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  77419. */
  77420. zOffset: number;
  77421. private _engine;
  77422. private _effect;
  77423. private _cachedDefines;
  77424. private _savedDepthWrite;
  77425. /**
  77426. * Instantiates a new outline renderer. (There could be only one per scene).
  77427. * @param scene Defines the scene it belongs to
  77428. */
  77429. constructor(scene: Scene);
  77430. /**
  77431. * Register the component to one instance of a scene.
  77432. */
  77433. register(): void;
  77434. /**
  77435. * Rebuilds the elements related to this component in case of
  77436. * context lost for instance.
  77437. */
  77438. rebuild(): void;
  77439. /**
  77440. * Disposes the component and the associated resources.
  77441. */
  77442. dispose(): void;
  77443. /**
  77444. * Renders the outline in the canvas.
  77445. * @param subMesh Defines the sumesh to render
  77446. * @param batch Defines the batch of meshes in case of instances
  77447. * @param useOverlay Defines if the rendering is for the overlay or the outline
  77448. */
  77449. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  77450. /**
  77451. * Returns whether or not the outline renderer is ready for a given submesh.
  77452. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  77453. * @param subMesh Defines the submesh to check readiness for
  77454. * @param useInstances Defines whether wee are trying to render instances or not
  77455. * @returns true if ready otherwise false
  77456. */
  77457. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  77458. private _beforeRenderingMesh;
  77459. private _afterRenderingMesh;
  77460. }
  77461. }
  77462. declare module BABYLON {
  77463. /**
  77464. * Defines the basic options interface of a Sprite Frame Source Size.
  77465. */
  77466. export interface ISpriteJSONSpriteSourceSize {
  77467. /**
  77468. * number of the original width of the Frame
  77469. */
  77470. w: number;
  77471. /**
  77472. * number of the original height of the Frame
  77473. */
  77474. h: number;
  77475. }
  77476. /**
  77477. * Defines the basic options interface of a Sprite Frame Data.
  77478. */
  77479. export interface ISpriteJSONSpriteFrameData {
  77480. /**
  77481. * number of the x offset of the Frame
  77482. */
  77483. x: number;
  77484. /**
  77485. * number of the y offset of the Frame
  77486. */
  77487. y: number;
  77488. /**
  77489. * number of the width of the Frame
  77490. */
  77491. w: number;
  77492. /**
  77493. * number of the height of the Frame
  77494. */
  77495. h: number;
  77496. }
  77497. /**
  77498. * Defines the basic options interface of a JSON Sprite.
  77499. */
  77500. export interface ISpriteJSONSprite {
  77501. /**
  77502. * string name of the Frame
  77503. */
  77504. filename: string;
  77505. /**
  77506. * ISpriteJSONSpriteFrame basic object of the frame data
  77507. */
  77508. frame: ISpriteJSONSpriteFrameData;
  77509. /**
  77510. * boolean to flag is the frame was rotated.
  77511. */
  77512. rotated: boolean;
  77513. /**
  77514. * boolean to flag is the frame was trimmed.
  77515. */
  77516. trimmed: boolean;
  77517. /**
  77518. * ISpriteJSONSpriteFrame basic object of the source data
  77519. */
  77520. spriteSourceSize: ISpriteJSONSpriteFrameData;
  77521. /**
  77522. * ISpriteJSONSpriteFrame basic object of the source data
  77523. */
  77524. sourceSize: ISpriteJSONSpriteSourceSize;
  77525. }
  77526. /**
  77527. * Defines the basic options interface of a JSON atlas.
  77528. */
  77529. export interface ISpriteJSONAtlas {
  77530. /**
  77531. * Array of objects that contain the frame data.
  77532. */
  77533. frames: Array<ISpriteJSONSprite>;
  77534. /**
  77535. * object basic object containing the sprite meta data.
  77536. */
  77537. meta?: object;
  77538. }
  77539. }
  77540. declare module BABYLON {
  77541. /** @hidden */
  77542. export var spriteMapPixelShader: {
  77543. name: string;
  77544. shader: string;
  77545. };
  77546. }
  77547. declare module BABYLON {
  77548. /** @hidden */
  77549. export var spriteMapVertexShader: {
  77550. name: string;
  77551. shader: string;
  77552. };
  77553. }
  77554. declare module BABYLON {
  77555. /**
  77556. * Defines the basic options interface of a SpriteMap
  77557. */
  77558. export interface ISpriteMapOptions {
  77559. /**
  77560. * Vector2 of the number of cells in the grid.
  77561. */
  77562. stageSize?: Vector2;
  77563. /**
  77564. * Vector2 of the size of the output plane in World Units.
  77565. */
  77566. outputSize?: Vector2;
  77567. /**
  77568. * Vector3 of the position of the output plane in World Units.
  77569. */
  77570. outputPosition?: Vector3;
  77571. /**
  77572. * Vector3 of the rotation of the output plane.
  77573. */
  77574. outputRotation?: Vector3;
  77575. /**
  77576. * number of layers that the system will reserve in resources.
  77577. */
  77578. layerCount?: number;
  77579. /**
  77580. * number of max animation frames a single cell will reserve in resources.
  77581. */
  77582. maxAnimationFrames?: number;
  77583. /**
  77584. * number cell index of the base tile when the system compiles.
  77585. */
  77586. baseTile?: number;
  77587. /**
  77588. * boolean flip the sprite after its been repositioned by the framing data.
  77589. */
  77590. flipU?: boolean;
  77591. /**
  77592. * Vector3 scalar of the global RGB values of the SpriteMap.
  77593. */
  77594. colorMultiply?: Vector3;
  77595. }
  77596. /**
  77597. * Defines the IDisposable interface in order to be cleanable from resources.
  77598. */
  77599. export interface ISpriteMap extends IDisposable {
  77600. /**
  77601. * String name of the SpriteMap.
  77602. */
  77603. name: string;
  77604. /**
  77605. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  77606. */
  77607. atlasJSON: ISpriteJSONAtlas;
  77608. /**
  77609. * Texture of the SpriteMap.
  77610. */
  77611. spriteSheet: Texture;
  77612. /**
  77613. * The parameters to initialize the SpriteMap with.
  77614. */
  77615. options: ISpriteMapOptions;
  77616. }
  77617. /**
  77618. * Class used to manage a grid restricted sprite deployment on an Output plane.
  77619. */
  77620. export class SpriteMap implements ISpriteMap {
  77621. /** The Name of the spriteMap */
  77622. name: string;
  77623. /** The JSON file with the frame and meta data */
  77624. atlasJSON: ISpriteJSONAtlas;
  77625. /** The systems Sprite Sheet Texture */
  77626. spriteSheet: Texture;
  77627. /** Arguments passed with the Constructor */
  77628. options: ISpriteMapOptions;
  77629. /** Public Sprite Storage array, parsed from atlasJSON */
  77630. sprites: Array<ISpriteJSONSprite>;
  77631. /** Returns the Number of Sprites in the System */
  77632. get spriteCount(): number;
  77633. /** Returns the Position of Output Plane*/
  77634. get position(): Vector3;
  77635. /** Returns the Position of Output Plane*/
  77636. set position(v: Vector3);
  77637. /** Returns the Rotation of Output Plane*/
  77638. get rotation(): Vector3;
  77639. /** Returns the Rotation of Output Plane*/
  77640. set rotation(v: Vector3);
  77641. /** Sets the AnimationMap*/
  77642. get animationMap(): RawTexture;
  77643. /** Sets the AnimationMap*/
  77644. set animationMap(v: RawTexture);
  77645. /** Scene that the SpriteMap was created in */
  77646. private _scene;
  77647. /** Texture Buffer of Float32 that holds tile frame data*/
  77648. private _frameMap;
  77649. /** Texture Buffers of Float32 that holds tileMap data*/
  77650. private _tileMaps;
  77651. /** Texture Buffer of Float32 that holds Animation Data*/
  77652. private _animationMap;
  77653. /** Custom ShaderMaterial Central to the System*/
  77654. private _material;
  77655. /** Custom ShaderMaterial Central to the System*/
  77656. private _output;
  77657. /** Systems Time Ticker*/
  77658. private _time;
  77659. /**
  77660. * Creates a new SpriteMap
  77661. * @param name defines the SpriteMaps Name
  77662. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  77663. * @param spriteSheet is the Texture that the Sprites are on.
  77664. * @param options a basic deployment configuration
  77665. * @param scene The Scene that the map is deployed on
  77666. */
  77667. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  77668. /**
  77669. * Returns tileID location
  77670. * @returns Vector2 the cell position ID
  77671. */
  77672. getTileID(): Vector2;
  77673. /**
  77674. * Gets the UV location of the mouse over the SpriteMap.
  77675. * @returns Vector2 the UV position of the mouse interaction
  77676. */
  77677. getMousePosition(): Vector2;
  77678. /**
  77679. * Creates the "frame" texture Buffer
  77680. * -------------------------------------
  77681. * Structure of frames
  77682. * "filename": "Falling-Water-2.png",
  77683. * "frame": {"x":69,"y":103,"w":24,"h":32},
  77684. * "rotated": true,
  77685. * "trimmed": true,
  77686. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  77687. * "sourceSize": {"w":32,"h":32}
  77688. * @returns RawTexture of the frameMap
  77689. */
  77690. private _createFrameBuffer;
  77691. /**
  77692. * Creates the tileMap texture Buffer
  77693. * @param buffer normally and array of numbers, or a false to generate from scratch
  77694. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  77695. * @returns RawTexture of the tileMap
  77696. */
  77697. private _createTileBuffer;
  77698. /**
  77699. * Modifies the data of the tileMaps
  77700. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  77701. * @param pos is the iVector2 Coordinates of the Tile
  77702. * @param tile The SpriteIndex of the new Tile
  77703. */
  77704. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  77705. /**
  77706. * Creates the animationMap texture Buffer
  77707. * @param buffer normally and array of numbers, or a false to generate from scratch
  77708. * @returns RawTexture of the animationMap
  77709. */
  77710. private _createTileAnimationBuffer;
  77711. /**
  77712. * Modifies the data of the animationMap
  77713. * @param cellID is the Index of the Sprite
  77714. * @param _frame is the target Animation frame
  77715. * @param toCell is the Target Index of the next frame of the animation
  77716. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  77717. * @param speed is a global scalar of the time variable on the map.
  77718. */
  77719. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  77720. /**
  77721. * Exports the .tilemaps file
  77722. */
  77723. saveTileMaps(): void;
  77724. /**
  77725. * Imports the .tilemaps file
  77726. * @param url of the .tilemaps file
  77727. */
  77728. loadTileMaps(url: string): void;
  77729. /**
  77730. * Release associated resources
  77731. */
  77732. dispose(): void;
  77733. }
  77734. }
  77735. declare module BABYLON {
  77736. /**
  77737. * Class used to manage multiple sprites of different sizes on the same spritesheet
  77738. * @see https://doc.babylonjs.com/babylon101/sprites
  77739. */
  77740. export class SpritePackedManager extends SpriteManager {
  77741. /** defines the packed manager's name */
  77742. name: string;
  77743. /**
  77744. * Creates a new sprite manager from a packed sprite sheet
  77745. * @param name defines the manager's name
  77746. * @param imgUrl defines the sprite sheet url
  77747. * @param capacity defines the maximum allowed number of sprites
  77748. * @param scene defines the hosting scene
  77749. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  77750. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  77751. * @param samplingMode defines the sampling mode to use with spritesheet
  77752. * @param fromPacked set to true; do not alter
  77753. */
  77754. constructor(
  77755. /** defines the packed manager's name */
  77756. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  77757. }
  77758. }
  77759. declare module BABYLON {
  77760. /**
  77761. * Defines the list of states available for a task inside a AssetsManager
  77762. */
  77763. export enum AssetTaskState {
  77764. /**
  77765. * Initialization
  77766. */
  77767. INIT = 0,
  77768. /**
  77769. * Running
  77770. */
  77771. RUNNING = 1,
  77772. /**
  77773. * Done
  77774. */
  77775. DONE = 2,
  77776. /**
  77777. * Error
  77778. */
  77779. ERROR = 3
  77780. }
  77781. /**
  77782. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  77783. */
  77784. export abstract class AbstractAssetTask {
  77785. /**
  77786. * Task name
  77787. */ name: string;
  77788. /**
  77789. * Callback called when the task is successful
  77790. */
  77791. onSuccess: (task: any) => void;
  77792. /**
  77793. * Callback called when the task is not successful
  77794. */
  77795. onError: (task: any, message?: string, exception?: any) => void;
  77796. /**
  77797. * Creates a new AssetsManager
  77798. * @param name defines the name of the task
  77799. */
  77800. constructor(
  77801. /**
  77802. * Task name
  77803. */ name: string);
  77804. private _isCompleted;
  77805. private _taskState;
  77806. private _errorObject;
  77807. /**
  77808. * Get if the task is completed
  77809. */
  77810. get isCompleted(): boolean;
  77811. /**
  77812. * Gets the current state of the task
  77813. */
  77814. get taskState(): AssetTaskState;
  77815. /**
  77816. * Gets the current error object (if task is in error)
  77817. */
  77818. get errorObject(): {
  77819. message?: string;
  77820. exception?: any;
  77821. };
  77822. /**
  77823. * Internal only
  77824. * @hidden
  77825. */
  77826. _setErrorObject(message?: string, exception?: any): void;
  77827. /**
  77828. * Execute the current task
  77829. * @param scene defines the scene where you want your assets to be loaded
  77830. * @param onSuccess is a callback called when the task is successfully executed
  77831. * @param onError is a callback called if an error occurs
  77832. */
  77833. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77834. /**
  77835. * Execute the current task
  77836. * @param scene defines the scene where you want your assets to be loaded
  77837. * @param onSuccess is a callback called when the task is successfully executed
  77838. * @param onError is a callback called if an error occurs
  77839. */
  77840. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77841. /**
  77842. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  77843. * This can be used with failed tasks that have the reason for failure fixed.
  77844. */
  77845. reset(): void;
  77846. private onErrorCallback;
  77847. private onDoneCallback;
  77848. }
  77849. /**
  77850. * Define the interface used by progress events raised during assets loading
  77851. */
  77852. export interface IAssetsProgressEvent {
  77853. /**
  77854. * Defines the number of remaining tasks to process
  77855. */
  77856. remainingCount: number;
  77857. /**
  77858. * Defines the total number of tasks
  77859. */
  77860. totalCount: number;
  77861. /**
  77862. * Defines the task that was just processed
  77863. */
  77864. task: AbstractAssetTask;
  77865. }
  77866. /**
  77867. * Class used to share progress information about assets loading
  77868. */
  77869. export class AssetsProgressEvent implements IAssetsProgressEvent {
  77870. /**
  77871. * Defines the number of remaining tasks to process
  77872. */
  77873. remainingCount: number;
  77874. /**
  77875. * Defines the total number of tasks
  77876. */
  77877. totalCount: number;
  77878. /**
  77879. * Defines the task that was just processed
  77880. */
  77881. task: AbstractAssetTask;
  77882. /**
  77883. * Creates a AssetsProgressEvent
  77884. * @param remainingCount defines the number of remaining tasks to process
  77885. * @param totalCount defines the total number of tasks
  77886. * @param task defines the task that was just processed
  77887. */
  77888. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  77889. }
  77890. /**
  77891. * Define a task used by AssetsManager to load assets into a container
  77892. */
  77893. export class ContainerAssetTask extends AbstractAssetTask {
  77894. /**
  77895. * Defines the name of the task
  77896. */
  77897. name: string;
  77898. /**
  77899. * Defines the list of mesh's names you want to load
  77900. */
  77901. meshesNames: any;
  77902. /**
  77903. * Defines the root url to use as a base to load your meshes and associated resources
  77904. */
  77905. rootUrl: string;
  77906. /**
  77907. * Defines the filename or File of the scene to load from
  77908. */
  77909. sceneFilename: string | File;
  77910. /**
  77911. * Get the loaded asset container
  77912. */
  77913. loadedContainer: AssetContainer;
  77914. /**
  77915. * Gets the list of loaded meshes
  77916. */
  77917. loadedMeshes: Array<AbstractMesh>;
  77918. /**
  77919. * Gets the list of loaded particle systems
  77920. */
  77921. loadedParticleSystems: Array<IParticleSystem>;
  77922. /**
  77923. * Gets the list of loaded skeletons
  77924. */
  77925. loadedSkeletons: Array<Skeleton>;
  77926. /**
  77927. * Gets the list of loaded animation groups
  77928. */
  77929. loadedAnimationGroups: Array<AnimationGroup>;
  77930. /**
  77931. * Callback called when the task is successful
  77932. */
  77933. onSuccess: (task: ContainerAssetTask) => void;
  77934. /**
  77935. * Callback called when the task is successful
  77936. */
  77937. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  77938. /**
  77939. * Creates a new ContainerAssetTask
  77940. * @param name defines the name of the task
  77941. * @param meshesNames defines the list of mesh's names you want to load
  77942. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  77943. * @param sceneFilename defines the filename or File of the scene to load from
  77944. */
  77945. constructor(
  77946. /**
  77947. * Defines the name of the task
  77948. */
  77949. name: string,
  77950. /**
  77951. * Defines the list of mesh's names you want to load
  77952. */
  77953. meshesNames: any,
  77954. /**
  77955. * Defines the root url to use as a base to load your meshes and associated resources
  77956. */
  77957. rootUrl: string,
  77958. /**
  77959. * Defines the filename or File of the scene to load from
  77960. */
  77961. sceneFilename: string | File);
  77962. /**
  77963. * Execute the current task
  77964. * @param scene defines the scene where you want your assets to be loaded
  77965. * @param onSuccess is a callback called when the task is successfully executed
  77966. * @param onError is a callback called if an error occurs
  77967. */
  77968. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77969. }
  77970. /**
  77971. * Define a task used by AssetsManager to load meshes
  77972. */
  77973. export class MeshAssetTask extends AbstractAssetTask {
  77974. /**
  77975. * Defines the name of the task
  77976. */
  77977. name: string;
  77978. /**
  77979. * Defines the list of mesh's names you want to load
  77980. */
  77981. meshesNames: any;
  77982. /**
  77983. * Defines the root url to use as a base to load your meshes and associated resources
  77984. */
  77985. rootUrl: string;
  77986. /**
  77987. * Defines the filename or File of the scene to load from
  77988. */
  77989. sceneFilename: string | File;
  77990. /**
  77991. * Gets the list of loaded meshes
  77992. */
  77993. loadedMeshes: Array<AbstractMesh>;
  77994. /**
  77995. * Gets the list of loaded particle systems
  77996. */
  77997. loadedParticleSystems: Array<IParticleSystem>;
  77998. /**
  77999. * Gets the list of loaded skeletons
  78000. */
  78001. loadedSkeletons: Array<Skeleton>;
  78002. /**
  78003. * Gets the list of loaded animation groups
  78004. */
  78005. loadedAnimationGroups: Array<AnimationGroup>;
  78006. /**
  78007. * Callback called when the task is successful
  78008. */
  78009. onSuccess: (task: MeshAssetTask) => void;
  78010. /**
  78011. * Callback called when the task is successful
  78012. */
  78013. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  78014. /**
  78015. * Creates a new MeshAssetTask
  78016. * @param name defines the name of the task
  78017. * @param meshesNames defines the list of mesh's names you want to load
  78018. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  78019. * @param sceneFilename defines the filename or File of the scene to load from
  78020. */
  78021. constructor(
  78022. /**
  78023. * Defines the name of the task
  78024. */
  78025. name: string,
  78026. /**
  78027. * Defines the list of mesh's names you want to load
  78028. */
  78029. meshesNames: any,
  78030. /**
  78031. * Defines the root url to use as a base to load your meshes and associated resources
  78032. */
  78033. rootUrl: string,
  78034. /**
  78035. * Defines the filename or File of the scene to load from
  78036. */
  78037. sceneFilename: string | File);
  78038. /**
  78039. * Execute the current task
  78040. * @param scene defines the scene where you want your assets to be loaded
  78041. * @param onSuccess is a callback called when the task is successfully executed
  78042. * @param onError is a callback called if an error occurs
  78043. */
  78044. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78045. }
  78046. /**
  78047. * Define a task used by AssetsManager to load text content
  78048. */
  78049. export class TextFileAssetTask extends AbstractAssetTask {
  78050. /**
  78051. * Defines the name of the task
  78052. */
  78053. name: string;
  78054. /**
  78055. * Defines the location of the file to load
  78056. */
  78057. url: string;
  78058. /**
  78059. * Gets the loaded text string
  78060. */
  78061. text: string;
  78062. /**
  78063. * Callback called when the task is successful
  78064. */
  78065. onSuccess: (task: TextFileAssetTask) => void;
  78066. /**
  78067. * Callback called when the task is successful
  78068. */
  78069. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  78070. /**
  78071. * Creates a new TextFileAssetTask object
  78072. * @param name defines the name of the task
  78073. * @param url defines the location of the file to load
  78074. */
  78075. constructor(
  78076. /**
  78077. * Defines the name of the task
  78078. */
  78079. name: string,
  78080. /**
  78081. * Defines the location of the file to load
  78082. */
  78083. url: string);
  78084. /**
  78085. * Execute the current task
  78086. * @param scene defines the scene where you want your assets to be loaded
  78087. * @param onSuccess is a callback called when the task is successfully executed
  78088. * @param onError is a callback called if an error occurs
  78089. */
  78090. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78091. }
  78092. /**
  78093. * Define a task used by AssetsManager to load binary data
  78094. */
  78095. export class BinaryFileAssetTask extends AbstractAssetTask {
  78096. /**
  78097. * Defines the name of the task
  78098. */
  78099. name: string;
  78100. /**
  78101. * Defines the location of the file to load
  78102. */
  78103. url: string;
  78104. /**
  78105. * Gets the lodaded data (as an array buffer)
  78106. */
  78107. data: ArrayBuffer;
  78108. /**
  78109. * Callback called when the task is successful
  78110. */
  78111. onSuccess: (task: BinaryFileAssetTask) => void;
  78112. /**
  78113. * Callback called when the task is successful
  78114. */
  78115. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  78116. /**
  78117. * Creates a new BinaryFileAssetTask object
  78118. * @param name defines the name of the new task
  78119. * @param url defines the location of the file to load
  78120. */
  78121. constructor(
  78122. /**
  78123. * Defines the name of the task
  78124. */
  78125. name: string,
  78126. /**
  78127. * Defines the location of the file to load
  78128. */
  78129. url: string);
  78130. /**
  78131. * Execute the current task
  78132. * @param scene defines the scene where you want your assets to be loaded
  78133. * @param onSuccess is a callback called when the task is successfully executed
  78134. * @param onError is a callback called if an error occurs
  78135. */
  78136. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78137. }
  78138. /**
  78139. * Define a task used by AssetsManager to load images
  78140. */
  78141. export class ImageAssetTask extends AbstractAssetTask {
  78142. /**
  78143. * Defines the name of the task
  78144. */
  78145. name: string;
  78146. /**
  78147. * Defines the location of the image to load
  78148. */
  78149. url: string;
  78150. /**
  78151. * Gets the loaded images
  78152. */
  78153. image: HTMLImageElement;
  78154. /**
  78155. * Callback called when the task is successful
  78156. */
  78157. onSuccess: (task: ImageAssetTask) => void;
  78158. /**
  78159. * Callback called when the task is successful
  78160. */
  78161. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  78162. /**
  78163. * Creates a new ImageAssetTask
  78164. * @param name defines the name of the task
  78165. * @param url defines the location of the image to load
  78166. */
  78167. constructor(
  78168. /**
  78169. * Defines the name of the task
  78170. */
  78171. name: string,
  78172. /**
  78173. * Defines the location of the image to load
  78174. */
  78175. url: string);
  78176. /**
  78177. * Execute the current task
  78178. * @param scene defines the scene where you want your assets to be loaded
  78179. * @param onSuccess is a callback called when the task is successfully executed
  78180. * @param onError is a callback called if an error occurs
  78181. */
  78182. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78183. }
  78184. /**
  78185. * Defines the interface used by texture loading tasks
  78186. */
  78187. export interface ITextureAssetTask<TEX extends BaseTexture> {
  78188. /**
  78189. * Gets the loaded texture
  78190. */
  78191. texture: TEX;
  78192. }
  78193. /**
  78194. * Define a task used by AssetsManager to load 2D textures
  78195. */
  78196. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  78197. /**
  78198. * Defines the name of the task
  78199. */
  78200. name: string;
  78201. /**
  78202. * Defines the location of the file to load
  78203. */
  78204. url: string;
  78205. /**
  78206. * Defines if mipmap should not be generated (default is false)
  78207. */
  78208. noMipmap?: boolean | undefined;
  78209. /**
  78210. * Defines if texture must be inverted on Y axis (default is true)
  78211. */
  78212. invertY: boolean;
  78213. /**
  78214. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  78215. */
  78216. samplingMode: number;
  78217. /**
  78218. * Gets the loaded texture
  78219. */
  78220. texture: Texture;
  78221. /**
  78222. * Callback called when the task is successful
  78223. */
  78224. onSuccess: (task: TextureAssetTask) => void;
  78225. /**
  78226. * Callback called when the task is successful
  78227. */
  78228. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  78229. /**
  78230. * Creates a new TextureAssetTask object
  78231. * @param name defines the name of the task
  78232. * @param url defines the location of the file to load
  78233. * @param noMipmap defines if mipmap should not be generated (default is false)
  78234. * @param invertY defines if texture must be inverted on Y axis (default is true)
  78235. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  78236. */
  78237. constructor(
  78238. /**
  78239. * Defines the name of the task
  78240. */
  78241. name: string,
  78242. /**
  78243. * Defines the location of the file to load
  78244. */
  78245. url: string,
  78246. /**
  78247. * Defines if mipmap should not be generated (default is false)
  78248. */
  78249. noMipmap?: boolean | undefined,
  78250. /**
  78251. * Defines if texture must be inverted on Y axis (default is true)
  78252. */
  78253. invertY?: boolean,
  78254. /**
  78255. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  78256. */
  78257. samplingMode?: number);
  78258. /**
  78259. * Execute the current task
  78260. * @param scene defines the scene where you want your assets to be loaded
  78261. * @param onSuccess is a callback called when the task is successfully executed
  78262. * @param onError is a callback called if an error occurs
  78263. */
  78264. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78265. }
  78266. /**
  78267. * Define a task used by AssetsManager to load cube textures
  78268. */
  78269. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  78270. /**
  78271. * Defines the name of the task
  78272. */
  78273. name: string;
  78274. /**
  78275. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  78276. */
  78277. url: string;
  78278. /**
  78279. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  78280. */
  78281. extensions?: string[] | undefined;
  78282. /**
  78283. * Defines if mipmaps should not be generated (default is false)
  78284. */
  78285. noMipmap?: boolean | undefined;
  78286. /**
  78287. * Defines the explicit list of files (undefined by default)
  78288. */
  78289. files?: string[] | undefined;
  78290. /**
  78291. * Gets the loaded texture
  78292. */
  78293. texture: CubeTexture;
  78294. /**
  78295. * Callback called when the task is successful
  78296. */
  78297. onSuccess: (task: CubeTextureAssetTask) => void;
  78298. /**
  78299. * Callback called when the task is successful
  78300. */
  78301. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  78302. /**
  78303. * Creates a new CubeTextureAssetTask
  78304. * @param name defines the name of the task
  78305. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  78306. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  78307. * @param noMipmap defines if mipmaps should not be generated (default is false)
  78308. * @param files defines the explicit list of files (undefined by default)
  78309. */
  78310. constructor(
  78311. /**
  78312. * Defines the name of the task
  78313. */
  78314. name: string,
  78315. /**
  78316. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  78317. */
  78318. url: string,
  78319. /**
  78320. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  78321. */
  78322. extensions?: string[] | undefined,
  78323. /**
  78324. * Defines if mipmaps should not be generated (default is false)
  78325. */
  78326. noMipmap?: boolean | undefined,
  78327. /**
  78328. * Defines the explicit list of files (undefined by default)
  78329. */
  78330. files?: string[] | undefined);
  78331. /**
  78332. * Execute the current task
  78333. * @param scene defines the scene where you want your assets to be loaded
  78334. * @param onSuccess is a callback called when the task is successfully executed
  78335. * @param onError is a callback called if an error occurs
  78336. */
  78337. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78338. }
  78339. /**
  78340. * Define a task used by AssetsManager to load HDR cube textures
  78341. */
  78342. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  78343. /**
  78344. * Defines the name of the task
  78345. */
  78346. name: string;
  78347. /**
  78348. * Defines the location of the file to load
  78349. */
  78350. url: string;
  78351. /**
  78352. * Defines the desired size (the more it increases the longer the generation will be)
  78353. */
  78354. size: number;
  78355. /**
  78356. * Defines if mipmaps should not be generated (default is false)
  78357. */
  78358. noMipmap: boolean;
  78359. /**
  78360. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  78361. */
  78362. generateHarmonics: boolean;
  78363. /**
  78364. * 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)
  78365. */
  78366. gammaSpace: boolean;
  78367. /**
  78368. * Internal Use Only
  78369. */
  78370. reserved: boolean;
  78371. /**
  78372. * Gets the loaded texture
  78373. */
  78374. texture: HDRCubeTexture;
  78375. /**
  78376. * Callback called when the task is successful
  78377. */
  78378. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  78379. /**
  78380. * Callback called when the task is successful
  78381. */
  78382. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  78383. /**
  78384. * Creates a new HDRCubeTextureAssetTask object
  78385. * @param name defines the name of the task
  78386. * @param url defines the location of the file to load
  78387. * @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.
  78388. * @param noMipmap defines if mipmaps should not be generated (default is false)
  78389. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  78390. * @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)
  78391. * @param reserved Internal use only
  78392. */
  78393. constructor(
  78394. /**
  78395. * Defines the name of the task
  78396. */
  78397. name: string,
  78398. /**
  78399. * Defines the location of the file to load
  78400. */
  78401. url: string,
  78402. /**
  78403. * Defines the desired size (the more it increases the longer the generation will be)
  78404. */
  78405. size: number,
  78406. /**
  78407. * Defines if mipmaps should not be generated (default is false)
  78408. */
  78409. noMipmap?: boolean,
  78410. /**
  78411. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  78412. */
  78413. generateHarmonics?: boolean,
  78414. /**
  78415. * 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)
  78416. */
  78417. gammaSpace?: boolean,
  78418. /**
  78419. * Internal Use Only
  78420. */
  78421. reserved?: boolean);
  78422. /**
  78423. * Execute the current task
  78424. * @param scene defines the scene where you want your assets to be loaded
  78425. * @param onSuccess is a callback called when the task is successfully executed
  78426. * @param onError is a callback called if an error occurs
  78427. */
  78428. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78429. }
  78430. /**
  78431. * Define a task used by AssetsManager to load Equirectangular cube textures
  78432. */
  78433. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  78434. /**
  78435. * Defines the name of the task
  78436. */
  78437. name: string;
  78438. /**
  78439. * Defines the location of the file to load
  78440. */
  78441. url: string;
  78442. /**
  78443. * Defines the desired size (the more it increases the longer the generation will be)
  78444. */
  78445. size: number;
  78446. /**
  78447. * Defines if mipmaps should not be generated (default is false)
  78448. */
  78449. noMipmap: boolean;
  78450. /**
  78451. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  78452. * but the standard material would require them in Gamma space) (default is true)
  78453. */
  78454. gammaSpace: boolean;
  78455. /**
  78456. * Gets the loaded texture
  78457. */
  78458. texture: EquiRectangularCubeTexture;
  78459. /**
  78460. * Callback called when the task is successful
  78461. */
  78462. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  78463. /**
  78464. * Callback called when the task is successful
  78465. */
  78466. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  78467. /**
  78468. * Creates a new EquiRectangularCubeTextureAssetTask object
  78469. * @param name defines the name of the task
  78470. * @param url defines the location of the file to load
  78471. * @param size defines the desired size (the more it increases the longer the generation will be)
  78472. * If the size is omitted this implies you are using a preprocessed cubemap.
  78473. * @param noMipmap defines if mipmaps should not be generated (default is false)
  78474. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  78475. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  78476. * (default is true)
  78477. */
  78478. constructor(
  78479. /**
  78480. * Defines the name of the task
  78481. */
  78482. name: string,
  78483. /**
  78484. * Defines the location of the file to load
  78485. */
  78486. url: string,
  78487. /**
  78488. * Defines the desired size (the more it increases the longer the generation will be)
  78489. */
  78490. size: number,
  78491. /**
  78492. * Defines if mipmaps should not be generated (default is false)
  78493. */
  78494. noMipmap?: boolean,
  78495. /**
  78496. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  78497. * but the standard material would require them in Gamma space) (default is true)
  78498. */
  78499. gammaSpace?: boolean);
  78500. /**
  78501. * Execute the current task
  78502. * @param scene defines the scene where you want your assets to be loaded
  78503. * @param onSuccess is a callback called when the task is successfully executed
  78504. * @param onError is a callback called if an error occurs
  78505. */
  78506. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78507. }
  78508. /**
  78509. * This class can be used to easily import assets into a scene
  78510. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  78511. */
  78512. export class AssetsManager {
  78513. private _scene;
  78514. private _isLoading;
  78515. protected _tasks: AbstractAssetTask[];
  78516. protected _waitingTasksCount: number;
  78517. protected _totalTasksCount: number;
  78518. /**
  78519. * Callback called when all tasks are processed
  78520. */
  78521. onFinish: (tasks: AbstractAssetTask[]) => void;
  78522. /**
  78523. * Callback called when a task is successful
  78524. */
  78525. onTaskSuccess: (task: AbstractAssetTask) => void;
  78526. /**
  78527. * Callback called when a task had an error
  78528. */
  78529. onTaskError: (task: AbstractAssetTask) => void;
  78530. /**
  78531. * Callback called when a task is done (whatever the result is)
  78532. */
  78533. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  78534. /**
  78535. * Observable called when all tasks are processed
  78536. */
  78537. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  78538. /**
  78539. * Observable called when a task had an error
  78540. */
  78541. onTaskErrorObservable: Observable<AbstractAssetTask>;
  78542. /**
  78543. * Observable called when all tasks were executed
  78544. */
  78545. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  78546. /**
  78547. * Observable called when a task is done (whatever the result is)
  78548. */
  78549. onProgressObservable: Observable<IAssetsProgressEvent>;
  78550. /**
  78551. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  78552. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  78553. */
  78554. useDefaultLoadingScreen: boolean;
  78555. /**
  78556. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  78557. * when all assets have been downloaded.
  78558. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  78559. */
  78560. autoHideLoadingUI: boolean;
  78561. /**
  78562. * Creates a new AssetsManager
  78563. * @param scene defines the scene to work on
  78564. */
  78565. constructor(scene: Scene);
  78566. /**
  78567. * Add a ContainerAssetTask to the list of active tasks
  78568. * @param taskName defines the name of the new task
  78569. * @param meshesNames defines the name of meshes to load
  78570. * @param rootUrl defines the root url to use to locate files
  78571. * @param sceneFilename defines the filename of the scene file
  78572. * @returns a new ContainerAssetTask object
  78573. */
  78574. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  78575. /**
  78576. * Add a MeshAssetTask to the list of active tasks
  78577. * @param taskName defines the name of the new task
  78578. * @param meshesNames defines the name of meshes to load
  78579. * @param rootUrl defines the root url to use to locate files
  78580. * @param sceneFilename defines the filename of the scene file
  78581. * @returns a new MeshAssetTask object
  78582. */
  78583. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  78584. /**
  78585. * Add a TextFileAssetTask to the list of active tasks
  78586. * @param taskName defines the name of the new task
  78587. * @param url defines the url of the file to load
  78588. * @returns a new TextFileAssetTask object
  78589. */
  78590. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  78591. /**
  78592. * Add a BinaryFileAssetTask to the list of active tasks
  78593. * @param taskName defines the name of the new task
  78594. * @param url defines the url of the file to load
  78595. * @returns a new BinaryFileAssetTask object
  78596. */
  78597. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  78598. /**
  78599. * Add a ImageAssetTask to the list of active tasks
  78600. * @param taskName defines the name of the new task
  78601. * @param url defines the url of the file to load
  78602. * @returns a new ImageAssetTask object
  78603. */
  78604. addImageTask(taskName: string, url: string): ImageAssetTask;
  78605. /**
  78606. * Add a TextureAssetTask to the list of active tasks
  78607. * @param taskName defines the name of the new task
  78608. * @param url defines the url of the file to load
  78609. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78610. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  78611. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  78612. * @returns a new TextureAssetTask object
  78613. */
  78614. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  78615. /**
  78616. * Add a CubeTextureAssetTask to the list of active tasks
  78617. * @param taskName defines the name of the new task
  78618. * @param url defines the url of the file to load
  78619. * @param extensions defines the extension to use to load the cube map (can be null)
  78620. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78621. * @param files defines the list of files to load (can be null)
  78622. * @returns a new CubeTextureAssetTask object
  78623. */
  78624. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  78625. /**
  78626. *
  78627. * Add a HDRCubeTextureAssetTask to the list of active tasks
  78628. * @param taskName defines the name of the new task
  78629. * @param url defines the url of the file to load
  78630. * @param size defines the size you want for the cubemap (can be null)
  78631. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78632. * @param generateHarmonics defines if you want to automatically generate (true by default)
  78633. * @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)
  78634. * @param reserved Internal use only
  78635. * @returns a new HDRCubeTextureAssetTask object
  78636. */
  78637. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  78638. /**
  78639. *
  78640. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  78641. * @param taskName defines the name of the new task
  78642. * @param url defines the url of the file to load
  78643. * @param size defines the size you want for the cubemap (can be null)
  78644. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78645. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  78646. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  78647. * @returns a new EquiRectangularCubeTextureAssetTask object
  78648. */
  78649. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  78650. /**
  78651. * Remove a task from the assets manager.
  78652. * @param task the task to remove
  78653. */
  78654. removeTask(task: AbstractAssetTask): void;
  78655. private _decreaseWaitingTasksCount;
  78656. private _runTask;
  78657. /**
  78658. * Reset the AssetsManager and remove all tasks
  78659. * @return the current instance of the AssetsManager
  78660. */
  78661. reset(): AssetsManager;
  78662. /**
  78663. * Start the loading process
  78664. * @return the current instance of the AssetsManager
  78665. */
  78666. load(): AssetsManager;
  78667. /**
  78668. * Start the loading process as an async operation
  78669. * @return a promise returning the list of failed tasks
  78670. */
  78671. loadAsync(): Promise<void>;
  78672. }
  78673. }
  78674. declare module BABYLON {
  78675. /**
  78676. * Wrapper class for promise with external resolve and reject.
  78677. */
  78678. export class Deferred<T> {
  78679. /**
  78680. * The promise associated with this deferred object.
  78681. */
  78682. readonly promise: Promise<T>;
  78683. private _resolve;
  78684. private _reject;
  78685. /**
  78686. * The resolve method of the promise associated with this deferred object.
  78687. */
  78688. get resolve(): (value: T | PromiseLike<T>) => void;
  78689. /**
  78690. * The reject method of the promise associated with this deferred object.
  78691. */
  78692. get reject(): (reason?: any) => void;
  78693. /**
  78694. * Constructor for this deferred object.
  78695. */
  78696. constructor();
  78697. }
  78698. }
  78699. declare module BABYLON {
  78700. /**
  78701. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  78702. */
  78703. export class MeshExploder {
  78704. private _centerMesh;
  78705. private _meshes;
  78706. private _meshesOrigins;
  78707. private _toCenterVectors;
  78708. private _scaledDirection;
  78709. private _newPosition;
  78710. private _centerPosition;
  78711. /**
  78712. * Explodes meshes from a center mesh.
  78713. * @param meshes The meshes to explode.
  78714. * @param centerMesh The mesh to be center of explosion.
  78715. */
  78716. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  78717. private _setCenterMesh;
  78718. /**
  78719. * Get class name
  78720. * @returns "MeshExploder"
  78721. */
  78722. getClassName(): string;
  78723. /**
  78724. * "Exploded meshes"
  78725. * @returns Array of meshes with the centerMesh at index 0.
  78726. */
  78727. getMeshes(): Array<Mesh>;
  78728. /**
  78729. * Explodes meshes giving a specific direction
  78730. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  78731. */
  78732. explode(direction?: number): void;
  78733. }
  78734. }
  78735. declare module BABYLON {
  78736. /**
  78737. * Class used to help managing file picking and drag'n'drop
  78738. */
  78739. export class FilesInput {
  78740. /**
  78741. * List of files ready to be loaded
  78742. */
  78743. static get FilesToLoad(): {
  78744. [key: string]: File;
  78745. };
  78746. /**
  78747. * Callback called when a file is processed
  78748. */
  78749. onProcessFileCallback: (file: File, name: string, extension: string, setSceneFileToLoad: (sceneFile: File) => void) => boolean;
  78750. /**
  78751. * Function used when loading the scene file
  78752. */
  78753. loadAsync: (sceneFile: File, onProgress: Nullable<(event: ISceneLoaderProgressEvent) => void>) => Promise<Scene>;
  78754. private _engine;
  78755. private _currentScene;
  78756. private _sceneLoadedCallback;
  78757. private _progressCallback;
  78758. private _additionalRenderLoopLogicCallback;
  78759. private _textureLoadingCallback;
  78760. private _startingProcessingFilesCallback;
  78761. private _onReloadCallback;
  78762. private _errorCallback;
  78763. private _elementToMonitor;
  78764. private _sceneFileToLoad;
  78765. private _filesToLoad;
  78766. /**
  78767. * Creates a new FilesInput
  78768. * @param engine defines the rendering engine
  78769. * @param scene defines the hosting scene
  78770. * @param sceneLoadedCallback callback called when scene is loaded
  78771. * @param progressCallback callback called to track progress
  78772. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  78773. * @param textureLoadingCallback callback called when a texture is loading
  78774. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  78775. * @param onReloadCallback callback called when a reload is requested
  78776. * @param errorCallback callback call if an error occurs
  78777. */
  78778. 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>);
  78779. private _dragEnterHandler;
  78780. private _dragOverHandler;
  78781. private _dropHandler;
  78782. /**
  78783. * Calls this function to listen to drag'n'drop events on a specific DOM element
  78784. * @param elementToMonitor defines the DOM element to track
  78785. */
  78786. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  78787. /** Gets the current list of files to load */
  78788. get filesToLoad(): File[];
  78789. /**
  78790. * Release all associated resources
  78791. */
  78792. dispose(): void;
  78793. private renderFunction;
  78794. private drag;
  78795. private drop;
  78796. private _traverseFolder;
  78797. private _processFiles;
  78798. /**
  78799. * Load files from a drop event
  78800. * @param event defines the drop event to use as source
  78801. */
  78802. loadFiles(event: any): void;
  78803. private _processReload;
  78804. /**
  78805. * Reload the current scene from the loaded files
  78806. */
  78807. reload(): void;
  78808. }
  78809. }
  78810. declare module BABYLON {
  78811. /**
  78812. * Defines the root class used to create scene optimization to use with SceneOptimizer
  78813. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78814. */
  78815. export class SceneOptimization {
  78816. /**
  78817. * Defines the priority of this optimization (0 by default which means first in the list)
  78818. */
  78819. priority: number;
  78820. /**
  78821. * Gets a string describing the action executed by the current optimization
  78822. * @returns description string
  78823. */
  78824. getDescription(): string;
  78825. /**
  78826. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78827. * @param scene defines the current scene where to apply this optimization
  78828. * @param optimizer defines the current optimizer
  78829. * @returns true if everything that can be done was applied
  78830. */
  78831. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78832. /**
  78833. * Creates the SceneOptimization object
  78834. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78835. * @param desc defines the description associated with the optimization
  78836. */
  78837. constructor(
  78838. /**
  78839. * Defines the priority of this optimization (0 by default which means first in the list)
  78840. */
  78841. priority?: number);
  78842. }
  78843. /**
  78844. * Defines an optimization used to reduce the size of render target textures
  78845. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78846. */
  78847. export class TextureOptimization extends SceneOptimization {
  78848. /**
  78849. * Defines the priority of this optimization (0 by default which means first in the list)
  78850. */
  78851. priority: number;
  78852. /**
  78853. * 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
  78854. */
  78855. maximumSize: number;
  78856. /**
  78857. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78858. */
  78859. step: number;
  78860. /**
  78861. * Gets a string describing the action executed by the current optimization
  78862. * @returns description string
  78863. */
  78864. getDescription(): string;
  78865. /**
  78866. * Creates the TextureOptimization object
  78867. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78868. * @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
  78869. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78870. */
  78871. constructor(
  78872. /**
  78873. * Defines the priority of this optimization (0 by default which means first in the list)
  78874. */
  78875. priority?: number,
  78876. /**
  78877. * 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
  78878. */
  78879. maximumSize?: number,
  78880. /**
  78881. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78882. */
  78883. step?: number);
  78884. /**
  78885. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78886. * @param scene defines the current scene where to apply this optimization
  78887. * @param optimizer defines the current optimizer
  78888. * @returns true if everything that can be done was applied
  78889. */
  78890. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78891. }
  78892. /**
  78893. * Defines an optimization used to increase or decrease the rendering resolution
  78894. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78895. */
  78896. export class HardwareScalingOptimization extends SceneOptimization {
  78897. /**
  78898. * Defines the priority of this optimization (0 by default which means first in the list)
  78899. */
  78900. priority: number;
  78901. /**
  78902. * Defines the maximum scale to use (2 by default)
  78903. */
  78904. maximumScale: number;
  78905. /**
  78906. * Defines the step to use between two passes (0.5 by default)
  78907. */
  78908. step: number;
  78909. private _currentScale;
  78910. private _directionOffset;
  78911. /**
  78912. * Gets a string describing the action executed by the current optimization
  78913. * @return description string
  78914. */
  78915. getDescription(): string;
  78916. /**
  78917. * Creates the HardwareScalingOptimization object
  78918. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78919. * @param maximumScale defines the maximum scale to use (2 by default)
  78920. * @param step defines the step to use between two passes (0.5 by default)
  78921. */
  78922. constructor(
  78923. /**
  78924. * Defines the priority of this optimization (0 by default which means first in the list)
  78925. */
  78926. priority?: number,
  78927. /**
  78928. * Defines the maximum scale to use (2 by default)
  78929. */
  78930. maximumScale?: number,
  78931. /**
  78932. * Defines the step to use between two passes (0.5 by default)
  78933. */
  78934. step?: number);
  78935. /**
  78936. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78937. * @param scene defines the current scene where to apply this optimization
  78938. * @param optimizer defines the current optimizer
  78939. * @returns true if everything that can be done was applied
  78940. */
  78941. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78942. }
  78943. /**
  78944. * Defines an optimization used to remove shadows
  78945. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78946. */
  78947. export class ShadowsOptimization extends SceneOptimization {
  78948. /**
  78949. * Gets a string describing the action executed by the current optimization
  78950. * @return description string
  78951. */
  78952. getDescription(): string;
  78953. /**
  78954. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78955. * @param scene defines the current scene where to apply this optimization
  78956. * @param optimizer defines the current optimizer
  78957. * @returns true if everything that can be done was applied
  78958. */
  78959. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78960. }
  78961. /**
  78962. * Defines an optimization used to turn post-processes off
  78963. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78964. */
  78965. export class PostProcessesOptimization extends SceneOptimization {
  78966. /**
  78967. * Gets a string describing the action executed by the current optimization
  78968. * @return description string
  78969. */
  78970. getDescription(): string;
  78971. /**
  78972. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78973. * @param scene defines the current scene where to apply this optimization
  78974. * @param optimizer defines the current optimizer
  78975. * @returns true if everything that can be done was applied
  78976. */
  78977. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78978. }
  78979. /**
  78980. * Defines an optimization used to turn lens flares off
  78981. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78982. */
  78983. export class LensFlaresOptimization extends SceneOptimization {
  78984. /**
  78985. * Gets a string describing the action executed by the current optimization
  78986. * @return description string
  78987. */
  78988. getDescription(): string;
  78989. /**
  78990. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78991. * @param scene defines the current scene where to apply this optimization
  78992. * @param optimizer defines the current optimizer
  78993. * @returns true if everything that can be done was applied
  78994. */
  78995. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78996. }
  78997. /**
  78998. * Defines an optimization based on user defined callback.
  78999. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79000. */
  79001. export class CustomOptimization extends SceneOptimization {
  79002. /**
  79003. * Callback called to apply the custom optimization.
  79004. */
  79005. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  79006. /**
  79007. * Callback called to get custom description
  79008. */
  79009. onGetDescription: () => string;
  79010. /**
  79011. * Gets a string describing the action executed by the current optimization
  79012. * @returns description string
  79013. */
  79014. getDescription(): string;
  79015. /**
  79016. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79017. * @param scene defines the current scene where to apply this optimization
  79018. * @param optimizer defines the current optimizer
  79019. * @returns true if everything that can be done was applied
  79020. */
  79021. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79022. }
  79023. /**
  79024. * Defines an optimization used to turn particles off
  79025. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79026. */
  79027. export class ParticlesOptimization extends SceneOptimization {
  79028. /**
  79029. * Gets a string describing the action executed by the current optimization
  79030. * @return description string
  79031. */
  79032. getDescription(): string;
  79033. /**
  79034. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79035. * @param scene defines the current scene where to apply this optimization
  79036. * @param optimizer defines the current optimizer
  79037. * @returns true if everything that can be done was applied
  79038. */
  79039. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79040. }
  79041. /**
  79042. * Defines an optimization used to turn render targets off
  79043. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79044. */
  79045. export class RenderTargetsOptimization extends SceneOptimization {
  79046. /**
  79047. * Gets a string describing the action executed by the current optimization
  79048. * @return description string
  79049. */
  79050. getDescription(): string;
  79051. /**
  79052. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79053. * @param scene defines the current scene where to apply this optimization
  79054. * @param optimizer defines the current optimizer
  79055. * @returns true if everything that can be done was applied
  79056. */
  79057. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79058. }
  79059. /**
  79060. * Defines an optimization used to merge meshes with compatible materials
  79061. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79062. */
  79063. export class MergeMeshesOptimization extends SceneOptimization {
  79064. private static _UpdateSelectionTree;
  79065. /**
  79066. * Gets or sets a boolean which defines if optimization octree has to be updated
  79067. */
  79068. static get UpdateSelectionTree(): boolean;
  79069. /**
  79070. * Gets or sets a boolean which defines if optimization octree has to be updated
  79071. */
  79072. static set UpdateSelectionTree(value: boolean);
  79073. /**
  79074. * Gets a string describing the action executed by the current optimization
  79075. * @return description string
  79076. */
  79077. getDescription(): string;
  79078. private _canBeMerged;
  79079. /**
  79080. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79081. * @param scene defines the current scene where to apply this optimization
  79082. * @param optimizer defines the current optimizer
  79083. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  79084. * @returns true if everything that can be done was applied
  79085. */
  79086. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  79087. }
  79088. /**
  79089. * Defines a list of options used by SceneOptimizer
  79090. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79091. */
  79092. export class SceneOptimizerOptions {
  79093. /**
  79094. * Defines the target frame rate to reach (60 by default)
  79095. */
  79096. targetFrameRate: number;
  79097. /**
  79098. * Defines the interval between two checks (2000ms by default)
  79099. */
  79100. trackerDuration: number;
  79101. /**
  79102. * Gets the list of optimizations to apply
  79103. */
  79104. optimizations: SceneOptimization[];
  79105. /**
  79106. * Creates a new list of options used by SceneOptimizer
  79107. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  79108. * @param trackerDuration defines the interval between two checks (2000ms by default)
  79109. */
  79110. constructor(
  79111. /**
  79112. * Defines the target frame rate to reach (60 by default)
  79113. */
  79114. targetFrameRate?: number,
  79115. /**
  79116. * Defines the interval between two checks (2000ms by default)
  79117. */
  79118. trackerDuration?: number);
  79119. /**
  79120. * Add a new optimization
  79121. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  79122. * @returns the current SceneOptimizerOptions
  79123. */
  79124. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  79125. /**
  79126. * Add a new custom optimization
  79127. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  79128. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  79129. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  79130. * @returns the current SceneOptimizerOptions
  79131. */
  79132. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  79133. /**
  79134. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  79135. * @param targetFrameRate defines the target frame rate (60 by default)
  79136. * @returns a SceneOptimizerOptions object
  79137. */
  79138. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  79139. /**
  79140. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  79141. * @param targetFrameRate defines the target frame rate (60 by default)
  79142. * @returns a SceneOptimizerOptions object
  79143. */
  79144. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  79145. /**
  79146. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  79147. * @param targetFrameRate defines the target frame rate (60 by default)
  79148. * @returns a SceneOptimizerOptions object
  79149. */
  79150. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  79151. }
  79152. /**
  79153. * Class used to run optimizations in order to reach a target frame rate
  79154. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79155. */
  79156. export class SceneOptimizer implements IDisposable {
  79157. private _isRunning;
  79158. private _options;
  79159. private _scene;
  79160. private _currentPriorityLevel;
  79161. private _targetFrameRate;
  79162. private _trackerDuration;
  79163. private _currentFrameRate;
  79164. private _sceneDisposeObserver;
  79165. private _improvementMode;
  79166. /**
  79167. * Defines an observable called when the optimizer reaches the target frame rate
  79168. */
  79169. onSuccessObservable: Observable<SceneOptimizer>;
  79170. /**
  79171. * Defines an observable called when the optimizer enables an optimization
  79172. */
  79173. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  79174. /**
  79175. * Defines an observable called when the optimizer is not able to reach the target frame rate
  79176. */
  79177. onFailureObservable: Observable<SceneOptimizer>;
  79178. /**
  79179. * Gets a boolean indicating if the optimizer is in improvement mode
  79180. */
  79181. get isInImprovementMode(): boolean;
  79182. /**
  79183. * Gets the current priority level (0 at start)
  79184. */
  79185. get currentPriorityLevel(): number;
  79186. /**
  79187. * Gets the current frame rate checked by the SceneOptimizer
  79188. */
  79189. get currentFrameRate(): number;
  79190. /**
  79191. * Gets or sets the current target frame rate (60 by default)
  79192. */
  79193. get targetFrameRate(): number;
  79194. /**
  79195. * Gets or sets the current target frame rate (60 by default)
  79196. */
  79197. set targetFrameRate(value: number);
  79198. /**
  79199. * Gets or sets the current interval between two checks (every 2000ms by default)
  79200. */
  79201. get trackerDuration(): number;
  79202. /**
  79203. * Gets or sets the current interval between two checks (every 2000ms by default)
  79204. */
  79205. set trackerDuration(value: number);
  79206. /**
  79207. * Gets the list of active optimizations
  79208. */
  79209. get optimizations(): SceneOptimization[];
  79210. /**
  79211. * Creates a new SceneOptimizer
  79212. * @param scene defines the scene to work on
  79213. * @param options defines the options to use with the SceneOptimizer
  79214. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  79215. * @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)
  79216. */
  79217. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  79218. /**
  79219. * Stops the current optimizer
  79220. */
  79221. stop(): void;
  79222. /**
  79223. * Reset the optimizer to initial step (current priority level = 0)
  79224. */
  79225. reset(): void;
  79226. /**
  79227. * Start the optimizer. By default it will try to reach a specific framerate
  79228. * but if the optimizer is set with improvementMode === true then it will run all optimization while frame rate is above the target frame rate
  79229. */
  79230. start(): void;
  79231. private _checkCurrentState;
  79232. /**
  79233. * Release all resources
  79234. */
  79235. dispose(): void;
  79236. /**
  79237. * Helper function to create a SceneOptimizer with one single line of code
  79238. * @param scene defines the scene to work on
  79239. * @param options defines the options to use with the SceneOptimizer
  79240. * @param onSuccess defines a callback to call on success
  79241. * @param onFailure defines a callback to call on failure
  79242. * @returns the new SceneOptimizer object
  79243. */
  79244. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  79245. }
  79246. }
  79247. declare module BABYLON {
  79248. /**
  79249. * Class used to serialize a scene into a string
  79250. */
  79251. export class SceneSerializer {
  79252. /**
  79253. * Clear cache used by a previous serialization
  79254. */
  79255. static ClearCache(): void;
  79256. /**
  79257. * Serialize a scene into a JSON compatible object
  79258. * Note that if the current engine does not support synchronous texture reading (like WebGPU), you should use SerializeAsync instead
  79259. * as else you may not retrieve the proper base64 encoded texture data (when using the Texture.ForceSerializeBuffers flag)
  79260. * @param scene defines the scene to serialize
  79261. * @returns a JSON compatible object
  79262. */
  79263. static Serialize(scene: Scene): any;
  79264. private static _Serialize;
  79265. /**
  79266. * Serialize a scene into a JSON compatible object
  79267. * @param scene defines the scene to serialize
  79268. * @returns a JSON promise compatible object
  79269. */
  79270. static SerializeAsync(scene: Scene): Promise<any>;
  79271. private static _CollectPromises;
  79272. /**
  79273. * Serialize a mesh into a JSON compatible object
  79274. * @param toSerialize defines the mesh to serialize
  79275. * @param withParents defines if parents must be serialized as well
  79276. * @param withChildren defines if children must be serialized as well
  79277. * @returns a JSON compatible object
  79278. */
  79279. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  79280. }
  79281. }
  79282. declare module BABYLON {
  79283. /**
  79284. * This represents the different options available for the video capture.
  79285. */
  79286. export interface VideoRecorderOptions {
  79287. /** Defines the mime type of the video. */
  79288. mimeType: string;
  79289. /** Defines the FPS the video should be recorded at. */
  79290. fps: number;
  79291. /** Defines the chunk size for the recording data. */
  79292. recordChunckSize: number;
  79293. /** The audio tracks to attach to the recording. */
  79294. audioTracks?: MediaStreamTrack[];
  79295. }
  79296. /**
  79297. * This can help with recording videos from BabylonJS.
  79298. * This is based on the available WebRTC functionalities of the browser.
  79299. *
  79300. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  79301. */
  79302. export class VideoRecorder {
  79303. private static readonly _defaultOptions;
  79304. /**
  79305. * Returns whether or not the VideoRecorder is available in your browser.
  79306. * @param engine Defines the Babylon Engine.
  79307. * @returns true if supported otherwise false.
  79308. */
  79309. static IsSupported(engine: Engine): boolean;
  79310. private readonly _options;
  79311. private _canvas;
  79312. private _mediaRecorder;
  79313. private _recordedChunks;
  79314. private _fileName;
  79315. private _resolve;
  79316. private _reject;
  79317. /**
  79318. * True when a recording is already in progress.
  79319. */
  79320. get isRecording(): boolean;
  79321. /**
  79322. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  79323. * @param engine Defines the BabylonJS Engine you wish to record.
  79324. * @param options Defines options that can be used to customize the capture.
  79325. */
  79326. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  79327. /**
  79328. * Stops the current recording before the default capture timeout passed in the startRecording function.
  79329. */
  79330. stopRecording(): void;
  79331. /**
  79332. * Starts recording the canvas for a max duration specified in parameters.
  79333. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  79334. * If null no automatic download will start and you can rely on the promise to get the data back.
  79335. * @param maxDuration Defines the maximum recording time in seconds.
  79336. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  79337. * @return A promise callback at the end of the recording with the video data in Blob.
  79338. */
  79339. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  79340. /**
  79341. * Releases internal resources used during the recording.
  79342. */
  79343. dispose(): void;
  79344. private _handleDataAvailable;
  79345. private _handleError;
  79346. private _handleStop;
  79347. }
  79348. }
  79349. declare module BABYLON {
  79350. /**
  79351. * Class containing a set of static utilities functions for screenshots
  79352. */
  79353. export class ScreenshotTools {
  79354. /**
  79355. * Captures a screenshot of the current rendering
  79356. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79357. * @param engine defines the rendering engine
  79358. * @param camera defines the source camera
  79359. * @param size This parameter can be set to a single number or to an object with the
  79360. * following (optional) properties: precision, width, height. If a single number is passed,
  79361. * it will be used for both width and height. If an object is passed, the screenshot size
  79362. * will be derived from the parameters. The precision property is a multiplier allowing
  79363. * rendering at a higher or lower resolution
  79364. * @param successCallback defines the callback receives a single parameter which contains the
  79365. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  79366. * src parameter of an <img> to display it
  79367. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  79368. * Check your browser for supported MIME types
  79369. * @param forceDownload force the system to download the image even if a successCallback is provided
  79370. */
  79371. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, forceDownload?: boolean): void;
  79372. /**
  79373. * Captures a screenshot of the current rendering
  79374. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79375. * @param engine defines the rendering engine
  79376. * @param camera defines the source camera
  79377. * @param size This parameter can be set to a single number or to an object with the
  79378. * following (optional) properties: precision, width, height. If a single number is passed,
  79379. * it will be used for both width and height. If an object is passed, the screenshot size
  79380. * will be derived from the parameters. The precision property is a multiplier allowing
  79381. * rendering at a higher or lower resolution
  79382. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  79383. * Check your browser for supported MIME types
  79384. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  79385. * to the src parameter of an <img> to display it
  79386. */
  79387. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  79388. /**
  79389. * 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)
  79390. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79391. * @param engine defines the rendering engine
  79392. * @param camera defines the source camera
  79393. * @param width defines the expected width
  79394. * @param height defines the expected height
  79395. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  79396. * Check your browser for supported MIME types
  79397. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  79398. * to the src parameter of an <img> to display it
  79399. */
  79400. static CreateScreenshotWithResizeAsync(engine: Engine, camera: Camera, width: number, height: number, mimeType?: string): Promise<void>;
  79401. /**
  79402. * Generates an image screenshot from the specified camera.
  79403. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79404. * @param engine The engine to use for rendering
  79405. * @param camera The camera to use for rendering
  79406. * @param size This parameter can be set to a single number or to an object with the
  79407. * following (optional) properties: precision, width, height. If a single number is passed,
  79408. * it will be used for both width and height. If an object is passed, the screenshot size
  79409. * will be derived from the parameters. The precision property is a multiplier allowing
  79410. * rendering at a higher or lower resolution
  79411. * @param successCallback The callback receives a single parameter which contains the
  79412. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  79413. * src parameter of an <img> to display it
  79414. * @param mimeType The MIME type of the screenshot image (default: image/png).
  79415. * Check your browser for supported MIME types
  79416. * @param samples Texture samples (default: 1)
  79417. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  79418. * @param fileName A name for for the downloaded file.
  79419. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  79420. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  79421. */
  79422. 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;
  79423. /**
  79424. * Generates an image screenshot from the specified camera.
  79425. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79426. * @param engine The engine to use for rendering
  79427. * @param camera The camera to use for rendering
  79428. * @param size This parameter can be set to a single number or to an object with the
  79429. * following (optional) properties: precision, width, height. If a single number is passed,
  79430. * it will be used for both width and height. If an object is passed, the screenshot size
  79431. * will be derived from the parameters. The precision property is a multiplier allowing
  79432. * rendering at a higher or lower resolution
  79433. * @param mimeType The MIME type of the screenshot image (default: image/png).
  79434. * Check your browser for supported MIME types
  79435. * @param samples Texture samples (default: 1)
  79436. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  79437. * @param fileName A name for for the downloaded file.
  79438. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  79439. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  79440. * to the src parameter of an <img> to display it
  79441. */
  79442. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  79443. /**
  79444. * Gets height and width for screenshot size
  79445. * @private
  79446. */
  79447. private static _getScreenshotSize;
  79448. }
  79449. }
  79450. declare module BABYLON {
  79451. /**
  79452. * Interface for a data buffer
  79453. */
  79454. export interface IDataBuffer {
  79455. /**
  79456. * Reads bytes from the data buffer.
  79457. * @param byteOffset The byte offset to read
  79458. * @param byteLength The byte length to read
  79459. * @returns A promise that resolves when the bytes are read
  79460. */
  79461. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  79462. /**
  79463. * The byte length of the buffer.
  79464. */
  79465. readonly byteLength: number;
  79466. }
  79467. /**
  79468. * Utility class for reading from a data buffer
  79469. */
  79470. export class DataReader {
  79471. /**
  79472. * The data buffer associated with this data reader.
  79473. */
  79474. readonly buffer: IDataBuffer;
  79475. /**
  79476. * The current byte offset from the beginning of the data buffer.
  79477. */
  79478. byteOffset: number;
  79479. private _dataView;
  79480. private _dataByteOffset;
  79481. /**
  79482. * Constructor
  79483. * @param buffer The buffer to read
  79484. */
  79485. constructor(buffer: IDataBuffer);
  79486. /**
  79487. * Loads the given byte length.
  79488. * @param byteLength The byte length to load
  79489. * @returns A promise that resolves when the load is complete
  79490. */
  79491. loadAsync(byteLength: number): Promise<void>;
  79492. /**
  79493. * Read a unsigned 32-bit integer from the currently loaded data range.
  79494. * @returns The 32-bit integer read
  79495. */
  79496. readUint32(): number;
  79497. /**
  79498. * Read a byte array from the currently loaded data range.
  79499. * @param byteLength The byte length to read
  79500. * @returns The byte array read
  79501. */
  79502. readUint8Array(byteLength: number): Uint8Array;
  79503. /**
  79504. * Read a string from the currently loaded data range.
  79505. * @param byteLength The byte length to read
  79506. * @returns The string read
  79507. */
  79508. readString(byteLength: number): string;
  79509. /**
  79510. * Skips the given byte length the currently loaded data range.
  79511. * @param byteLength The byte length to skip
  79512. */
  79513. skipBytes(byteLength: number): void;
  79514. }
  79515. }
  79516. declare module BABYLON {
  79517. /**
  79518. * Class for storing data to local storage if available or in-memory storage otherwise
  79519. */
  79520. export class DataStorage {
  79521. private static _Storage;
  79522. private static _GetStorage;
  79523. /**
  79524. * Reads a string from the data storage
  79525. * @param key The key to read
  79526. * @param defaultValue The value if the key doesn't exist
  79527. * @returns The string value
  79528. */
  79529. static ReadString(key: string, defaultValue: string): string;
  79530. /**
  79531. * Writes a string to the data storage
  79532. * @param key The key to write
  79533. * @param value The value to write
  79534. */
  79535. static WriteString(key: string, value: string): void;
  79536. /**
  79537. * Reads a boolean from the data storage
  79538. * @param key The key to read
  79539. * @param defaultValue The value if the key doesn't exist
  79540. * @returns The boolean value
  79541. */
  79542. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  79543. /**
  79544. * Writes a boolean to the data storage
  79545. * @param key The key to write
  79546. * @param value The value to write
  79547. */
  79548. static WriteBoolean(key: string, value: boolean): void;
  79549. /**
  79550. * Reads a number from the data storage
  79551. * @param key The key to read
  79552. * @param defaultValue The value if the key doesn't exist
  79553. * @returns The number value
  79554. */
  79555. static ReadNumber(key: string, defaultValue: number): number;
  79556. /**
  79557. * Writes a number to the data storage
  79558. * @param key The key to write
  79559. * @param value The value to write
  79560. */
  79561. static WriteNumber(key: string, value: number): void;
  79562. }
  79563. }
  79564. declare module BABYLON {
  79565. /**
  79566. * Class used to record delta files between 2 scene states
  79567. */
  79568. export class SceneRecorder {
  79569. private _trackedScene;
  79570. private _savedJSON;
  79571. /**
  79572. * Track a given scene. This means the current scene state will be considered the original state
  79573. * @param scene defines the scene to track
  79574. */
  79575. track(scene: Scene): void;
  79576. /**
  79577. * Get the delta between current state and original state
  79578. * @returns a any containing the delta
  79579. */
  79580. getDelta(): any;
  79581. private _compareArray;
  79582. private _compareObjects;
  79583. private _compareCollections;
  79584. private static GetShadowGeneratorById;
  79585. /**
  79586. * Apply a given delta to a given scene
  79587. * @param deltaJSON defines the JSON containing the delta
  79588. * @param scene defines the scene to apply the delta to
  79589. */
  79590. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  79591. private static _ApplyPropertiesToEntity;
  79592. private static _ApplyDeltaForEntity;
  79593. }
  79594. }
  79595. declare module BABYLON {
  79596. /**
  79597. * A 3D trajectory consisting of an order list of vectors describing a
  79598. * path of motion through 3D space.
  79599. */
  79600. export class Trajectory {
  79601. private _points;
  79602. private readonly _segmentLength;
  79603. /**
  79604. * Serialize to JSON.
  79605. * @returns serialized JSON string
  79606. */
  79607. serialize(): string;
  79608. /**
  79609. * Deserialize from JSON.
  79610. * @param json serialized JSON string
  79611. * @returns deserialized Trajectory
  79612. */
  79613. static Deserialize(json: string): Trajectory;
  79614. /**
  79615. * Create a new empty Trajectory.
  79616. * @param segmentLength radius of discretization for Trajectory points
  79617. */
  79618. constructor(segmentLength?: number);
  79619. /**
  79620. * Get the length of the Trajectory.
  79621. * @returns length of the Trajectory
  79622. */
  79623. getLength(): number;
  79624. /**
  79625. * Append a new point to the Trajectory.
  79626. * NOTE: This implementation has many allocations.
  79627. * @param point point to append to the Trajectory
  79628. */
  79629. add(point: DeepImmutable<Vector3>): void;
  79630. /**
  79631. * Create a new Trajectory with a segment length chosen to make it
  79632. * probable that the new Trajectory will have a specified number of
  79633. * segments. This operation is imprecise.
  79634. * @param targetResolution number of segments desired
  79635. * @returns new Trajectory with approximately the requested number of segments
  79636. */
  79637. resampleAtTargetResolution(targetResolution: number): Trajectory;
  79638. /**
  79639. * Convert Trajectory segments into tokenized representation. This
  79640. * representation is an array of numbers where each nth number is the
  79641. * index of the token which is most similar to the nth segment of the
  79642. * Trajectory.
  79643. * @param tokens list of vectors which serve as discrete tokens
  79644. * @returns list of indices of most similar token per segment
  79645. */
  79646. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  79647. private static _forwardDir;
  79648. private static _inverseFromVec;
  79649. private static _upDir;
  79650. private static _fromToVec;
  79651. private static _lookMatrix;
  79652. /**
  79653. * Transform the rotation (i.e., direction) of a segment to isolate
  79654. * the relative transformation represented by the segment. This operation
  79655. * may or may not succeed due to singularities in the equations that define
  79656. * motion relativity in this context.
  79657. * @param priorVec the origin of the prior segment
  79658. * @param fromVec the origin of the current segment
  79659. * @param toVec the destination of the current segment
  79660. * @param result reference to output variable
  79661. * @returns whether or not transformation was successful
  79662. */
  79663. private static _transformSegmentDirToRef;
  79664. private static _bestMatch;
  79665. private static _score;
  79666. private static _bestScore;
  79667. /**
  79668. * Determine which token vector is most similar to the
  79669. * segment vector.
  79670. * @param segment segment vector
  79671. * @param tokens token vector list
  79672. * @returns index of the most similar token to the segment
  79673. */
  79674. private static _tokenizeSegment;
  79675. }
  79676. /**
  79677. * Class representing a set of known, named trajectories to which Trajectories can be
  79678. * added and using which Trajectories can be recognized.
  79679. */
  79680. export class TrajectoryClassifier {
  79681. private _maximumAllowableMatchCost;
  79682. private _vector3Alphabet;
  79683. private _levenshteinAlphabet;
  79684. private _nameToDescribedTrajectory;
  79685. /**
  79686. * Serialize to JSON.
  79687. * @returns JSON serialization
  79688. */
  79689. serialize(): string;
  79690. /**
  79691. * Deserialize from JSON.
  79692. * @param json JSON serialization
  79693. * @returns deserialized TrajectorySet
  79694. */
  79695. static Deserialize(json: string): TrajectoryClassifier;
  79696. /**
  79697. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  79698. * VERY naive, need to be generating these things from known
  79699. * sets. Better version later, probably eliminating this one.
  79700. * @returns auto-generated TrajectorySet
  79701. */
  79702. static Generate(): TrajectoryClassifier;
  79703. private constructor();
  79704. /**
  79705. * Add a new Trajectory to the set with a given name.
  79706. * @param trajectory new Trajectory to be added
  79707. * @param classification name to which to add the Trajectory
  79708. */
  79709. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  79710. /**
  79711. * Remove a known named trajectory and all Trajectories associated with it.
  79712. * @param classification name to remove
  79713. * @returns whether anything was removed
  79714. */
  79715. deleteClassification(classification: string): boolean;
  79716. /**
  79717. * Attempt to recognize a Trajectory from among all the classifications
  79718. * already known to the classifier.
  79719. * @param trajectory Trajectory to be recognized
  79720. * @returns classification of Trajectory if recognized, null otherwise
  79721. */
  79722. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  79723. }
  79724. }
  79725. declare module BABYLON {
  79726. /**
  79727. * An interface for all Hit test features
  79728. */
  79729. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  79730. /**
  79731. * Triggered when new babylon (transformed) hit test results are available
  79732. */
  79733. onHitTestResultObservable: Observable<T[]>;
  79734. }
  79735. /**
  79736. * Options used for hit testing
  79737. */
  79738. export interface IWebXRLegacyHitTestOptions {
  79739. /**
  79740. * Only test when user interacted with the scene. Default - hit test every frame
  79741. */
  79742. testOnPointerDownOnly?: boolean;
  79743. /**
  79744. * The node to use to transform the local results to world coordinates
  79745. */
  79746. worldParentNode?: TransformNode;
  79747. }
  79748. /**
  79749. * Interface defining the babylon result of raycasting/hit-test
  79750. */
  79751. export interface IWebXRLegacyHitResult {
  79752. /**
  79753. * Transformation matrix that can be applied to a node that will put it in the hit point location
  79754. */
  79755. transformationMatrix: Matrix;
  79756. /**
  79757. * The native hit test result
  79758. */
  79759. xrHitResult: XRHitResult | XRHitTestResult;
  79760. }
  79761. /**
  79762. * The currently-working hit-test module.
  79763. * Hit test (or Ray-casting) is used to interact with the real world.
  79764. * For further information read here - https://github.com/immersive-web/hit-test
  79765. */
  79766. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  79767. /**
  79768. * options to use when constructing this feature
  79769. */
  79770. readonly options: IWebXRLegacyHitTestOptions;
  79771. private _direction;
  79772. private _mat;
  79773. private _onSelectEnabled;
  79774. private _origin;
  79775. /**
  79776. * The module's name
  79777. */
  79778. static readonly Name: string;
  79779. /**
  79780. * The (Babylon) version of this module.
  79781. * This is an integer representing the implementation version.
  79782. * This number does not correspond to the WebXR specs version
  79783. */
  79784. static readonly Version: number;
  79785. /**
  79786. * Populated with the last native XR Hit Results
  79787. */
  79788. lastNativeXRHitResults: XRHitResult[];
  79789. /**
  79790. * Triggered when new babylon (transformed) hit test results are available
  79791. */
  79792. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  79793. /**
  79794. * Creates a new instance of the (legacy version) hit test feature
  79795. * @param _xrSessionManager an instance of WebXRSessionManager
  79796. * @param options options to use when constructing this feature
  79797. */
  79798. constructor(_xrSessionManager: WebXRSessionManager,
  79799. /**
  79800. * options to use when constructing this feature
  79801. */
  79802. options?: IWebXRLegacyHitTestOptions);
  79803. /**
  79804. * execute a hit test with an XR Ray
  79805. *
  79806. * @param xrSession a native xrSession that will execute this hit test
  79807. * @param xrRay the ray (position and direction) to use for ray-casting
  79808. * @param referenceSpace native XR reference space to use for the hit-test
  79809. * @param filter filter function that will filter the results
  79810. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  79811. */
  79812. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  79813. /**
  79814. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  79815. * @param event the (select) event to use to select with
  79816. * @param referenceSpace the reference space to use for this hit test
  79817. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  79818. */
  79819. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  79820. /**
  79821. * attach this feature
  79822. * Will usually be called by the features manager
  79823. *
  79824. * @returns true if successful.
  79825. */
  79826. attach(): boolean;
  79827. /**
  79828. * detach this feature.
  79829. * Will usually be called by the features manager
  79830. *
  79831. * @returns true if successful.
  79832. */
  79833. detach(): boolean;
  79834. /**
  79835. * Dispose this feature and all of the resources attached
  79836. */
  79837. dispose(): void;
  79838. protected _onXRFrame(frame: XRFrame): void;
  79839. private _onHitTestResults;
  79840. private _onSelect;
  79841. }
  79842. }
  79843. declare module BABYLON {
  79844. /**
  79845. * Options used for hit testing (version 2)
  79846. */
  79847. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  79848. /**
  79849. * Do not create a permanent hit test. Will usually be used when only
  79850. * transient inputs are needed.
  79851. */
  79852. disablePermanentHitTest?: boolean;
  79853. /**
  79854. * Enable transient (for example touch-based) hit test inspections
  79855. */
  79856. enableTransientHitTest?: boolean;
  79857. /**
  79858. * Offset ray for the permanent hit test
  79859. */
  79860. offsetRay?: Vector3;
  79861. /**
  79862. * Offset ray for the transient hit test
  79863. */
  79864. transientOffsetRay?: Vector3;
  79865. /**
  79866. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  79867. */
  79868. useReferenceSpace?: boolean;
  79869. /**
  79870. * Override the default entity type(s) of the hit-test result
  79871. */
  79872. entityTypes?: XRHitTestTrackableType[];
  79873. }
  79874. /**
  79875. * Interface defining the babylon result of hit-test
  79876. */
  79877. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  79878. /**
  79879. * The input source that generated this hit test (if transient)
  79880. */
  79881. inputSource?: XRInputSource;
  79882. /**
  79883. * Is this a transient hit test
  79884. */
  79885. isTransient?: boolean;
  79886. /**
  79887. * Position of the hit test result
  79888. */
  79889. position: Vector3;
  79890. /**
  79891. * Rotation of the hit test result
  79892. */
  79893. rotationQuaternion: Quaternion;
  79894. /**
  79895. * The native hit test result
  79896. */
  79897. xrHitResult: XRHitTestResult;
  79898. }
  79899. /**
  79900. * The currently-working hit-test module.
  79901. * Hit test (or Ray-casting) is used to interact with the real world.
  79902. * For further information read here - https://github.com/immersive-web/hit-test
  79903. *
  79904. * Tested on chrome (mobile) 80.
  79905. */
  79906. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  79907. /**
  79908. * options to use when constructing this feature
  79909. */
  79910. readonly options: IWebXRHitTestOptions;
  79911. private _tmpMat;
  79912. private _tmpPos;
  79913. private _tmpQuat;
  79914. private _transientXrHitTestSource;
  79915. private _xrHitTestSource;
  79916. private initHitTestSource;
  79917. /**
  79918. * The module's name
  79919. */
  79920. static readonly Name: string;
  79921. /**
  79922. * The (Babylon) version of this module.
  79923. * This is an integer representing the implementation version.
  79924. * This number does not correspond to the WebXR specs version
  79925. */
  79926. static readonly Version: number;
  79927. /**
  79928. * When set to true, each hit test will have its own position/rotation objects
  79929. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  79930. * the developers will clone them or copy them as they see fit.
  79931. */
  79932. autoCloneTransformation: boolean;
  79933. /**
  79934. * Triggered when new babylon (transformed) hit test results are available
  79935. * Note - this will be called when results come back from the device. It can be an empty array!!
  79936. */
  79937. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  79938. /**
  79939. * Use this to temporarily pause hit test checks.
  79940. */
  79941. paused: boolean;
  79942. /**
  79943. * Creates a new instance of the hit test feature
  79944. * @param _xrSessionManager an instance of WebXRSessionManager
  79945. * @param options options to use when constructing this feature
  79946. */
  79947. constructor(_xrSessionManager: WebXRSessionManager,
  79948. /**
  79949. * options to use when constructing this feature
  79950. */
  79951. options?: IWebXRHitTestOptions);
  79952. /**
  79953. * attach this feature
  79954. * Will usually be called by the features manager
  79955. *
  79956. * @returns true if successful.
  79957. */
  79958. attach(): boolean;
  79959. /**
  79960. * detach this feature.
  79961. * Will usually be called by the features manager
  79962. *
  79963. * @returns true if successful.
  79964. */
  79965. detach(): boolean;
  79966. /**
  79967. * Dispose this feature and all of the resources attached
  79968. */
  79969. dispose(): void;
  79970. protected _onXRFrame(frame: XRFrame): void;
  79971. private _processWebXRHitTestResult;
  79972. }
  79973. }
  79974. declare module BABYLON {
  79975. /**
  79976. * Configuration options of the anchor system
  79977. */
  79978. export interface IWebXRAnchorSystemOptions {
  79979. /**
  79980. * a node that will be used to convert local to world coordinates
  79981. */
  79982. worldParentNode?: TransformNode;
  79983. /**
  79984. * If set to true a reference of the created anchors will be kept until the next session starts
  79985. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  79986. */
  79987. doNotRemoveAnchorsOnSessionEnded?: boolean;
  79988. }
  79989. /**
  79990. * A babylon container for an XR Anchor
  79991. */
  79992. export interface IWebXRAnchor {
  79993. /**
  79994. * A babylon-assigned ID for this anchor
  79995. */
  79996. id: number;
  79997. /**
  79998. * Transformation matrix to apply to an object attached to this anchor
  79999. */
  80000. transformationMatrix: Matrix;
  80001. /**
  80002. * The native anchor object
  80003. */
  80004. xrAnchor: XRAnchor;
  80005. /**
  80006. * if defined, this object will be constantly updated by the anchor's position and rotation
  80007. */
  80008. attachedNode?: TransformNode;
  80009. /**
  80010. * Remove this anchor from the scene
  80011. */
  80012. remove(): void;
  80013. }
  80014. /**
  80015. * An implementation of the anchor system for WebXR.
  80016. * For further information see https://github.com/immersive-web/anchors/
  80017. */
  80018. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  80019. private _options;
  80020. private _lastFrameDetected;
  80021. private _trackedAnchors;
  80022. private _referenceSpaceForFrameAnchors;
  80023. private _futureAnchors;
  80024. /**
  80025. * The module's name
  80026. */
  80027. static readonly Name: string;
  80028. /**
  80029. * The (Babylon) version of this module.
  80030. * This is an integer representing the implementation version.
  80031. * This number does not correspond to the WebXR specs version
  80032. */
  80033. static readonly Version: number;
  80034. /**
  80035. * Observers registered here will be executed when a new anchor was added to the session
  80036. */
  80037. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  80038. /**
  80039. * Observers registered here will be executed when an anchor was removed from the session
  80040. */
  80041. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  80042. /**
  80043. * Observers registered here will be executed when an existing anchor updates
  80044. * This can execute N times every frame
  80045. */
  80046. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  80047. /**
  80048. * Set the reference space to use for anchor creation, when not using a hit test.
  80049. * Will default to the session's reference space if not defined
  80050. */
  80051. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  80052. /**
  80053. * constructs a new anchor system
  80054. * @param _xrSessionManager an instance of WebXRSessionManager
  80055. * @param _options configuration object for this feature
  80056. */
  80057. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  80058. private _tmpVector;
  80059. private _tmpQuaternion;
  80060. private _populateTmpTransformation;
  80061. /**
  80062. * Create a new anchor point using a hit test result at a specific point in the scene
  80063. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  80064. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  80065. *
  80066. * @param hitTestResult The hit test result to use for this anchor creation
  80067. * @param position an optional position offset for this anchor
  80068. * @param rotationQuaternion an optional rotation offset for this anchor
  80069. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  80070. */
  80071. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<IWebXRAnchor>;
  80072. /**
  80073. * Add a new anchor at a specific position and rotation
  80074. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  80075. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  80076. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  80077. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  80078. *
  80079. * @param position the position in which to add an anchor
  80080. * @param rotationQuaternion an optional rotation for the anchor transformation
  80081. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  80082. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  80083. */
  80084. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<IWebXRAnchor>;
  80085. /**
  80086. * Get the list of anchors currently being tracked by the system
  80087. */
  80088. get anchors(): IWebXRAnchor[];
  80089. /**
  80090. * detach this feature.
  80091. * Will usually be called by the features manager
  80092. *
  80093. * @returns true if successful.
  80094. */
  80095. detach(): boolean;
  80096. /**
  80097. * Dispose this feature and all of the resources attached
  80098. */
  80099. dispose(): void;
  80100. protected _onXRFrame(frame: XRFrame): void;
  80101. /**
  80102. * avoiding using Array.find for global support.
  80103. * @param xrAnchor the plane to find in the array
  80104. */
  80105. private _findIndexInAnchorArray;
  80106. private _updateAnchorWithXRFrame;
  80107. private _createAnchorAtTransformation;
  80108. }
  80109. }
  80110. declare module BABYLON {
  80111. /**
  80112. * Options used in the plane detector module
  80113. */
  80114. export interface IWebXRPlaneDetectorOptions {
  80115. /**
  80116. * The node to use to transform the local results to world coordinates
  80117. */
  80118. worldParentNode?: TransformNode;
  80119. /**
  80120. * If set to true a reference of the created planes will be kept until the next session starts
  80121. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  80122. */
  80123. doNotRemovePlanesOnSessionEnded?: boolean;
  80124. /**
  80125. * Preferred detector configuration, not all preferred options will be supported by all platforms.
  80126. */
  80127. preferredDetectorOptions?: XRGeometryDetectorOptions;
  80128. }
  80129. /**
  80130. * A babylon interface for a WebXR plane.
  80131. * A Plane is actually a polygon, built from N points in space
  80132. *
  80133. * Supported in chrome 79, not supported in canary 81 ATM
  80134. */
  80135. export interface IWebXRPlane {
  80136. /**
  80137. * a babylon-assigned ID for this polygon
  80138. */
  80139. id: number;
  80140. /**
  80141. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  80142. */
  80143. polygonDefinition: Array<Vector3>;
  80144. /**
  80145. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  80146. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  80147. */
  80148. transformationMatrix: Matrix;
  80149. /**
  80150. * the native xr-plane object
  80151. */
  80152. xrPlane: XRPlane;
  80153. }
  80154. /**
  80155. * The plane detector is used to detect planes in the real world when in AR
  80156. * For more information see https://github.com/immersive-web/real-world-geometry/
  80157. */
  80158. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  80159. private _options;
  80160. private _detectedPlanes;
  80161. private _enabled;
  80162. private _lastFrameDetected;
  80163. /**
  80164. * The module's name
  80165. */
  80166. static readonly Name: string;
  80167. /**
  80168. * The (Babylon) version of this module.
  80169. * This is an integer representing the implementation version.
  80170. * This number does not correspond to the WebXR specs version
  80171. */
  80172. static readonly Version: number;
  80173. /**
  80174. * Observers registered here will be executed when a new plane was added to the session
  80175. */
  80176. onPlaneAddedObservable: Observable<IWebXRPlane>;
  80177. /**
  80178. * Observers registered here will be executed when a plane is no longer detected in the session
  80179. */
  80180. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  80181. /**
  80182. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  80183. * This can execute N times every frame
  80184. */
  80185. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  80186. /**
  80187. * construct a new Plane Detector
  80188. * @param _xrSessionManager an instance of xr Session manager
  80189. * @param _options configuration to use when constructing this feature
  80190. */
  80191. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  80192. /**
  80193. * detach this feature.
  80194. * Will usually be called by the features manager
  80195. *
  80196. * @returns true if successful.
  80197. */
  80198. detach(): boolean;
  80199. /**
  80200. * Dispose this feature and all of the resources attached
  80201. */
  80202. dispose(): void;
  80203. /**
  80204. * Check if the needed objects are defined.
  80205. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  80206. */
  80207. isCompatible(): boolean;
  80208. protected _onXRFrame(frame: XRFrame): void;
  80209. private _init;
  80210. private _updatePlaneWithXRPlane;
  80211. /**
  80212. * avoiding using Array.find for global support.
  80213. * @param xrPlane the plane to find in the array
  80214. */
  80215. private _findIndexInPlaneArray;
  80216. }
  80217. }
  80218. declare module BABYLON {
  80219. /**
  80220. * Options interface for the background remover plugin
  80221. */
  80222. export interface IWebXRBackgroundRemoverOptions {
  80223. /**
  80224. * Further background meshes to disable when entering AR
  80225. */
  80226. backgroundMeshes?: AbstractMesh[];
  80227. /**
  80228. * flags to configure the removal of the environment helper.
  80229. * If not set, the entire background will be removed. If set, flags should be set as well.
  80230. */
  80231. environmentHelperRemovalFlags?: {
  80232. /**
  80233. * Should the skybox be removed (default false)
  80234. */
  80235. skyBox?: boolean;
  80236. /**
  80237. * Should the ground be removed (default false)
  80238. */
  80239. ground?: boolean;
  80240. };
  80241. /**
  80242. * don't disable the environment helper
  80243. */
  80244. ignoreEnvironmentHelper?: boolean;
  80245. }
  80246. /**
  80247. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  80248. */
  80249. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  80250. /**
  80251. * read-only options to be used in this module
  80252. */
  80253. readonly options: IWebXRBackgroundRemoverOptions;
  80254. /**
  80255. * The module's name
  80256. */
  80257. static readonly Name: string;
  80258. /**
  80259. * The (Babylon) version of this module.
  80260. * This is an integer representing the implementation version.
  80261. * This number does not correspond to the WebXR specs version
  80262. */
  80263. static readonly Version: number;
  80264. /**
  80265. * registered observers will be triggered when the background state changes
  80266. */
  80267. onBackgroundStateChangedObservable: Observable<boolean>;
  80268. /**
  80269. * constructs a new background remover module
  80270. * @param _xrSessionManager the session manager for this module
  80271. * @param options read-only options to be used in this module
  80272. */
  80273. constructor(_xrSessionManager: WebXRSessionManager,
  80274. /**
  80275. * read-only options to be used in this module
  80276. */
  80277. options?: IWebXRBackgroundRemoverOptions);
  80278. /**
  80279. * attach this feature
  80280. * Will usually be called by the features manager
  80281. *
  80282. * @returns true if successful.
  80283. */
  80284. attach(): boolean;
  80285. /**
  80286. * detach this feature.
  80287. * Will usually be called by the features manager
  80288. *
  80289. * @returns true if successful.
  80290. */
  80291. detach(): boolean;
  80292. /**
  80293. * Dispose this feature and all of the resources attached
  80294. */
  80295. dispose(): void;
  80296. protected _onXRFrame(_xrFrame: XRFrame): void;
  80297. private _setBackgroundState;
  80298. }
  80299. }
  80300. declare module BABYLON {
  80301. /**
  80302. * Options for the controller physics feature
  80303. */
  80304. export class IWebXRControllerPhysicsOptions {
  80305. /**
  80306. * Should the headset get its own impostor
  80307. */
  80308. enableHeadsetImpostor?: boolean;
  80309. /**
  80310. * Optional parameters for the headset impostor
  80311. */
  80312. headsetImpostorParams?: {
  80313. /**
  80314. * The type of impostor to create. Default is sphere
  80315. */
  80316. impostorType: number;
  80317. /**
  80318. * the size of the impostor. Defaults to 10cm
  80319. */
  80320. impostorSize?: number | {
  80321. width: number;
  80322. height: number;
  80323. depth: number;
  80324. };
  80325. /**
  80326. * Friction definitions
  80327. */
  80328. friction?: number;
  80329. /**
  80330. * Restitution
  80331. */
  80332. restitution?: number;
  80333. };
  80334. /**
  80335. * The physics properties of the future impostors
  80336. */
  80337. physicsProperties?: {
  80338. /**
  80339. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  80340. * Note that this requires a physics engine that supports mesh impostors!
  80341. */
  80342. useControllerMesh?: boolean;
  80343. /**
  80344. * The type of impostor to create. Default is sphere
  80345. */
  80346. impostorType?: number;
  80347. /**
  80348. * the size of the impostor. Defaults to 10cm
  80349. */
  80350. impostorSize?: number | {
  80351. width: number;
  80352. height: number;
  80353. depth: number;
  80354. };
  80355. /**
  80356. * Friction definitions
  80357. */
  80358. friction?: number;
  80359. /**
  80360. * Restitution
  80361. */
  80362. restitution?: number;
  80363. };
  80364. /**
  80365. * the xr input to use with this pointer selection
  80366. */
  80367. xrInput: WebXRInput;
  80368. }
  80369. /**
  80370. * Add physics impostor to your webxr controllers,
  80371. * including naive calculation of their linear and angular velocity
  80372. */
  80373. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  80374. private readonly _options;
  80375. private _attachController;
  80376. private _controllers;
  80377. private _debugMode;
  80378. private _delta;
  80379. private _headsetImpostor?;
  80380. private _headsetMesh?;
  80381. private _lastTimestamp;
  80382. private _tmpQuaternion;
  80383. private _tmpVector;
  80384. /**
  80385. * The module's name
  80386. */
  80387. static readonly Name: string;
  80388. /**
  80389. * The (Babylon) version of this module.
  80390. * This is an integer representing the implementation version.
  80391. * This number does not correspond to the webxr specs version
  80392. */
  80393. static readonly Version: number;
  80394. /**
  80395. * Construct a new Controller Physics Feature
  80396. * @param _xrSessionManager the corresponding xr session manager
  80397. * @param _options options to create this feature with
  80398. */
  80399. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  80400. /**
  80401. * @hidden
  80402. * enable debugging - will show console outputs and the impostor mesh
  80403. */
  80404. _enablePhysicsDebug(): void;
  80405. /**
  80406. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  80407. * @param xrController the controller to add
  80408. */
  80409. addController(xrController: WebXRInputSource): void;
  80410. /**
  80411. * attach this feature
  80412. * Will usually be called by the features manager
  80413. *
  80414. * @returns true if successful.
  80415. */
  80416. attach(): boolean;
  80417. /**
  80418. * detach this feature.
  80419. * Will usually be called by the features manager
  80420. *
  80421. * @returns true if successful.
  80422. */
  80423. detach(): boolean;
  80424. /**
  80425. * Get the headset impostor, if enabled
  80426. * @returns the impostor
  80427. */
  80428. getHeadsetImpostor(): PhysicsImpostor | undefined;
  80429. /**
  80430. * Get the physics impostor of a specific controller.
  80431. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  80432. * @param controller the controller or the controller id of which to get the impostor
  80433. * @returns the impostor or null
  80434. */
  80435. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  80436. /**
  80437. * Update the physics properties provided in the constructor
  80438. * @param newProperties the new properties object
  80439. */
  80440. setPhysicsProperties(newProperties: {
  80441. impostorType?: number;
  80442. impostorSize?: number | {
  80443. width: number;
  80444. height: number;
  80445. depth: number;
  80446. };
  80447. friction?: number;
  80448. restitution?: number;
  80449. }): void;
  80450. protected _onXRFrame(_xrFrame: any): void;
  80451. private _detachController;
  80452. }
  80453. }
  80454. declare module BABYLON {
  80455. /**
  80456. * A babylon interface for a "WebXR" feature point.
  80457. * Represents the position and confidence value of a given feature point.
  80458. */
  80459. export interface IWebXRFeaturePoint {
  80460. /**
  80461. * Represents the position of the feature point in world space.
  80462. */
  80463. position: Vector3;
  80464. /**
  80465. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  80466. */
  80467. confidenceValue: number;
  80468. }
  80469. /**
  80470. * The feature point system is used to detect feature points from real world geometry.
  80471. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  80472. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  80473. */
  80474. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  80475. private _enabled;
  80476. private _featurePointCloud;
  80477. /**
  80478. * The module's name
  80479. */
  80480. static readonly Name: string;
  80481. /**
  80482. * The (Babylon) version of this module.
  80483. * This is an integer representing the implementation version.
  80484. * This number does not correspond to the WebXR specs version
  80485. */
  80486. static readonly Version: number;
  80487. /**
  80488. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  80489. * Will notify the observers about which feature points have been added.
  80490. */
  80491. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  80492. /**
  80493. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  80494. * Will notify the observers about which feature points have been updated.
  80495. */
  80496. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  80497. /**
  80498. * The current feature point cloud maintained across frames.
  80499. */
  80500. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  80501. /**
  80502. * construct the feature point system
  80503. * @param _xrSessionManager an instance of xr Session manager
  80504. */
  80505. constructor(_xrSessionManager: WebXRSessionManager);
  80506. /**
  80507. * Detach this feature.
  80508. * Will usually be called by the features manager
  80509. *
  80510. * @returns true if successful.
  80511. */
  80512. detach(): boolean;
  80513. /**
  80514. * Dispose this feature and all of the resources attached
  80515. */
  80516. dispose(): void;
  80517. /**
  80518. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  80519. */
  80520. protected _onXRFrame(frame: XRFrame): void;
  80521. /**
  80522. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  80523. */
  80524. private _init;
  80525. }
  80526. }
  80527. declare module BABYLON {
  80528. /**
  80529. * Configuration interface for the hand tracking feature
  80530. */
  80531. export interface IWebXRHandTrackingOptions {
  80532. /**
  80533. * The xrInput that will be used as source for new hands
  80534. */
  80535. xrInput: WebXRInput;
  80536. /**
  80537. * Configuration object for the joint meshes
  80538. */
  80539. jointMeshes?: {
  80540. /**
  80541. * Should the meshes created be invisible (defaults to false)
  80542. */
  80543. invisible?: boolean;
  80544. /**
  80545. * A source mesh to be used to create instances. Defaults to a sphere.
  80546. * This mesh will be the source for all other (25) meshes.
  80547. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  80548. */
  80549. sourceMesh?: Mesh;
  80550. /**
  80551. * This function will be called after a mesh was created for a specific joint.
  80552. * Using this function you can either manipulate the instance or return a new mesh.
  80553. * When returning a new mesh the instance created before will be disposed
  80554. */
  80555. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  80556. /**
  80557. * Should the source mesh stay visible. Defaults to false
  80558. */
  80559. keepOriginalVisible?: boolean;
  80560. /**
  80561. * Scale factor for all instances (defaults to 2)
  80562. */
  80563. scaleFactor?: number;
  80564. /**
  80565. * Should each instance have its own physics impostor
  80566. */
  80567. enablePhysics?: boolean;
  80568. /**
  80569. * If enabled, override default physics properties
  80570. */
  80571. physicsProps?: {
  80572. friction?: number;
  80573. restitution?: number;
  80574. impostorType?: number;
  80575. };
  80576. /**
  80577. * Should the default hand mesh be disabled. In this case, the spheres will be visible (unless set invisible).
  80578. */
  80579. disableDefaultHandMesh?: boolean;
  80580. /**
  80581. * a rigged hand-mesh that will be updated according to the XRHand data provided. This will override the default hand mesh
  80582. */
  80583. handMeshes?: {
  80584. right: AbstractMesh;
  80585. left: AbstractMesh;
  80586. };
  80587. /**
  80588. * Are the meshes prepared for a left-handed system. Default hand meshes are right-handed.
  80589. */
  80590. leftHandedSystemMeshes?: boolean;
  80591. /**
  80592. * If a hand mesh was provided, this array will define what axis will update which node. This will override the default hand mesh
  80593. */
  80594. rigMapping?: {
  80595. right: string[];
  80596. left: string[];
  80597. };
  80598. /**
  80599. * The utilityLayer scene that contains the 3D UI elements. Passing this in turns on near interactions with the index finger tip
  80600. */
  80601. sceneForNearInteraction?: Scene;
  80602. };
  80603. }
  80604. /**
  80605. * Parts of the hands divided to writs and finger names
  80606. */
  80607. export const enum HandPart {
  80608. /**
  80609. * HandPart - Wrist
  80610. */
  80611. WRIST = "wrist",
  80612. /**
  80613. * HandPart - The thumb
  80614. */
  80615. THUMB = "thumb",
  80616. /**
  80617. * HandPart - Index finger
  80618. */
  80619. INDEX = "index",
  80620. /**
  80621. * HandPart - Middle finger
  80622. */
  80623. MIDDLE = "middle",
  80624. /**
  80625. * HandPart - Ring finger
  80626. */
  80627. RING = "ring",
  80628. /**
  80629. * HandPart - Little finger
  80630. */
  80631. LITTLE = "little"
  80632. }
  80633. /**
  80634. * Representing a single hand (with its corresponding native XRHand object)
  80635. */
  80636. export class WebXRHand implements IDisposable {
  80637. /** the controller to which the hand correlates */
  80638. readonly xrController: WebXRInputSource;
  80639. /** the meshes to be used to track the hand joints */
  80640. readonly trackedMeshes: AbstractMesh[];
  80641. private _handMesh?;
  80642. private _rigMapping?;
  80643. private _nearInteractionMesh?;
  80644. private _leftHandedMeshes?;
  80645. private _scene;
  80646. private _defaultHandMesh;
  80647. private _transformNodeMapping;
  80648. private _boneMapping;
  80649. private _useBones;
  80650. /**
  80651. * Hand-parts definition (key is HandPart)
  80652. */
  80653. handPartsDefinition: {
  80654. [key: string]: number[];
  80655. };
  80656. /**
  80657. * Observers will be triggered when the mesh for this hand was initialized.
  80658. */
  80659. onHandMeshReadyObservable: Observable<WebXRHand>;
  80660. /**
  80661. * Populate the HandPartsDefinition object.
  80662. * This is called as a side effect since certain browsers don't have XRHand defined.
  80663. */
  80664. private generateHandPartsDefinition;
  80665. /**
  80666. * Construct a new hand object
  80667. * @param xrController the controller to which the hand correlates
  80668. * @param trackedMeshes the meshes to be used to track the hand joints
  80669. * @param _handMesh an optional hand mesh. if not provided, ours will be used
  80670. * @param _rigMapping an optional rig mapping for the hand mesh. if not provided, ours will be used
  80671. * @param disableDefaultHandMesh should the default mesh creation be disabled
  80672. * @param _nearInteractionMesh as optional mesh used for near interaction collision checking
  80673. * @param _leftHandedMeshes are the hand meshes left-handed-system meshes
  80674. */
  80675. constructor(
  80676. /** the controller to which the hand correlates */
  80677. xrController: WebXRInputSource,
  80678. /** the meshes to be used to track the hand joints */
  80679. trackedMeshes: AbstractMesh[], _handMesh?: AbstractMesh | undefined, _rigMapping?: string[] | undefined, disableDefaultHandMesh?: boolean, _nearInteractionMesh?: AbstractMesh | null | undefined, _leftHandedMeshes?: boolean | undefined);
  80680. /**
  80681. * Get the hand mesh. It is possible that the hand mesh is not yet ready!
  80682. */
  80683. get handMesh(): AbstractMesh | undefined;
  80684. /**
  80685. * Update this hand from the latest xr frame
  80686. * @param xrFrame xrFrame to update from
  80687. * @param referenceSpace The current viewer reference space
  80688. * @param scaleFactor optional scale factor for the meshes
  80689. */
  80690. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  80691. /**
  80692. * Get meshes of part of the hand
  80693. * @param part the part of hand to get
  80694. * @returns An array of meshes that correlate to the hand part requested
  80695. */
  80696. getHandPartMeshes(part: HandPart): AbstractMesh[];
  80697. /**
  80698. * Dispose this Hand object
  80699. */
  80700. dispose(): void;
  80701. private _generateDefaultHandMesh;
  80702. }
  80703. /**
  80704. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  80705. */
  80706. export class WebXRHandTracking extends WebXRAbstractFeature {
  80707. /**
  80708. * options to use when constructing this feature
  80709. */
  80710. readonly options: IWebXRHandTrackingOptions;
  80711. private static _idCounter;
  80712. /**
  80713. * The module's name
  80714. */
  80715. static readonly Name: string;
  80716. /**
  80717. * The (Babylon) version of this module.
  80718. * This is an integer representing the implementation version.
  80719. * This number does not correspond to the WebXR specs version
  80720. */
  80721. static readonly Version: number;
  80722. /**
  80723. * This observable will notify registered observers when a new hand object was added and initialized
  80724. */
  80725. onHandAddedObservable: Observable<WebXRHand>;
  80726. /**
  80727. * This observable will notify its observers right before the hand object is disposed
  80728. */
  80729. onHandRemovedObservable: Observable<WebXRHand>;
  80730. private _hands;
  80731. /**
  80732. * Creates a new instance of the hit test feature
  80733. * @param _xrSessionManager an instance of WebXRSessionManager
  80734. * @param options options to use when constructing this feature
  80735. */
  80736. constructor(_xrSessionManager: WebXRSessionManager,
  80737. /**
  80738. * options to use when constructing this feature
  80739. */
  80740. options: IWebXRHandTrackingOptions);
  80741. /**
  80742. * Check if the needed objects are defined.
  80743. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  80744. */
  80745. isCompatible(): boolean;
  80746. /**
  80747. * attach this feature
  80748. * Will usually be called by the features manager
  80749. *
  80750. * @returns true if successful.
  80751. */
  80752. attach(): boolean;
  80753. /**
  80754. * detach this feature.
  80755. * Will usually be called by the features manager
  80756. *
  80757. * @returns true if successful.
  80758. */
  80759. detach(): boolean;
  80760. /**
  80761. * Dispose this feature and all of the resources attached
  80762. */
  80763. dispose(): void;
  80764. /**
  80765. * Get the hand object according to the controller id
  80766. * @param controllerId the controller id to which we want to get the hand
  80767. * @returns null if not found or the WebXRHand object if found
  80768. */
  80769. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  80770. /**
  80771. * Get a hand object according to the requested handedness
  80772. * @param handedness the handedness to request
  80773. * @returns null if not found or the WebXRHand object if found
  80774. */
  80775. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  80776. protected _onXRFrame(_xrFrame: XRFrame): void;
  80777. private _attachHand;
  80778. private _detachHand;
  80779. }
  80780. }
  80781. declare module BABYLON {
  80782. /**
  80783. * Options used in the mesh detector module
  80784. */
  80785. export interface IWebXRMeshDetectorOptions {
  80786. /**
  80787. * The node to use to transform the local results to world coordinates
  80788. */
  80789. worldParentNode?: TransformNode;
  80790. /**
  80791. * If set to true a reference of the created meshes will be kept until the next session starts
  80792. * If not defined, meshes will be removed from the array when the feature is detached or the session ended.
  80793. */
  80794. doNotRemoveMeshesOnSessionEnded?: boolean;
  80795. /**
  80796. * Preferred detector configuration, not all preferred options will be supported by all platforms.
  80797. */
  80798. preferredDetectorOptions?: XRGeometryDetectorOptions;
  80799. /**
  80800. * If set to true, WebXRMeshDetector will convert coordinate systems for meshes.
  80801. * If not defined, mesh conversions from right handed to left handed coordinate systems won't be conducted.
  80802. * Right handed mesh data will be available through IWebXRVertexData.xrMesh.
  80803. */
  80804. convertCoordinateSystems?: boolean;
  80805. }
  80806. /**
  80807. * A babylon interface for a XR mesh's vertex data.
  80808. *
  80809. * Currently not supported by WebXR, available only with BabylonNative
  80810. */
  80811. export interface IWebXRVertexData {
  80812. /**
  80813. * A babylon-assigned ID for this mesh
  80814. */
  80815. id: number;
  80816. /**
  80817. * Data required for constructing a mesh in Babylon.js.
  80818. */
  80819. xrMesh: XRMesh;
  80820. /**
  80821. * The node to use to transform the local results to world coordinates.
  80822. * WorldParentNode will only exist if it was declared in the IWebXRMeshDetectorOptions.
  80823. */
  80824. worldParentNode?: TransformNode;
  80825. /**
  80826. * An array of vertex positions in babylon space. right/left hand system is taken into account.
  80827. * Positions will only be calculated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  80828. */
  80829. positions?: Float32Array;
  80830. /**
  80831. * An array of indices in babylon space. Indices have a counterclockwise winding order.
  80832. * Indices will only be populated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  80833. */
  80834. indices?: Uint32Array;
  80835. /**
  80836. * An array of vertex normals in babylon space. right/left hand system is taken into account.
  80837. * Normals will not be calculated if convertCoordinateSystems is undefined in the IWebXRMeshDetectorOptions.
  80838. * Different platforms may or may not support mesh normals when convertCoordinateSystems is set to true.
  80839. */
  80840. normals?: Float32Array;
  80841. /**
  80842. * A transformation matrix to apply on the mesh that will be built using the meshDefinition.
  80843. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module.
  80844. * TransformationMatrix will only be calculated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  80845. */
  80846. transformationMatrix?: Matrix;
  80847. }
  80848. /**
  80849. * The mesh detector is used to detect meshes in the real world when in AR
  80850. */
  80851. export class WebXRMeshDetector extends WebXRAbstractFeature {
  80852. private _options;
  80853. private _detectedMeshes;
  80854. /**
  80855. * The module's name
  80856. */
  80857. static readonly Name: string;
  80858. /**
  80859. * The (Babylon) version of this module.
  80860. * This is an integer representing the implementation version.
  80861. * This number does not correspond to the WebXR specs version
  80862. */
  80863. static readonly Version: number;
  80864. /**
  80865. * Observers registered here will be executed when a new mesh was added to the session
  80866. */
  80867. onMeshAddedObservable: Observable<IWebXRVertexData>;
  80868. /**
  80869. * Observers registered here will be executed when a mesh is no longer detected in the session
  80870. */
  80871. onMeshRemovedObservable: Observable<IWebXRVertexData>;
  80872. /**
  80873. * Observers registered here will be executed when an existing mesh updates
  80874. */
  80875. onMeshUpdatedObservable: Observable<IWebXRVertexData>;
  80876. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRMeshDetectorOptions);
  80877. detach(): boolean;
  80878. dispose(): void;
  80879. protected _onXRFrame(frame: XRFrame): void;
  80880. private _init;
  80881. private _updateVertexDataWithXRMesh;
  80882. }
  80883. }
  80884. declare module BABYLON {
  80885. /**
  80886. * Options interface for the background remover plugin
  80887. */
  80888. export interface IWebXRImageTrackingOptions {
  80889. /**
  80890. * A required array with images to track
  80891. */
  80892. images: {
  80893. /**
  80894. * The source of the image. can be a URL or an image bitmap
  80895. */
  80896. src: string | ImageBitmap;
  80897. /**
  80898. * The estimated width in the real world (in meters)
  80899. */
  80900. estimatedRealWorldWidth: number;
  80901. }[];
  80902. }
  80903. /**
  80904. * An object representing an image tracked by the system
  80905. */
  80906. export interface IWebXRTrackedImage {
  80907. /**
  80908. * The ID of this image (which is the same as the position in the array that was used to initialize the feature)
  80909. */
  80910. id: number;
  80911. /**
  80912. * Is the transformation provided emulated. If it is, the system "guesses" its real position. Otherwise it can be considered as exact position.
  80913. */
  80914. emulated?: boolean;
  80915. /**
  80916. * Just in case it is needed - the image bitmap that is being tracked
  80917. */
  80918. originalBitmap: ImageBitmap;
  80919. /**
  80920. * The native XR result image tracking result, untouched
  80921. */
  80922. xrTrackingResult?: XRImageTrackingResult;
  80923. /**
  80924. * Width in real world (meters)
  80925. */
  80926. realWorldWidth?: number;
  80927. /**
  80928. * A transformation matrix of this current image in the current reference space.
  80929. */
  80930. transformationMatrix: Matrix;
  80931. /**
  80932. * The width/height ratio of this image. can be used to calculate the size of the detected object/image
  80933. */
  80934. ratio?: number;
  80935. }
  80936. /**
  80937. * Image tracking for immersive AR sessions.
  80938. * Providing a list of images and their estimated widths will enable tracking those images in the real world.
  80939. */
  80940. export class WebXRImageTracking extends WebXRAbstractFeature {
  80941. /**
  80942. * read-only options to be used in this module
  80943. */
  80944. readonly options: IWebXRImageTrackingOptions;
  80945. /**
  80946. * The module's name
  80947. */
  80948. static readonly Name: string;
  80949. /**
  80950. * The (Babylon) version of this module.
  80951. * This is an integer representing the implementation version.
  80952. * This number does not correspond to the WebXR specs version
  80953. */
  80954. static readonly Version: number;
  80955. /**
  80956. * This will be triggered if the underlying system deems an image untrackable.
  80957. * The index is the index of the image from the array used to initialize the feature.
  80958. */
  80959. onUntrackableImageFoundObservable: Observable<number>;
  80960. /**
  80961. * An image was deemed trackable, and the system will start tracking it.
  80962. */
  80963. onTrackableImageFoundObservable: Observable<IWebXRTrackedImage>;
  80964. /**
  80965. * The image was found and its state was updated.
  80966. */
  80967. onTrackedImageUpdatedObservable: Observable<IWebXRTrackedImage>;
  80968. private _trackedImages;
  80969. private _originalTrackingRequest;
  80970. /**
  80971. * constructs the image tracking feature
  80972. * @param _xrSessionManager the session manager for this module
  80973. * @param options read-only options to be used in this module
  80974. */
  80975. constructor(_xrSessionManager: WebXRSessionManager,
  80976. /**
  80977. * read-only options to be used in this module
  80978. */
  80979. options: IWebXRImageTrackingOptions);
  80980. /**
  80981. * attach this feature
  80982. * Will usually be called by the features manager
  80983. *
  80984. * @returns true if successful.
  80985. */
  80986. attach(): boolean;
  80987. /**
  80988. * detach this feature.
  80989. * Will usually be called by the features manager
  80990. *
  80991. * @returns true if successful.
  80992. */
  80993. detach(): boolean;
  80994. /**
  80995. * Check if the needed objects are defined.
  80996. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  80997. */
  80998. isCompatible(): boolean;
  80999. /**
  81000. * Get a tracked image by its ID.
  81001. *
  81002. * @param id the id of the image to load (position in the init array)
  81003. * @returns a trackable image, if exists in this location
  81004. */
  81005. getTrackedImageById(id: number): Nullable<IWebXRTrackedImage>;
  81006. /**
  81007. * Dispose this feature and all of the resources attached
  81008. */
  81009. dispose(): void;
  81010. /**
  81011. * Extends the session init object if needed
  81012. * @returns augmentation object fo the xr session init object.
  81013. */
  81014. getXRSessionInitExtension(): Promise<Partial<XRSessionInit>>;
  81015. protected _onXRFrame(_xrFrame: XRFrame): void;
  81016. private _init;
  81017. }
  81018. }
  81019. declare module BABYLON {
  81020. /**
  81021. * The motion controller class for all microsoft mixed reality controllers
  81022. */
  81023. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  81024. protected readonly _mapping: {
  81025. defaultButton: {
  81026. valueNodeName: string;
  81027. unpressedNodeName: string;
  81028. pressedNodeName: string;
  81029. };
  81030. defaultAxis: {
  81031. valueNodeName: string;
  81032. minNodeName: string;
  81033. maxNodeName: string;
  81034. };
  81035. buttons: {
  81036. "xr-standard-trigger": {
  81037. rootNodeName: string;
  81038. componentProperty: string;
  81039. states: string[];
  81040. };
  81041. "xr-standard-squeeze": {
  81042. rootNodeName: string;
  81043. componentProperty: string;
  81044. states: string[];
  81045. };
  81046. "xr-standard-touchpad": {
  81047. rootNodeName: string;
  81048. labelAnchorNodeName: string;
  81049. touchPointNodeName: string;
  81050. };
  81051. "xr-standard-thumbstick": {
  81052. rootNodeName: string;
  81053. componentProperty: string;
  81054. states: string[];
  81055. };
  81056. };
  81057. axes: {
  81058. "xr-standard-touchpad": {
  81059. "x-axis": {
  81060. rootNodeName: string;
  81061. };
  81062. "y-axis": {
  81063. rootNodeName: string;
  81064. };
  81065. };
  81066. "xr-standard-thumbstick": {
  81067. "x-axis": {
  81068. rootNodeName: string;
  81069. };
  81070. "y-axis": {
  81071. rootNodeName: string;
  81072. };
  81073. };
  81074. };
  81075. };
  81076. /**
  81077. * The base url used to load the left and right controller models
  81078. */
  81079. static MODEL_BASE_URL: string;
  81080. /**
  81081. * The name of the left controller model file
  81082. */
  81083. static MODEL_LEFT_FILENAME: string;
  81084. /**
  81085. * The name of the right controller model file
  81086. */
  81087. static MODEL_RIGHT_FILENAME: string;
  81088. profileId: string;
  81089. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  81090. protected _getFilenameAndPath(): {
  81091. filename: string;
  81092. path: string;
  81093. };
  81094. protected _getModelLoadingConstraints(): boolean;
  81095. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  81096. protected _setRootMesh(meshes: AbstractMesh[]): void;
  81097. protected _updateModel(): void;
  81098. }
  81099. }
  81100. declare module BABYLON {
  81101. /**
  81102. * The motion controller class for oculus touch (quest, rift).
  81103. * This class supports legacy mapping as well the standard xr mapping
  81104. */
  81105. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  81106. private _forceLegacyControllers;
  81107. private _modelRootNode;
  81108. /**
  81109. * The base url used to load the left and right controller models
  81110. */
  81111. static MODEL_BASE_URL: string;
  81112. /**
  81113. * The name of the left controller model file
  81114. */
  81115. static MODEL_LEFT_FILENAME: string;
  81116. /**
  81117. * The name of the right controller model file
  81118. */
  81119. static MODEL_RIGHT_FILENAME: string;
  81120. /**
  81121. * Base Url for the Quest controller model.
  81122. */
  81123. static QUEST_MODEL_BASE_URL: string;
  81124. profileId: string;
  81125. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  81126. protected _getFilenameAndPath(): {
  81127. filename: string;
  81128. path: string;
  81129. };
  81130. protected _getModelLoadingConstraints(): boolean;
  81131. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  81132. protected _setRootMesh(meshes: AbstractMesh[]): void;
  81133. protected _updateModel(): void;
  81134. /**
  81135. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  81136. * between the touch and touch 2.
  81137. */
  81138. private _isQuest;
  81139. }
  81140. }
  81141. declare module BABYLON {
  81142. /**
  81143. * The motion controller class for the standard HTC-Vive controllers
  81144. */
  81145. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  81146. private _modelRootNode;
  81147. /**
  81148. * The base url used to load the left and right controller models
  81149. */
  81150. static MODEL_BASE_URL: string;
  81151. /**
  81152. * File name for the controller model.
  81153. */
  81154. static MODEL_FILENAME: string;
  81155. profileId: string;
  81156. /**
  81157. * Create a new Vive motion controller object
  81158. * @param scene the scene to use to create this controller
  81159. * @param gamepadObject the corresponding gamepad object
  81160. * @param handedness the handedness of the controller
  81161. */
  81162. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  81163. protected _getFilenameAndPath(): {
  81164. filename: string;
  81165. path: string;
  81166. };
  81167. protected _getModelLoadingConstraints(): boolean;
  81168. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  81169. protected _setRootMesh(meshes: AbstractMesh[]): void;
  81170. protected _updateModel(): void;
  81171. }
  81172. }
  81173. declare module BABYLON {
  81174. /** @hidden */
  81175. export class WebGPUCacheRenderPipelineString extends WebGPUCacheRenderPipeline {
  81176. private static _Cache;
  81177. protected _getRenderPipeline(param: {
  81178. token: any;
  81179. pipeline: Nullable<GPURenderPipeline>;
  81180. }): void;
  81181. protected _setRenderPipeline(param: {
  81182. token: any;
  81183. pipeline: Nullable<GPURenderPipeline>;
  81184. }): void;
  81185. }
  81186. }
  81187. declare module BABYLON {
  81188. /** @hidden */
  81189. export var blurPixelShader: {
  81190. name: string;
  81191. shader: string;
  81192. };
  81193. }
  81194. declare module BABYLON {
  81195. /** @hidden */
  81196. export var pointCloudVertexDeclaration: {
  81197. name: string;
  81198. shader: string;
  81199. };
  81200. }
  81201. // Mixins
  81202. interface Window {
  81203. mozIndexedDB: IDBFactory;
  81204. webkitIndexedDB: IDBFactory;
  81205. msIndexedDB: IDBFactory;
  81206. webkitURL: typeof URL;
  81207. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  81208. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  81209. WebGLRenderingContext: WebGLRenderingContext;
  81210. MSGesture: MSGesture;
  81211. CANNON: any;
  81212. AudioContext: AudioContext;
  81213. webkitAudioContext: AudioContext;
  81214. PointerEvent: any;
  81215. Math: Math;
  81216. Uint8Array: Uint8ArrayConstructor;
  81217. Float32Array: Float32ArrayConstructor;
  81218. mozURL: typeof URL;
  81219. msURL: typeof URL;
  81220. VRFrameData: any; // WebVR, from specs 1.1
  81221. DracoDecoderModule: any;
  81222. setImmediate(handler: (...args: any[]) => void): number;
  81223. }
  81224. interface HTMLCanvasElement {
  81225. requestPointerLock(): void;
  81226. msRequestPointerLock?(): void;
  81227. mozRequestPointerLock?(): void;
  81228. webkitRequestPointerLock?(): void;
  81229. /** Track whether a record is in progress */
  81230. isRecording: boolean;
  81231. /** Capture Stream method defined by some browsers */
  81232. captureStream(fps?: number): MediaStream;
  81233. }
  81234. interface CanvasRenderingContext2D {
  81235. msImageSmoothingEnabled: boolean;
  81236. }
  81237. interface MouseEvent {
  81238. mozMovementX: number;
  81239. mozMovementY: number;
  81240. webkitMovementX: number;
  81241. webkitMovementY: number;
  81242. msMovementX: number;
  81243. msMovementY: number;
  81244. }
  81245. interface Navigator {
  81246. mozGetVRDevices: (any: any) => any;
  81247. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  81248. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  81249. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  81250. webkitGetGamepads(): Gamepad[];
  81251. msGetGamepads(): Gamepad[];
  81252. webkitGamepads(): Gamepad[];
  81253. }
  81254. interface HTMLVideoElement {
  81255. mozSrcObject: any;
  81256. }
  81257. interface Math {
  81258. fround(x: number): number;
  81259. imul(a: number, b: number): number;
  81260. log2(x: number): number;
  81261. }
  81262. interface WebGLRenderingContext {
  81263. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  81264. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  81265. vertexAttribDivisor(index: number, divisor: number): void;
  81266. createVertexArray(): any;
  81267. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  81268. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  81269. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  81270. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  81271. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  81272. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  81273. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  81274. // Queries
  81275. createQuery(): WebGLQuery;
  81276. deleteQuery(query: WebGLQuery): void;
  81277. beginQuery(target: number, query: WebGLQuery): void;
  81278. endQuery(target: number): void;
  81279. getQueryParameter(query: WebGLQuery, pname: number): any;
  81280. getQuery(target: number, pname: number): any;
  81281. MAX_SAMPLES: number;
  81282. RGBA8: number;
  81283. READ_FRAMEBUFFER: number;
  81284. DRAW_FRAMEBUFFER: number;
  81285. UNIFORM_BUFFER: number;
  81286. HALF_FLOAT_OES: number;
  81287. RGBA16F: number;
  81288. RGBA32F: number;
  81289. R32F: number;
  81290. RG32F: number;
  81291. RGB32F: number;
  81292. R16F: number;
  81293. RG16F: number;
  81294. RGB16F: number;
  81295. RED: number;
  81296. RG: number;
  81297. R8: number;
  81298. RG8: number;
  81299. UNSIGNED_INT_24_8: number;
  81300. DEPTH24_STENCIL8: number;
  81301. MIN: number;
  81302. MAX: number;
  81303. /* Multiple Render Targets */
  81304. drawBuffers(buffers: number[]): void;
  81305. readBuffer(src: number): void;
  81306. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  81307. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  81308. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  81309. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  81310. // Occlusion Query
  81311. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  81312. ANY_SAMPLES_PASSED: number;
  81313. QUERY_RESULT_AVAILABLE: number;
  81314. QUERY_RESULT: number;
  81315. }
  81316. interface WebGLProgram {
  81317. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  81318. }
  81319. interface EXT_disjoint_timer_query {
  81320. QUERY_COUNTER_BITS_EXT: number;
  81321. TIME_ELAPSED_EXT: number;
  81322. TIMESTAMP_EXT: number;
  81323. GPU_DISJOINT_EXT: number;
  81324. QUERY_RESULT_EXT: number;
  81325. QUERY_RESULT_AVAILABLE_EXT: number;
  81326. queryCounterEXT(query: WebGLQuery, target: number): void;
  81327. createQueryEXT(): WebGLQuery;
  81328. beginQueryEXT(target: number, query: WebGLQuery): void;
  81329. endQueryEXT(target: number): void;
  81330. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  81331. deleteQueryEXT(query: WebGLQuery): void;
  81332. }
  81333. interface WebGLUniformLocation {
  81334. _currentState: any;
  81335. }
  81336. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  81337. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  81338. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  81339. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  81340. interface WebGLRenderingContext {
  81341. readonly RASTERIZER_DISCARD: number;
  81342. readonly DEPTH_COMPONENT24: number;
  81343. readonly TEXTURE_3D: number;
  81344. readonly TEXTURE_2D_ARRAY: number;
  81345. readonly TEXTURE_COMPARE_FUNC: number;
  81346. readonly TEXTURE_COMPARE_MODE: number;
  81347. readonly COMPARE_REF_TO_TEXTURE: number;
  81348. readonly TEXTURE_WRAP_R: number;
  81349. readonly HALF_FLOAT: number;
  81350. readonly RGB8: number;
  81351. readonly RED_INTEGER: number;
  81352. readonly RG_INTEGER: number;
  81353. readonly RGB_INTEGER: number;
  81354. readonly RGBA_INTEGER: number;
  81355. readonly R8_SNORM: number;
  81356. readonly RG8_SNORM: number;
  81357. readonly RGB8_SNORM: number;
  81358. readonly RGBA8_SNORM: number;
  81359. readonly R8I: number;
  81360. readonly RG8I: number;
  81361. readonly RGB8I: number;
  81362. readonly RGBA8I: number;
  81363. readonly R8UI: number;
  81364. readonly RG8UI: number;
  81365. readonly RGB8UI: number;
  81366. readonly RGBA8UI: number;
  81367. readonly R16I: number;
  81368. readonly RG16I: number;
  81369. readonly RGB16I: number;
  81370. readonly RGBA16I: number;
  81371. readonly R16UI: number;
  81372. readonly RG16UI: number;
  81373. readonly RGB16UI: number;
  81374. readonly RGBA16UI: number;
  81375. readonly R32I: number;
  81376. readonly RG32I: number;
  81377. readonly RGB32I: number;
  81378. readonly RGBA32I: number;
  81379. readonly R32UI: number;
  81380. readonly RG32UI: number;
  81381. readonly RGB32UI: number;
  81382. readonly RGBA32UI: number;
  81383. readonly RGB10_A2UI: number;
  81384. readonly R11F_G11F_B10F: number;
  81385. readonly RGB9_E5: number;
  81386. readonly RGB10_A2: number;
  81387. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  81388. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  81389. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  81390. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  81391. readonly DEPTH_COMPONENT32F: number;
  81392. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  81393. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  81394. 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;
  81395. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  81396. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  81397. readonly TRANSFORM_FEEDBACK: number;
  81398. readonly INTERLEAVED_ATTRIBS: number;
  81399. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  81400. createTransformFeedback(): WebGLTransformFeedback;
  81401. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  81402. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  81403. beginTransformFeedback(primitiveMode: number): void;
  81404. endTransformFeedback(): void;
  81405. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  81406. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  81407. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  81408. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  81409. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  81410. }
  81411. interface ImageBitmap {
  81412. readonly width: number;
  81413. readonly height: number;
  81414. close(): void;
  81415. }
  81416. interface WebGLQuery extends WebGLObject {
  81417. }
  81418. declare var WebGLQuery: {
  81419. prototype: WebGLQuery;
  81420. new(): WebGLQuery;
  81421. };
  81422. interface WebGLSampler extends WebGLObject {
  81423. }
  81424. declare var WebGLSampler: {
  81425. prototype: WebGLSampler;
  81426. new(): WebGLSampler;
  81427. };
  81428. interface WebGLSync extends WebGLObject {
  81429. }
  81430. declare var WebGLSync: {
  81431. prototype: WebGLSync;
  81432. new(): WebGLSync;
  81433. };
  81434. interface WebGLTransformFeedback extends WebGLObject {
  81435. }
  81436. declare var WebGLTransformFeedback: {
  81437. prototype: WebGLTransformFeedback;
  81438. new(): WebGLTransformFeedback;
  81439. };
  81440. interface WebGLVertexArrayObject extends WebGLObject {
  81441. }
  81442. declare var WebGLVertexArrayObject: {
  81443. prototype: WebGLVertexArrayObject;
  81444. new(): WebGLVertexArrayObject;
  81445. };
  81446. interface Navigator {
  81447. readonly gpu: GPU | undefined;
  81448. }
  81449. interface GPUColorDict {
  81450. a: number;
  81451. b: number;
  81452. g: number;
  81453. r: number;
  81454. }
  81455. type GPUColor = [number, number, number, number] | GPUColorDict;
  81456. interface GPUOrigin2DDict {
  81457. x?: number;
  81458. y?: number;
  81459. }
  81460. type GPUOrigin2D = [number, number] | GPUOrigin2DDict;
  81461. interface GPUOrigin3DDict {
  81462. x?: number;
  81463. y?: number;
  81464. z?: number;
  81465. }
  81466. type GPUOrigin3D = [number, number, number] | GPUOrigin3DDict;
  81467. interface GPUExtent3DDict {
  81468. width: number;
  81469. height: number;
  81470. depth: number;
  81471. }
  81472. type GPUExtent3D = [number, number, number] | GPUExtent3DDict;
  81473. type GPUBindingResource =
  81474. | GPUSampler
  81475. | GPUTextureView
  81476. | GPUBufferBinding;
  81477. type GPUExtensionName =
  81478. | "texture-compression-bc"
  81479. | "timestamp-query"
  81480. | "pipeline-statistics-query"
  81481. | "depth-clamping"
  81482. | "depth24unorm-stencil8"
  81483. | "depth32float-stencil8";
  81484. type GPUAddressMode = "clamp-to-edge" | "repeat" | "mirror-repeat";
  81485. type GPUBindingType =
  81486. | "uniform-buffer"
  81487. | "storage-buffer"
  81488. | "readonly-storage-buffer"
  81489. | "sampler"
  81490. | "comparison-sampler"
  81491. | "sampled-texture"
  81492. | "readonly-storage-texture"
  81493. | "writeonly-storage-texture";
  81494. type GPUBlendFactor =
  81495. | "zero"
  81496. | "one"
  81497. | "src-color"
  81498. | "one-minus-src-color"
  81499. | "src-alpha"
  81500. | "one-minus-src-alpha"
  81501. | "dst-color"
  81502. | "one-minus-dst-color"
  81503. | "dst-alpha"
  81504. | "one-minus-dst-alpha"
  81505. | "src-alpha-saturated"
  81506. | "blend-color"
  81507. | "one-minus-blend-color";
  81508. type GPUBlendOperation =
  81509. | "add"
  81510. | "subtract"
  81511. | "reverse-subtract"
  81512. | "min"
  81513. | "max";
  81514. type GPUCompareFunction =
  81515. | "never"
  81516. | "less"
  81517. | "equal"
  81518. | "less-equal"
  81519. | "greater"
  81520. | "not-equal"
  81521. | "greater-equal"
  81522. | "always";
  81523. type GPUCullMode = "none" | "front" | "back";
  81524. type GPUFilterMode = "nearest" | "linear";
  81525. type GPUFrontFace = "ccw" | "cw";
  81526. type GPUIndexFormat = "uint16" | "uint32";
  81527. type GPUInputStepMode = "vertex" | "instance";
  81528. type GPULoadOp = "load";
  81529. type GPUPrimitiveTopology =
  81530. | "point-list"
  81531. | "line-list"
  81532. | "line-strip"
  81533. | "triangle-list"
  81534. | "triangle-strip";
  81535. type GPUStencilOperation =
  81536. | "keep"
  81537. | "zero"
  81538. | "replace"
  81539. | "invert"
  81540. | "increment-clamp"
  81541. | "decrement-clamp"
  81542. | "increment-wrap"
  81543. | "decrement-wrap";
  81544. type GPUStoreOp = "store" | "clear";
  81545. type GPUTextureDimension = "1d" | "2d" | "3d";
  81546. type GPUTextureFormat =
  81547. | "r8unorm"
  81548. | "r8snorm"
  81549. | "r8uint"
  81550. | "r8sint"
  81551. | "r16uint"
  81552. | "r16sint"
  81553. | "r16float"
  81554. | "rg8unorm"
  81555. | "rg8snorm"
  81556. | "rg8uint"
  81557. | "rg8sint"
  81558. | "r32uint"
  81559. | "r32sint"
  81560. | "r32float"
  81561. | "rg16uint"
  81562. | "rg16sint"
  81563. | "rg16float"
  81564. | "rgba8unorm"
  81565. | "rgba8unorm-srgb"
  81566. | "rgba8snorm"
  81567. | "rgba8uint"
  81568. | "rgba8sint"
  81569. | "bgra8unorm"
  81570. | "bgra8unorm-srgb"
  81571. | "rgb9e5ufloat"
  81572. | "rgb10a2unorm"
  81573. | "rg11b10ufloat"
  81574. | "rg32uint"
  81575. | "rg32sint"
  81576. | "rg32float"
  81577. | "rgba16uint"
  81578. | "rgba16sint"
  81579. | "rgba16float"
  81580. | "rgba32uint"
  81581. | "rgba32sint"
  81582. | "rgba32float"
  81583. | "stencil8"
  81584. | "depth16unorm"
  81585. | "depth24plus"
  81586. | "depth24plus-stencil8"
  81587. | "depth32float"
  81588. | "bc1-rgba-unorm"
  81589. | "bc1-rgba-unorm-srgb"
  81590. | "bc2-rgba-unorm"
  81591. | "bc2-rgba-unorm-srgb"
  81592. | "bc3-rgba-unorm"
  81593. | "bc3-rgba-unorm-srgb"
  81594. | "bc4-r-unorm"
  81595. | "bc4-r-snorm"
  81596. | "bc5-rg-unorm"
  81597. | "bc5-rg-snorm"
  81598. | "bc6h-rgb-ufloat"
  81599. | "bc6h-rgb-float"
  81600. | "bc7-rgba-unorm"
  81601. | "bc7-rgba-unorm-srgb"
  81602. | "depth24unorm-stencil8"
  81603. | "depth32float-stencil8";
  81604. type GPUTextureComponentType = "float" | "sint" | "uint" | "depth-comparison";
  81605. type GPUTextureViewDimension =
  81606. | "1d"
  81607. | "2d"
  81608. | "2d-array"
  81609. | "cube"
  81610. | "cube-array"
  81611. | "3d";
  81612. type GPUVertexFormat =
  81613. | "uchar2"
  81614. | "uchar4"
  81615. | "char2"
  81616. | "char4"
  81617. | "uchar2norm"
  81618. | "uchar4norm"
  81619. | "char2norm"
  81620. | "char4norm"
  81621. | "ushort2"
  81622. | "ushort4"
  81623. | "short2"
  81624. | "short4"
  81625. | "ushort2norm"
  81626. | "ushort4norm"
  81627. | "short2norm"
  81628. | "short4norm"
  81629. | "half2"
  81630. | "half4"
  81631. | "float"
  81632. | "float2"
  81633. | "float3"
  81634. | "float4"
  81635. | "uint"
  81636. | "uint2"
  81637. | "uint3"
  81638. | "uint4"
  81639. | "int"
  81640. | "int2"
  81641. | "int3"
  81642. | "int4";
  81643. type GPUTextureAspect = "all" | "stencil-only" | "depth-only";
  81644. type GPUBufferUsageFlags = number;
  81645. type GPUColorWriteFlags = number;
  81646. type GPUShaderStageFlags = number;
  81647. type GPUTextureUsageFlags = number;
  81648. type GPUMapModeFlags = number;
  81649. interface GPUBindGroupEntry {
  81650. binding: number;
  81651. resource: GPUBindingResource;
  81652. }
  81653. interface GPUBindGroupDescriptor extends GPUObjectDescriptorBase {
  81654. layout: GPUBindGroupLayout;
  81655. entries: Iterable<GPUBindGroupEntry>;
  81656. }
  81657. interface GPUBindGroupLayoutEntry {
  81658. binding: number;
  81659. visibility: GPUShaderStageFlags;
  81660. type: GPUBindingType;
  81661. hasDynamicOffset?: boolean;
  81662. minBufferBindingSize?: number;
  81663. viewDimension?: GPUTextureViewDimension;
  81664. textureComponentType?: GPUTextureComponentType;
  81665. storageTextureFormat?: GPUTextureFormat;
  81666. }
  81667. interface GPUBindGroupLayoutDescriptor
  81668. extends GPUObjectDescriptorBase {
  81669. entries: Iterable<GPUBindGroupLayoutEntry>;
  81670. }
  81671. interface GPUBlendDescriptor {
  81672. dstFactor?: GPUBlendFactor;
  81673. operation?: GPUBlendOperation;
  81674. srcFactor?: GPUBlendFactor;
  81675. }
  81676. interface GPUColorStateDescriptor {
  81677. format: GPUTextureFormat;
  81678. alphaBlend?: GPUBlendDescriptor;
  81679. colorBlend?: GPUBlendDescriptor;
  81680. writeMask?: GPUColorWriteFlags;
  81681. }
  81682. interface GPUBufferBinding {
  81683. buffer: GPUBuffer;
  81684. offset?: number;
  81685. size?: number;
  81686. }
  81687. interface GPUTextureDataLayout {
  81688. offset?: number;
  81689. bytesPerRow: number;
  81690. rowsPerImage?: number;
  81691. }
  81692. interface GPUBufferCopyView extends GPUTextureDataLayout {
  81693. buffer: GPUBuffer;
  81694. }
  81695. interface GPUTextureCopyView {
  81696. texture: GPUTexture;
  81697. mipLevel?: number;
  81698. origin?: GPUOrigin3D;
  81699. }
  81700. interface GPUImageBitmapCopyView {
  81701. imageBitmap: ImageBitmap;
  81702. origin?: GPUOrigin2D;
  81703. }
  81704. interface GPUBufferDescriptor extends GPUObjectDescriptorBase {
  81705. size: number;
  81706. usage: GPUBufferUsageFlags;
  81707. mappedAtCreation?: boolean;
  81708. }
  81709. interface GPUCommandEncoderDescriptor extends GPUObjectDescriptorBase {
  81710. label?: string;
  81711. measureExecutionTime?: boolean;
  81712. }
  81713. interface GPUComputePipelineDescriptor
  81714. extends GPUPipelineDescriptorBase {
  81715. computeStage: GPUProgrammableStageDescriptor;
  81716. }
  81717. interface GPUDepthStencilStateDescriptor {
  81718. format: GPUTextureFormat;
  81719. depthWriteEnabled?: boolean;
  81720. depthCompare?: GPUCompareFunction;
  81721. stencilFront?: GPUStencilStateFaceDescriptor;
  81722. stencilBack?: GPUStencilStateFaceDescriptor;
  81723. stencilReadMask?: number;
  81724. stencilWriteMask?: number;
  81725. }
  81726. interface GPUDeviceDescriptor extends GPUObjectDescriptorBase {
  81727. extensions?: Iterable<GPUExtensionName>;
  81728. limits?: GPULimits;
  81729. }
  81730. interface GPUFenceDescriptor extends GPUObjectDescriptorBase {
  81731. initialValue?: number;
  81732. label?: string;
  81733. signalQueue?: GPUQueue;
  81734. }
  81735. interface GPUVertexAttributeDescriptor {
  81736. format: GPUVertexFormat;
  81737. offset: number;
  81738. shaderLocation: number;
  81739. }
  81740. interface GPUVertexBufferLayoutDescriptor {
  81741. arrayStride: number;
  81742. stepMode?: GPUInputStepMode;
  81743. attributes: Iterable<GPUVertexAttributeDescriptor>;
  81744. }
  81745. interface GPUVertexStateDescriptor {
  81746. indexFormat?: GPUIndexFormat;
  81747. vertexBuffers?: Iterable<GPUVertexBufferLayoutDescriptor>;
  81748. }
  81749. interface GPULimits {
  81750. maxBindGroups?: number;
  81751. maxDynamicUniformBuffersPerPipelineLayout?: number;
  81752. maxDynamicStorageBuffersPerPipelineLayout?: number;
  81753. maxSampledTexturesPerShaderStage?: number;
  81754. maxSamplersPerShaderStage?: number;
  81755. maxStorageBuffersPerShaderStage?: number;
  81756. maxStorageTexturesPerShaderStage?: number;
  81757. maxUniformBuffersPerShaderStage?: number;
  81758. maxUniformBufferBindingSize?: number;
  81759. }
  81760. interface GPUPipelineDescriptorBase {
  81761. label?: string;
  81762. layout?: GPUPipelineLayout;
  81763. }
  81764. interface GPUPipelineLayoutDescriptor extends GPUObjectDescriptorBase {
  81765. bindGroupLayouts: Iterable<GPUBindGroupLayout>;
  81766. }
  81767. interface GPUProgrammableStageDescriptor {
  81768. module: GPUShaderModule;
  81769. entryPoint: string;
  81770. }
  81771. interface GPURasterizationStateDescriptor {
  81772. frontFace?: GPUFrontFace;
  81773. cullMode?: GPUCullMode;
  81774. clampDepth?: boolean;
  81775. depthBias?: number;
  81776. depthBiasSlopeScale?: number;
  81777. depthBiasClamp?: number;
  81778. }
  81779. interface GPURenderPassColorAttachmentDescriptor {
  81780. attachment: GPUTextureView;
  81781. resolveTarget?: GPUTextureView;
  81782. loadValue: GPULoadOp | GPUColor;
  81783. storeOp?: GPUStoreOp;
  81784. }
  81785. interface GPURenderPassDepthStencilAttachmentDescriptor {
  81786. attachment: GPUTextureView;
  81787. depthLoadValue: GPULoadOp | number;
  81788. depthStoreOp: GPUStoreOp;
  81789. depthReadOnly?: boolean;
  81790. stencilLoadValue: GPULoadOp | number;
  81791. stencilStoreOp: GPUStoreOp;
  81792. stencilReadOnly?: boolean;
  81793. }
  81794. interface GPURenderPassDescriptor extends GPUObjectDescriptorBase {
  81795. colorAttachments: Iterable<GPURenderPassColorAttachmentDescriptor>;
  81796. depthStencilAttachment?: GPURenderPassDepthStencilAttachmentDescriptor;
  81797. }
  81798. interface GPURenderPipelineDescriptor
  81799. extends GPUPipelineDescriptorBase {
  81800. vertexStage: GPUProgrammableStageDescriptor;
  81801. fragmentStage?: GPUProgrammableStageDescriptor;
  81802. primitiveTopology: GPUPrimitiveTopology;
  81803. rasterizationState?: GPURasterizationStateDescriptor;
  81804. colorStates: Iterable<GPUColorStateDescriptor>;
  81805. depthStencilState?: GPUDepthStencilStateDescriptor;
  81806. vertexState?: GPUVertexStateDescriptor;
  81807. sampleCount?: number;
  81808. sampleMask?: number;
  81809. alphaToCoverageEnabled?: boolean;
  81810. }
  81811. interface GPUSamplerDescriptor extends GPUObjectDescriptorBase {
  81812. addressModeU?: GPUAddressMode;
  81813. addressModeV?: GPUAddressMode;
  81814. addressModeW?: GPUAddressMode;
  81815. magFilter?: GPUFilterMode;
  81816. minFilter?: GPUFilterMode;
  81817. mipmapFilter?: GPUFilterMode;
  81818. lodMinClamp?: number;
  81819. lodMaxClamp?: number;
  81820. compare?: GPUCompareFunction;
  81821. maxAnisotropy?: number;
  81822. }
  81823. interface GPUShaderModuleDescriptor extends GPUObjectDescriptorBase {
  81824. code: Uint32Array | string;
  81825. label?: string;
  81826. sourceMap?: object;
  81827. }
  81828. interface GPUStencilStateFaceDescriptor {
  81829. compare?: GPUCompareFunction;
  81830. depthFailOp?: GPUStencilOperation;
  81831. passOp?: GPUStencilOperation;
  81832. failOp?: GPUStencilOperation;
  81833. }
  81834. interface GPUSwapChainDescriptor extends GPUObjectDescriptorBase {
  81835. device: GPUDevice;
  81836. format: GPUTextureFormat;
  81837. usage?: GPUTextureUsageFlags;
  81838. }
  81839. interface GPUTextureDescriptor extends GPUObjectDescriptorBase {
  81840. size: GPUExtent3D;
  81841. mipLevelCount?: number;
  81842. sampleCount?: number;
  81843. dimension?: GPUTextureDimension;
  81844. format: GPUTextureFormat;
  81845. usage: GPUTextureUsageFlags;
  81846. }
  81847. interface GPUTextureViewDescriptor extends GPUObjectDescriptorBase {
  81848. format?: GPUTextureFormat;
  81849. dimension?: GPUTextureViewDimension;
  81850. aspect?: GPUTextureAspect;
  81851. baseArrayLayer?: number;
  81852. baseMipLevel?: number;
  81853. arrayLayerCount?: number;
  81854. mipLevelCount?: number;
  81855. }
  81856. declare class GPUAdapter {
  81857. // https://michalzalecki.com/nominal-typing-in-typescript/#approach-1-class-with-a-private-property
  81858. private __brand: void;
  81859. readonly name: string;
  81860. readonly extensions: GPUExtensionName[];
  81861. readonly limits: Required<GPULimits>;
  81862. requestDevice(descriptor?: GPUDeviceDescriptor): Promise<GPUDevice | null>;
  81863. }
  81864. declare class GPUBindGroup implements GPUObjectBase {
  81865. private __brand: void;
  81866. label: string | undefined;
  81867. }
  81868. declare class GPUBindGroupLayout implements GPUObjectBase {
  81869. private __brand: void;
  81870. label: string | undefined;
  81871. }
  81872. declare class GPUBuffer implements GPUObjectBase {
  81873. private __brand: void;
  81874. label: string | undefined;
  81875. destroy(): void;
  81876. unmap(): void;
  81877. mapAsync(mode: GPUMapModeFlags, offset?: number, size?: number): Promise<void>;
  81878. getMappedRange(offset?: number, size?: number): ArrayBuffer;
  81879. }
  81880. declare class GPUCommandBuffer implements GPUObjectBase {
  81881. private __brand: void;
  81882. label: string | undefined;
  81883. readonly executionTime: Promise<number>;
  81884. }
  81885. interface GPUCommandBufferDescriptor extends GPUObjectDescriptorBase { }
  81886. declare class GPUCommandEncoder implements GPUObjectBase {
  81887. private __brand: void;
  81888. label: string | undefined;
  81889. beginComputePass(
  81890. descriptor?: GPUComputePassDescriptor
  81891. ): GPUComputePassEncoder;
  81892. beginRenderPass(descriptor: GPURenderPassDescriptor): GPURenderPassEncoder;
  81893. copyBufferToBuffer(
  81894. source: GPUBuffer,
  81895. sourceOffset: number,
  81896. destination: GPUBuffer,
  81897. destinationOffset: number,
  81898. size: number
  81899. ): void;
  81900. copyBufferToTexture(
  81901. source: GPUBufferCopyView,
  81902. destination: GPUTextureCopyView,
  81903. copySize: GPUExtent3D
  81904. ): void;
  81905. copyTextureToBuffer(
  81906. source: GPUTextureCopyView,
  81907. destination: GPUBufferCopyView,
  81908. copySize: GPUExtent3D
  81909. ): void;
  81910. copyTextureToTexture(
  81911. source: GPUTextureCopyView,
  81912. destination: GPUTextureCopyView,
  81913. copySize: GPUExtent3D
  81914. ): void;
  81915. finish(descriptor?: GPUCommandBufferDescriptor): GPUCommandBuffer;
  81916. writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;
  81917. popDebugGroup(): void;
  81918. pushDebugGroup(groupLabel: string): void;
  81919. insertDebugMarker(markerLabel: string): void;
  81920. }
  81921. interface GPUComputePassDescriptor extends GPUObjectDescriptorBase { }
  81922. declare class GPUComputePassEncoder implements GPUObjectBase, GPUProgrammablePassEncoder {
  81923. private __brand: void;
  81924. label: string | undefined;
  81925. setBindGroup(
  81926. index: number,
  81927. bindGroup: GPUBindGroup,
  81928. dynamicOffsets?: Iterable<number>
  81929. ): void;
  81930. popDebugGroup(): void;
  81931. pushDebugGroup(groupLabel: string): void;
  81932. insertDebugMarker(markerLabel: string): void;
  81933. setPipeline(pipeline: GPUComputePipeline): void;
  81934. dispatch(x: number, y?: number, z?: number): void;
  81935. dispatchIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  81936. writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;
  81937. beginPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  81938. endPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  81939. endPass(): void;
  81940. }
  81941. declare class GPUComputePipeline implements GPUPipelineBase {
  81942. private __brand: void;
  81943. label: string | undefined;
  81944. getBindGroupLayout(index: number): GPUBindGroupLayout;
  81945. }
  81946. interface GPUObjectBase {
  81947. label: string | undefined;
  81948. }
  81949. interface GPUObjectDescriptorBase {
  81950. label?: string;
  81951. }
  81952. // SwapChain / CanvasContext
  81953. declare class GPUCanvasContext {
  81954. private __brand: void;
  81955. configureSwapChain(descriptor: GPUSwapChainDescriptor): GPUSwapChain;
  81956. getSwapChainPreferredFormat(device: GPUDevice): Promise<GPUTextureFormat>;
  81957. }
  81958. declare class GPUDevice extends EventTarget implements GPUObjectBase {
  81959. private __brand: void;
  81960. label: string | undefined;
  81961. readonly adapter: GPUAdapter;
  81962. readonly extensions: GPUExtensionName[];
  81963. readonly limits: Required<GPULimits>;
  81964. createBindGroup(descriptor: GPUBindGroupDescriptor): GPUBindGroup;
  81965. createBindGroupLayout(
  81966. descriptor: GPUBindGroupLayoutDescriptor
  81967. ): GPUBindGroupLayout;
  81968. createBuffer(descriptor: GPUBufferDescriptor): GPUBuffer;
  81969. createPipelineLayout(
  81970. descriptor: GPUPipelineLayoutDescriptor
  81971. ): GPUPipelineLayout;
  81972. createSampler(descriptor?: GPUSamplerDescriptor): GPUSampler;
  81973. createShaderModule(descriptor: GPUShaderModuleDescriptor): GPUShaderModule;
  81974. createTexture(descriptor: GPUTextureDescriptor): GPUTexture;
  81975. createComputePipeline(
  81976. descriptor: GPUComputePipelineDescriptor
  81977. ): GPUComputePipeline;
  81978. createRenderPipeline(
  81979. descriptor: GPURenderPipelineDescriptor
  81980. ): GPURenderPipeline;
  81981. createReadyComputePipeline(
  81982. descriptor: GPUComputePipelineDescriptor
  81983. ): Promise<GPUComputePipeline>;
  81984. createReadyRenderPipeline(
  81985. descriptor: GPURenderPipelineDescriptor
  81986. ): Promise<GPURenderPipeline>;
  81987. createCommandEncoder(
  81988. descriptor?: GPUCommandEncoderDescriptor
  81989. ): GPUCommandEncoder;
  81990. createRenderBundleEncoder(
  81991. descriptor: GPURenderBundleEncoderDescriptor
  81992. ): GPURenderBundleEncoder;
  81993. createQuerySet(descriptor: GPUQuerySetDescriptor): GPUQuerySet;
  81994. defaultQueue: GPUQueue;
  81995. pushErrorScope(filter: GPUErrorFilter): void;
  81996. popErrorScope(): Promise<GPUError | null>;
  81997. onuncapturederror: Event | undefined;
  81998. readonly lost: Promise<GPUDeviceLostInfo>;
  81999. }
  82000. declare class GPUFence implements GPUObjectBase {
  82001. private __brand: void;
  82002. label: string | undefined;
  82003. getCompletedValue(): number;
  82004. onCompletion(completionValue: number): Promise<void>;
  82005. }
  82006. interface GPUPipelineBase extends GPUObjectBase {
  82007. getBindGroupLayout(index: number): GPUBindGroupLayout;
  82008. }
  82009. declare class GPUPipelineLayout implements GPUObjectBase {
  82010. private __brand: void;
  82011. label: string | undefined;
  82012. }
  82013. interface GPUProgrammablePassEncoder {
  82014. setBindGroup(
  82015. index: number,
  82016. bindGroup: GPUBindGroup,
  82017. dynamicOffsets?: Iterable<number>
  82018. ): void;
  82019. popDebugGroup(): void;
  82020. pushDebugGroup(groupLabel: string): void;
  82021. insertDebugMarker(markerLabel: string): void;
  82022. }
  82023. declare class GPUQueue implements GPUObjectBase {
  82024. private __brand: void;
  82025. label: string | undefined;
  82026. signal(fence: GPUFence, signalValue: number): void;
  82027. submit(commandBuffers: Iterable<GPUCommandBuffer>): void;
  82028. createFence(descriptor?: GPUFenceDescriptor): GPUFence;
  82029. writeBuffer(buffer: GPUBuffer,
  82030. bufferOffset: number,
  82031. data: BufferSource | ArrayBuffer,
  82032. dataOffset?: number,
  82033. size?: number): void;
  82034. writeTexture(destination: GPUTextureCopyView,
  82035. data: BufferSource | ArrayBuffer,
  82036. dataLayout: GPUTextureDataLayout,
  82037. size: GPUExtent3D): void;
  82038. copyImageBitmapToTexture(
  82039. source: GPUImageBitmapCopyView,
  82040. destination: GPUTextureCopyView,
  82041. copySize: GPUExtent3D
  82042. ): void;
  82043. }
  82044. type GPUQueryType =
  82045. | "occlusion"
  82046. | "timestamp"
  82047. | "pipeline-statistics";
  82048. type GPUPipelineStatisticName =
  82049. | "vertex-shader-invocations"
  82050. | "clipper-invocations"
  82051. | "clipper-primitives-out"
  82052. | "fragment-shader-invocations"
  82053. | "compute-shader-invocations";
  82054. interface GPUQuerySetDescriptor extends GPUObjectDescriptorBase {
  82055. type: GPUQueryType;
  82056. count: number;
  82057. pipelineStatistics?: Iterable<GPUPipelineStatisticName>;
  82058. }
  82059. declare class GPUQuerySet implements GPUObjectBase {
  82060. private __brand: void;
  82061. label: string | undefined;
  82062. destroy(): void;
  82063. }
  82064. interface GPURenderEncoderBase {
  82065. setPipeline(pipeline: GPURenderPipeline): void;
  82066. setIndexBuffer(buffer: GPUBuffer, offset?: number, size?: number): void;
  82067. setIndexBuffer(buffer: GPUBuffer, indexFormat: GPUIndexFormat, offset?: number, size?: number): void;
  82068. setVertexBuffer(slot: number, buffer: GPUBuffer, offset?: number, size?: number): void;
  82069. draw(
  82070. vertexCount: number,
  82071. instanceCount?: number,
  82072. firstVertex?: number,
  82073. firstInstance?: number
  82074. ): void;
  82075. drawIndexed(
  82076. indexCount: number,
  82077. instanceCount?: number,
  82078. firstIndex?: number,
  82079. baseVertex?: number,
  82080. firstInstance?: number
  82081. ): void;
  82082. drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  82083. drawIndexedIndirect(
  82084. indirectBuffer: GPUBuffer,
  82085. indirectOffset: number
  82086. ): void;
  82087. }
  82088. declare class GPURenderPassEncoder implements GPUObjectBase, GPUProgrammablePassEncoder, GPURenderEncoderBase {
  82089. private __brand: void;
  82090. label: string | undefined;
  82091. setBindGroup(
  82092. index: number,
  82093. bindGroup: GPUBindGroup,
  82094. dynamicOffsets?: Iterable<number>
  82095. ): void;
  82096. popDebugGroup(): void;
  82097. pushDebugGroup(groupLabel: string): void;
  82098. insertDebugMarker(markerLabel: string): void;
  82099. setPipeline(pipeline: GPURenderPipeline): void;
  82100. setIndexBuffer(buffer: GPUBuffer, offset?: number): void;
  82101. setIndexBuffer(buffer: GPUBuffer, indexFormat: GPUIndexFormat, offset?: number, size?: number): void;
  82102. setVertexBuffer(slot: number, buffer: GPUBuffer, offset?: number): void;
  82103. draw(
  82104. vertexCount: number,
  82105. instanceCount?: number,
  82106. firstVertex?: number,
  82107. firstInstance?: number
  82108. ): void;
  82109. drawIndexed(
  82110. indexCount: number,
  82111. instanceCount?: number,
  82112. firstIndex?: number,
  82113. baseVertex?: number,
  82114. firstInstance?: number
  82115. ): void;
  82116. drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  82117. drawIndexedIndirect(
  82118. indirectBuffer: GPUBuffer,
  82119. indirectOffset: number
  82120. ): void;
  82121. setViewport(
  82122. x: number,
  82123. y: number,
  82124. width: number,
  82125. height: number,
  82126. minDepth: number,
  82127. maxDepth: number
  82128. ): void;
  82129. setScissorRect(x: number, y: number, width: number, height: number): void;
  82130. setBlendColor(color: GPUColor): void;
  82131. setStencilReference(reference: number): void;
  82132. writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;
  82133. beginOcclusionQuery(queryIndex: number): void;
  82134. endOcclusionQuery(): void;
  82135. beginPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  82136. endPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  82137. executeBundles(bundles: Iterable<GPURenderBundle>): void;
  82138. endPass(): void;
  82139. }
  82140. interface GPURenderBundleDescriptor extends GPUObjectDescriptorBase { }
  82141. declare class GPURenderBundle implements GPUObjectBase {
  82142. private __brand: void;
  82143. label: string | undefined;
  82144. }
  82145. declare class GPURenderBundleEncoder implements GPURenderEncoderBase {
  82146. private __brand: void;
  82147. label: string | undefined;
  82148. setBindGroup(
  82149. index: number,
  82150. bindGroup: GPUBindGroup,
  82151. dynamicOffsets?: Iterable<number>
  82152. ): void;
  82153. popDebugGroup(): void;
  82154. pushDebugGroup(groupLabel: string): void;
  82155. insertDebugMarker(markerLabel: string): void;
  82156. setPipeline(pipeline: GPURenderPipeline): void;
  82157. setIndexBuffer(buffer: GPUBuffer, offset?: number): void;
  82158. setIndexBuffer(buffer: GPUBuffer, indexFormat: GPUIndexFormat, offset?: number, size?: number): void;
  82159. setVertexBuffer(slot: number, buffer: GPUBuffer, offset?: number): void;
  82160. draw(
  82161. vertexCount: number,
  82162. instanceCount?: number,
  82163. firstVertex?: number,
  82164. firstInstance?: number
  82165. ): void;
  82166. drawIndexed(
  82167. indexCount: number,
  82168. instanceCount?: number,
  82169. firstIndex?: number,
  82170. baseVertex?: number,
  82171. firstInstance?: number
  82172. ): void;
  82173. drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  82174. drawIndexedIndirect(
  82175. indirectBuffer: GPUBuffer,
  82176. indirectOffset: number
  82177. ): void;
  82178. finish(descriptor?: GPURenderBundleDescriptor): GPURenderBundle;
  82179. }
  82180. interface GPURenderBundleEncoderDescriptor
  82181. extends GPUObjectDescriptorBase {
  82182. colorFormats: Iterable<GPUTextureFormat>;
  82183. depthStencilFormat?: GPUTextureFormat;
  82184. sampleCount?: number;
  82185. }
  82186. declare class GPURenderPipeline implements GPUPipelineBase {
  82187. private __brand: void;
  82188. label: string | undefined;
  82189. getBindGroupLayout(index: number): GPUBindGroupLayout;
  82190. }
  82191. declare class GPUSampler implements GPUObjectBase {
  82192. private __brand: void;
  82193. label: string | undefined;
  82194. }
  82195. type GPUCompilationMessageType =
  82196. | "error"
  82197. | "warning"
  82198. | "info";
  82199. interface GPUCompilationMessage {
  82200. readonly message: string;
  82201. readonly type: GPUCompilationMessageType;
  82202. readonly lineNum: number;
  82203. readonly linePos: number;
  82204. }
  82205. interface GPUCompilationInfo {
  82206. readonly messages: readonly GPUCompilationMessage[];
  82207. }
  82208. declare class GPUShaderModule implements GPUObjectBase {
  82209. private __brand: void;
  82210. label: string | undefined;
  82211. compilationInfo(): Promise<GPUCompilationInfo>;
  82212. }
  82213. declare class GPUSwapChain implements GPUObjectBase {
  82214. private __brand: void;
  82215. label: string | undefined;
  82216. getCurrentTexture(): GPUTexture;
  82217. }
  82218. declare class GPUTexture implements GPUObjectBase {
  82219. private __brand: void;
  82220. label: string | undefined;
  82221. createView(descriptor?: GPUTextureViewDescriptor): GPUTextureView;
  82222. destroy(): void;
  82223. }
  82224. declare class GPUTextureView implements GPUObjectBase {
  82225. private __brand: void;
  82226. label: string | undefined;
  82227. }
  82228. type GPUPowerPreference = "low-power" | "high-performance";
  82229. interface GPURequestAdapterOptions {
  82230. powerPreference?: GPUPowerPreference;
  82231. }
  82232. declare class GPU {
  82233. private __brand: void;
  82234. requestAdapter(options?: GPURequestAdapterOptions): Promise<GPUAdapter | null>;
  82235. }
  82236. // ****************************************************************************
  82237. // ERROR SCOPES
  82238. // ****************************************************************************
  82239. type GPUErrorFilter = "out-of-memory" | "validation";
  82240. declare class GPUOutOfMemoryError {
  82241. private __brand: void;
  82242. constructor();
  82243. }
  82244. declare class GPUValidationError {
  82245. private __brand: void;
  82246. constructor(message: string);
  82247. readonly message: string;
  82248. }
  82249. type GPUError = GPUOutOfMemoryError | GPUValidationError;
  82250. // ****************************************************************************
  82251. // TELEMETRY
  82252. // ****************************************************************************
  82253. declare class GPUUncapturedErrorEvent extends Event {
  82254. private __brand: void;
  82255. constructor(
  82256. type: string,
  82257. gpuUncapturedErrorEventInitDict: GPUUncapturedErrorEventInit
  82258. );
  82259. readonly error: GPUError;
  82260. }
  82261. interface GPUUncapturedErrorEventInit extends EventInit {
  82262. error: GPUError;
  82263. }
  82264. declare class GPUDeviceLostInfo {
  82265. private __brand: void;
  82266. readonly message: string;
  82267. }
  82268. // Type definitions for WebVR API
  82269. // Project: https://w3c.github.io/webvr/
  82270. // Definitions by: six a <https://github.com/lostfictions>
  82271. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  82272. interface VRDisplay extends EventTarget {
  82273. /**
  82274. * Dictionary of capabilities describing the VRDisplay.
  82275. */
  82276. readonly capabilities: VRDisplayCapabilities;
  82277. /**
  82278. * z-depth defining the far plane of the eye view frustum
  82279. * enables mapping of values in the render target depth
  82280. * attachment to scene coordinates. Initially set to 10000.0.
  82281. */
  82282. depthFar: number;
  82283. /**
  82284. * z-depth defining the near plane of the eye view frustum
  82285. * enables mapping of values in the render target depth
  82286. * attachment to scene coordinates. Initially set to 0.01.
  82287. */
  82288. depthNear: number;
  82289. /**
  82290. * An identifier for this distinct VRDisplay. Used as an
  82291. * association point in the Gamepad API.
  82292. */
  82293. readonly displayId: number;
  82294. /**
  82295. * A display name, a user-readable name identifying it.
  82296. */
  82297. readonly displayName: string;
  82298. readonly isConnected: boolean;
  82299. readonly isPresenting: boolean;
  82300. /**
  82301. * If this VRDisplay supports room-scale experiences, the optional
  82302. * stage attribute contains details on the room-scale parameters.
  82303. */
  82304. readonly stageParameters: VRStageParameters | null;
  82305. /**
  82306. * Passing the value returned by `requestAnimationFrame` to
  82307. * `cancelAnimationFrame` will unregister the callback.
  82308. * @param handle Define the hanle of the request to cancel
  82309. */
  82310. cancelAnimationFrame(handle: number): void;
  82311. /**
  82312. * Stops presenting to the VRDisplay.
  82313. * @returns a promise to know when it stopped
  82314. */
  82315. exitPresent(): Promise<void>;
  82316. /**
  82317. * Return the current VREyeParameters for the given eye.
  82318. * @param whichEye Define the eye we want the parameter for
  82319. * @returns the eye parameters
  82320. */
  82321. getEyeParameters(whichEye: string): VREyeParameters;
  82322. /**
  82323. * Populates the passed VRFrameData with the information required to render
  82324. * the current frame.
  82325. * @param frameData Define the data structure to populate
  82326. * @returns true if ok otherwise false
  82327. */
  82328. getFrameData(frameData: VRFrameData): boolean;
  82329. /**
  82330. * Get the layers currently being presented.
  82331. * @returns the list of VR layers
  82332. */
  82333. getLayers(): VRLayer[];
  82334. /**
  82335. * Return a VRPose containing the future predicted pose of the VRDisplay
  82336. * when the current frame will be presented. The value returned will not
  82337. * change until JavaScript has returned control to the browser.
  82338. *
  82339. * The VRPose will contain the position, orientation, velocity,
  82340. * and acceleration of each of these properties.
  82341. * @returns the pose object
  82342. */
  82343. getPose(): VRPose;
  82344. /**
  82345. * Return the current instantaneous pose of the VRDisplay, with no
  82346. * prediction applied.
  82347. * @returns the current instantaneous pose
  82348. */
  82349. getImmediatePose(): VRPose;
  82350. /**
  82351. * The callback passed to `requestAnimationFrame` will be called
  82352. * any time a new frame should be rendered. When the VRDisplay is
  82353. * presenting the callback will be called at the native refresh
  82354. * rate of the HMD. When not presenting this function acts
  82355. * identically to how window.requestAnimationFrame acts. Content should
  82356. * make no assumptions of frame rate or vsync behavior as the HMD runs
  82357. * asynchronously from other displays and at differing refresh rates.
  82358. * @param callback Define the action to run next frame
  82359. * @returns the request handle it
  82360. */
  82361. requestAnimationFrame(callback: FrameRequestCallback): number;
  82362. /**
  82363. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  82364. * Repeat calls while already presenting will update the VRLayers being displayed.
  82365. * @param layers Define the list of layer to present
  82366. * @returns a promise to know when the request has been fulfilled
  82367. */
  82368. requestPresent(layers: VRLayer[]): Promise<void>;
  82369. /**
  82370. * Reset the pose for this display, treating its current position and
  82371. * orientation as the "origin/zero" values. VRPose.position,
  82372. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  82373. * updated when calling resetPose(). This should be called in only
  82374. * sitting-space experiences.
  82375. */
  82376. resetPose(): void;
  82377. /**
  82378. * The VRLayer provided to the VRDisplay will be captured and presented
  82379. * in the HMD. Calling this function has the same effect on the source
  82380. * canvas as any other operation that uses its source image, and canvases
  82381. * created without preserveDrawingBuffer set to true will be cleared.
  82382. * @param pose Define the pose to submit
  82383. */
  82384. submitFrame(pose?: VRPose): void;
  82385. }
  82386. declare var VRDisplay: {
  82387. prototype: VRDisplay;
  82388. new(): VRDisplay;
  82389. };
  82390. interface VRLayer {
  82391. leftBounds?: number[] | Float32Array | null;
  82392. rightBounds?: number[] | Float32Array | null;
  82393. source?: HTMLCanvasElement | null;
  82394. }
  82395. interface VRDisplayCapabilities {
  82396. readonly canPresent: boolean;
  82397. readonly hasExternalDisplay: boolean;
  82398. readonly hasOrientation: boolean;
  82399. readonly hasPosition: boolean;
  82400. readonly maxLayers: number;
  82401. }
  82402. interface VREyeParameters {
  82403. /** @deprecated */
  82404. readonly fieldOfView: VRFieldOfView;
  82405. readonly offset: Float32Array;
  82406. readonly renderHeight: number;
  82407. readonly renderWidth: number;
  82408. }
  82409. interface VRFieldOfView {
  82410. readonly downDegrees: number;
  82411. readonly leftDegrees: number;
  82412. readonly rightDegrees: number;
  82413. readonly upDegrees: number;
  82414. }
  82415. interface VRFrameData {
  82416. readonly leftProjectionMatrix: Float32Array;
  82417. readonly leftViewMatrix: Float32Array;
  82418. readonly pose: VRPose;
  82419. readonly rightProjectionMatrix: Float32Array;
  82420. readonly rightViewMatrix: Float32Array;
  82421. readonly timestamp: number;
  82422. }
  82423. interface VRPose {
  82424. readonly angularAcceleration: Float32Array | null;
  82425. readonly angularVelocity: Float32Array | null;
  82426. readonly linearAcceleration: Float32Array | null;
  82427. readonly linearVelocity: Float32Array | null;
  82428. readonly orientation: Float32Array | null;
  82429. readonly position: Float32Array | null;
  82430. readonly timestamp: number;
  82431. }
  82432. interface VRStageParameters {
  82433. sittingToStandingTransform?: Float32Array;
  82434. sizeX?: number;
  82435. sizeY?: number;
  82436. }
  82437. interface Navigator {
  82438. getVRDisplays(): Promise<VRDisplay[]>;
  82439. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  82440. }
  82441. interface Window {
  82442. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  82443. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  82444. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  82445. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  82446. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  82447. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  82448. }
  82449. interface Gamepad {
  82450. readonly displayId: number;
  82451. }
  82452. /**
  82453. * Available session modes
  82454. */
  82455. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  82456. /**
  82457. * Reference space types
  82458. */
  82459. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  82460. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  82461. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  82462. /**
  82463. * Handedness types
  82464. */
  82465. type XRHandedness = "none" | "left" | "right";
  82466. /**
  82467. * InputSource target ray modes
  82468. */
  82469. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  82470. /**
  82471. * Eye types
  82472. */
  82473. type XREye = "none" | "left" | "right";
  82474. /**
  82475. * Type of XR events available
  82476. */
  82477. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  82478. type XRFrameRequestCallback = (time: DOMHighResTimeStamp, frame: XRFrame) => void;
  82479. type XRPlaneSet = Set<XRPlane>;
  82480. type XRAnchorSet = Set<XRAnchor>;
  82481. type XREventHandler = (callback: any) => void;
  82482. interface XRLayer extends EventTarget {}
  82483. interface XRSessionInit {
  82484. optionalFeatures?: string[];
  82485. requiredFeatures?: string[];
  82486. trackedImages?: XRTrackedImageInit[];
  82487. }
  82488. interface XRSessionEvent extends Event {
  82489. readonly session: XRSession;
  82490. }
  82491. interface XRSystem {
  82492. isSessionSupported: (sessionMode: XRSessionMode) => Promise<boolean>;
  82493. requestSession: (sessionMode: XRSessionMode, sessionInit?: any) => Promise<XRSession>;
  82494. }
  82495. interface XRViewport {
  82496. readonly x: number;
  82497. readonly y: number;
  82498. readonly width: number;
  82499. readonly height: number;
  82500. }
  82501. interface XRWebGLLayerInit {
  82502. antialias?: boolean;
  82503. depth?: boolean;
  82504. stencil?: boolean;
  82505. alpha?: boolean;
  82506. multiview?: boolean;
  82507. framebufferScaleFactor?: number;
  82508. }
  82509. declare class XRWebGLLayer {
  82510. static getNativeFramebufferScaleFactor(session: XRSession): number;
  82511. constructor(session: XRSession, context: WebGLRenderingContext | WebGL2RenderingContext, layerInit?: XRWebGLLayerInit);
  82512. readonly antialias: boolean;
  82513. readonly framebuffer: WebGLFramebuffer;
  82514. readonly framebufferWidth: number;
  82515. readonly framebufferHeight: number;
  82516. readonly ignoreDepthValues: boolean;
  82517. getViewport: (view: XRView) => XRViewport;
  82518. }
  82519. // tslint:disable-next-line no-empty-interface
  82520. interface XRSpace extends EventTarget {}
  82521. interface XRRenderState {
  82522. readonly baseLayer?: XRWebGLLayer;
  82523. readonly depthFar: number;
  82524. readonly depthNear: number;
  82525. readonly inlineVerticalFieldOfView?: number;
  82526. }
  82527. interface XRRenderStateInit extends XRRenderState {
  82528. baseLayer: XRWebGLLayer;
  82529. depthFar: number;
  82530. depthNear: number;
  82531. inlineVerticalFieldOfView?: number;
  82532. layers?: XRLayer[];
  82533. }
  82534. interface XRReferenceSpace extends XRSpace {
  82535. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  82536. onreset: XREventHandler;
  82537. }
  82538. interface XRBoundedReferenceSpace extends XRSpace {
  82539. readonly boundsGeometry: DOMPointReadOnly[];
  82540. }
  82541. interface XRInputSource {
  82542. readonly handedness: XRHandedness;
  82543. readonly targetRayMode: XRTargetRayMode;
  82544. readonly targetRaySpace: XRSpace;
  82545. readonly gripSpace?: XRSpace;
  82546. readonly gamepad?: Gamepad;
  82547. readonly profiles: Array<string>;
  82548. readonly hand?: XRHand;
  82549. }
  82550. interface XRPose {
  82551. readonly transform: XRRigidTransform;
  82552. readonly emulatedPosition: boolean;
  82553. }
  82554. interface XRWorldInformation {
  82555. detectedPlanes?: XRPlaneSet;
  82556. }
  82557. interface XRFrame {
  82558. readonly session: XRSession;
  82559. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  82560. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  82561. // AR
  82562. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  82563. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  82564. // Anchors
  82565. trackedAnchors?: XRAnchorSet;
  82566. createAnchor?(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  82567. // World geometries
  82568. worldInformation?: XRWorldInformation;
  82569. // Hand tracking
  82570. getJointPose?(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  82571. // Image tracking
  82572. getImageTrackingResults?(): Array<XRImageTrackingResult>;
  82573. }
  82574. interface XRInputSourceEvent extends Event {
  82575. readonly frame: XRFrame;
  82576. readonly inputSource: XRInputSource;
  82577. }
  82578. type XRInputSourceArray = XRInputSource[];
  82579. interface XRSession {
  82580. addEventListener(type: XREventType, listener: XREventHandler, options?: boolean | AddEventListenerOptions): void;
  82581. removeEventListener(type: XREventType, listener: XREventHandler, options?: boolean | EventListenerOptions): void;
  82582. /**
  82583. * Returns a list of this session's XRInputSources, each representing an input device
  82584. * used to control the camera and/or scene.
  82585. */
  82586. readonly inputSources: Array<XRInputSource>;
  82587. /**
  82588. * object which contains options affecting how the imagery is rendered.
  82589. * This includes things such as the near and far clipping planes
  82590. */
  82591. readonly renderState: XRRenderState;
  82592. readonly visibilityState: XRVisibilityState;
  82593. /**
  82594. * Removes a callback from the animation frame painting callback from
  82595. * XRSession's set of animation frame rendering callbacks, given the
  82596. * identifying handle returned by a previous call to requestAnimationFrame().
  82597. */
  82598. cancelAnimationFrame: (handle: number) => void;
  82599. /**
  82600. * Ends the WebXR session. Returns a promise which resolves when the
  82601. * session has been shut down.
  82602. */
  82603. end(): Promise<void>;
  82604. /**
  82605. * Schedules the specified method to be called the next time the user agent
  82606. * is working on rendering an animation frame for the WebXR device. Returns an
  82607. * integer value which can be used to identify the request for the purposes of
  82608. * canceling the callback using cancelAnimationFrame(). This method is comparable
  82609. * to the Window.requestAnimationFrame() method.
  82610. */
  82611. requestAnimationFrame: XRFrameRequestCallback;
  82612. /**
  82613. * Requests that a new XRReferenceSpace of the specified type be created.
  82614. * Returns a promise which resolves with the XRReferenceSpace or
  82615. * XRBoundedReferenceSpace which was requested, or throws a NotSupportedError if
  82616. * the requested space type isn't supported by the device.
  82617. */
  82618. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace | XRBoundedReferenceSpace>;
  82619. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  82620. onend: XREventHandler;
  82621. oninputsourceschange: XREventHandler;
  82622. onselect: XREventHandler;
  82623. onselectstart: XREventHandler;
  82624. onselectend: XREventHandler;
  82625. onsqueeze: XREventHandler;
  82626. onsqueezestart: XREventHandler;
  82627. onsqueezeend: XREventHandler;
  82628. onvisibilitychange: XREventHandler;
  82629. // hit test
  82630. requestHitTestSource?(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  82631. requestHitTestSourceForTransientInput?(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  82632. // legacy AR hit test
  82633. requestHitTest?(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  82634. // legacy plane detection
  82635. updateWorldTrackingState?(options: { planeDetectionState?: { enabled: boolean } }): void;
  82636. // image tracking
  82637. getTrackedImageScores?(): XRImageTrackingScore[];
  82638. }
  82639. interface XRViewerPose extends XRPose {
  82640. readonly views: Array<XRView>;
  82641. }
  82642. declare class XRRigidTransform {
  82643. constructor(position?: DOMPointInit, direction?: DOMPointInit);
  82644. position: DOMPointReadOnly;
  82645. orientation: DOMPointReadOnly;
  82646. matrix: Float32Array;
  82647. inverse: XRRigidTransform;
  82648. }
  82649. interface XRView {
  82650. readonly eye: XREye;
  82651. readonly projectionMatrix: Float32Array;
  82652. readonly transform: XRRigidTransform;
  82653. readonly recommendedViewportScale?: number;
  82654. requestViewportScale(scale: number): void;
  82655. }
  82656. interface XRInputSourceChangeEvent extends Event {
  82657. session: XRSession;
  82658. removed: Array<XRInputSource>;
  82659. added: Array<XRInputSource>;
  82660. }
  82661. // Experimental/Draft features
  82662. declare class XRRay {
  82663. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  82664. origin: DOMPointReadOnly;
  82665. direction: DOMPointReadOnly;
  82666. matrix: Float32Array;
  82667. }
  82668. declare enum XRHitTestTrackableType {
  82669. "point",
  82670. "plane",
  82671. "mesh",
  82672. }
  82673. interface XRHitResult {
  82674. hitMatrix: Float32Array;
  82675. }
  82676. interface XRTransientInputHitTestResult {
  82677. readonly inputSource: XRInputSource;
  82678. readonly results: Array<XRHitTestResult>;
  82679. }
  82680. interface XRHitTestResult {
  82681. getPose(baseSpace: XRSpace): XRPose | undefined;
  82682. // When anchor system is enabled
  82683. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  82684. }
  82685. interface XRHitTestSource {
  82686. cancel(): void;
  82687. }
  82688. interface XRTransientInputHitTestSource {
  82689. cancel(): void;
  82690. }
  82691. interface XRHitTestOptionsInit {
  82692. space: XRSpace;
  82693. entityTypes?: Array<XRHitTestTrackableType>;
  82694. offsetRay?: XRRay;
  82695. }
  82696. interface XRTransientInputHitTestOptionsInit {
  82697. profile: string;
  82698. entityTypes?: Array<XRHitTestTrackableType>;
  82699. offsetRay?: XRRay;
  82700. }
  82701. interface XRAnchor {
  82702. anchorSpace: XRSpace;
  82703. delete(): void;
  82704. }
  82705. interface XRPlane {
  82706. orientation: "Horizontal" | "Vertical";
  82707. planeSpace: XRSpace;
  82708. polygon: Array<DOMPointReadOnly>;
  82709. lastChangedTime: number;
  82710. }
  82711. interface XRJointSpace extends XRSpace {}
  82712. interface XRJointPose extends XRPose {
  82713. radius: number | undefined;
  82714. }
  82715. interface XRHand extends Iterable<XRJointSpace> {
  82716. readonly length: number;
  82717. [index: number]: XRJointSpace;
  82718. readonly WRIST: number;
  82719. readonly THUMB_METACARPAL: number;
  82720. readonly THUMB_PHALANX_PROXIMAL: number;
  82721. readonly THUMB_PHALANX_DISTAL: number;
  82722. readonly THUMB_PHALANX_TIP: number;
  82723. readonly INDEX_METACARPAL: number;
  82724. readonly INDEX_PHALANX_PROXIMAL: number;
  82725. readonly INDEX_PHALANX_INTERMEDIATE: number;
  82726. readonly INDEX_PHALANX_DISTAL: number;
  82727. readonly INDEX_PHALANX_TIP: number;
  82728. readonly MIDDLE_METACARPAL: number;
  82729. readonly MIDDLE_PHALANX_PROXIMAL: number;
  82730. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  82731. readonly MIDDLE_PHALANX_DISTAL: number;
  82732. readonly MIDDLE_PHALANX_TIP: number;
  82733. readonly RING_METACARPAL: number;
  82734. readonly RING_PHALANX_PROXIMAL: number;
  82735. readonly RING_PHALANX_INTERMEDIATE: number;
  82736. readonly RING_PHALANX_DISTAL: number;
  82737. readonly RING_PHALANX_TIP: number;
  82738. readonly LITTLE_METACARPAL: number;
  82739. readonly LITTLE_PHALANX_PROXIMAL: number;
  82740. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  82741. readonly LITTLE_PHALANX_DISTAL: number;
  82742. readonly LITTLE_PHALANX_TIP: number;
  82743. }
  82744. type XRImageTrackingState = "tracked" | "emulated";
  82745. type XRImageTrackingScore = "untrackable" | "trackable";
  82746. interface XRTrackedImageInit {
  82747. image: ImageBitmap;
  82748. widthInMeters: number;
  82749. }
  82750. interface XRImageTrackingResult {
  82751. readonly imageSpace: XRSpace;
  82752. readonly index: number;
  82753. readonly trackingState: XRImageTrackingState;
  82754. readonly measuredWidthInMeters: number;
  82755. }
  82756. // This file contains native only extensions for WebXR. These APIs are not supported in the browser yet.
  82757. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  82758. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  82759. type XRSceneObjectType = "unknown" | "background" | "wall" | "floor" | "ceiling" | "platform";
  82760. interface XRSceneObject {
  82761. type: XRSceneObjectType;
  82762. }
  82763. interface XRFieldOfView {
  82764. angleLeft: number;
  82765. angleRight: number;
  82766. angleUp: number;
  82767. angleDown: number;
  82768. }
  82769. interface XRFrustum {
  82770. position: DOMPointReadOnly;
  82771. orientation: DOMPointReadOnly;
  82772. fieldOfView: XRFieldOfView;
  82773. farDistance: number;
  82774. }
  82775. interface XRPlane {
  82776. parentSceneObject?: XRSceneObject;
  82777. }
  82778. interface XRMesh {
  82779. meshSpace: XRSpace;
  82780. positions: Float32Array;
  82781. indices: Uint32Array;
  82782. normals?: Float32Array;
  82783. lastChangedTime: number;
  82784. parentSceneObject?: XRSceneObject;
  82785. }
  82786. interface XRFrustumDetectionBoundary {
  82787. type: "frustum";
  82788. frustum: XRFrustum;
  82789. }
  82790. interface XRSphereDetectionBoundary {
  82791. type: "sphere";
  82792. radius: number;
  82793. }
  82794. interface XRBoxDetectionBoundary {
  82795. type: "box";
  82796. extent: DOMPointReadOnly;
  82797. }
  82798. type XRDetectionBoundary = XRFrustumDetectionBoundary | XRSphereDetectionBoundary | XRBoxDetectionBoundary;
  82799. interface XRGeometryDetectorOptions {
  82800. detectionBoundary?: XRDetectionBoundary;
  82801. updateInterval?: number;
  82802. }
  82803. interface XRSession {
  82804. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  82805. trySetPreferredPlaneDetectorOptions(preferredOptions: XRGeometryDetectorOptions): boolean;
  82806. trySetMeshDetectorEnabled(enabled: boolean): boolean;
  82807. trySetPreferredMeshDetectorOptions(preferredOptions: XRGeometryDetectorOptions): boolean;
  82808. }
  82809. interface XRFrame {
  82810. featurePointCloud?: Array<number>;
  82811. }
  82812. type XRMeshSet = Set<XRMesh>;
  82813. interface XRWorldInformation {
  82814. detectedMeshes?: XRMeshSet;
  82815. }
  82816. /**
  82817. * @ignore
  82818. */
  82819. declare module BABYLON.GLTF2.Exporter {
  82820. }
  82821. /**
  82822. * @ignore
  82823. */
  82824. declare module BABYLON.GLTF1 {
  82825. }
  82826. declare module BABYLON.GUI {
  82827. /**
  82828. * Interface used to define a control that can receive focus
  82829. */
  82830. export interface IFocusableControl {
  82831. /**
  82832. * Function called when the control receives the focus
  82833. */
  82834. onFocus(): void;
  82835. /**
  82836. * Function called when the control loses the focus
  82837. */
  82838. onBlur(): void;
  82839. /**
  82840. * Function called to let the control handle keyboard events
  82841. * @param evt defines the current keyboard event
  82842. */
  82843. processKeyboard(evt: BABYLON.IKeyboardEvent): void;
  82844. /**
  82845. * Function called to get the list of controls that should not steal the focus from this control
  82846. * @returns an array of controls
  82847. */
  82848. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  82849. /**
  82850. * Function to focus the control programmatically
  82851. */
  82852. focus(): void;
  82853. /**
  82854. * Function to unfocus the control programmatically
  82855. */
  82856. blur(): void;
  82857. }
  82858. }
  82859. declare module BABYLON.GUI {
  82860. /**
  82861. * Class used to specific a value and its associated unit
  82862. */
  82863. export class ValueAndUnit {
  82864. /** defines the unit to store */
  82865. unit: number;
  82866. /** defines a boolean indicating if the value can be negative */
  82867. negativeValueAllowed: boolean;
  82868. private _value;
  82869. private _originalUnit;
  82870. /**
  82871. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  82872. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  82873. */
  82874. ignoreAdaptiveScaling: boolean;
  82875. /**
  82876. * Creates a new ValueAndUnit
  82877. * @param value defines the value to store
  82878. * @param unit defines the unit to store
  82879. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  82880. */
  82881. constructor(value: number,
  82882. /** defines the unit to store */
  82883. unit?: number,
  82884. /** defines a boolean indicating if the value can be negative */
  82885. negativeValueAllowed?: boolean);
  82886. /** Gets a boolean indicating if the value is a percentage */
  82887. get isPercentage(): boolean;
  82888. /** Gets a boolean indicating if the value is store as pixel */
  82889. get isPixel(): boolean;
  82890. /** Gets direct internal value */
  82891. get internalValue(): number;
  82892. /**
  82893. * Gets value as pixel
  82894. * @param host defines the root host
  82895. * @param refValue defines the reference value for percentages
  82896. * @returns the value as pixel
  82897. */
  82898. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  82899. /**
  82900. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  82901. * @param value defines the value to store
  82902. * @param unit defines the unit to store
  82903. * @returns the current ValueAndUnit
  82904. */
  82905. updateInPlace(value: number, unit?: number): ValueAndUnit;
  82906. /**
  82907. * Gets the value accordingly to its unit
  82908. * @param host defines the root host
  82909. * @returns the value
  82910. */
  82911. getValue(host: AdvancedDynamicTexture): number;
  82912. /**
  82913. * Gets a string representation of the value
  82914. * @param host defines the root host
  82915. * @param decimals defines an optional number of decimals to display
  82916. * @returns a string
  82917. */
  82918. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  82919. /**
  82920. * Store a value parsed from a string
  82921. * @param source defines the source string
  82922. * @returns true if the value was successfully parsed
  82923. */
  82924. fromString(source: string | number): boolean;
  82925. private static _Regex;
  82926. private static _UNITMODE_PERCENTAGE;
  82927. private static _UNITMODE_PIXEL;
  82928. /** UNITMODE_PERCENTAGE */
  82929. static get UNITMODE_PERCENTAGE(): number;
  82930. /** UNITMODE_PIXEL */
  82931. static get UNITMODE_PIXEL(): number;
  82932. }
  82933. }
  82934. declare module BABYLON.GUI {
  82935. /**
  82936. * Define a style used by control to automatically setup properties based on a template.
  82937. * Only support font related properties so far
  82938. */
  82939. export class Style implements BABYLON.IDisposable {
  82940. private _fontFamily;
  82941. private _fontStyle;
  82942. private _fontWeight;
  82943. /** @hidden */
  82944. _host: AdvancedDynamicTexture;
  82945. /** @hidden */
  82946. _fontSize: ValueAndUnit;
  82947. /**
  82948. * BABYLON.Observable raised when the style values are changed
  82949. */
  82950. onChangedObservable: BABYLON.Observable<Style>;
  82951. /**
  82952. * Creates a new style object
  82953. * @param host defines the AdvancedDynamicTexture which hosts this style
  82954. */
  82955. constructor(host: AdvancedDynamicTexture);
  82956. /**
  82957. * Gets or sets the font size
  82958. */
  82959. get fontSize(): string | number;
  82960. set fontSize(value: string | number);
  82961. /**
  82962. * Gets or sets the font family
  82963. */
  82964. get fontFamily(): string;
  82965. set fontFamily(value: string);
  82966. /**
  82967. * Gets or sets the font style
  82968. */
  82969. get fontStyle(): string;
  82970. set fontStyle(value: string);
  82971. /** Gets or sets font weight */
  82972. get fontWeight(): string;
  82973. set fontWeight(value: string);
  82974. /** Dispose all associated resources */
  82975. dispose(): void;
  82976. }
  82977. }
  82978. declare module BABYLON.GUI {
  82979. /**
  82980. * Class used to transport BABYLON.Vector2 information for pointer events
  82981. */
  82982. export class Vector2WithInfo extends BABYLON.Vector2 {
  82983. /** defines the current mouse button index */
  82984. buttonIndex: number;
  82985. /**
  82986. * Creates a new Vector2WithInfo
  82987. * @param source defines the vector2 data to transport
  82988. * @param buttonIndex defines the current mouse button index
  82989. */
  82990. constructor(source: BABYLON.Vector2,
  82991. /** defines the current mouse button index */
  82992. buttonIndex?: number);
  82993. }
  82994. /** Class used to provide 2D matrix features */
  82995. export class Matrix2D {
  82996. /** Gets the internal array of 6 floats used to store matrix data */
  82997. m: Float32Array;
  82998. /**
  82999. * Creates a new matrix
  83000. * @param m00 defines value for (0, 0)
  83001. * @param m01 defines value for (0, 1)
  83002. * @param m10 defines value for (1, 0)
  83003. * @param m11 defines value for (1, 1)
  83004. * @param m20 defines value for (2, 0)
  83005. * @param m21 defines value for (2, 1)
  83006. */
  83007. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  83008. /**
  83009. * Fills the matrix from direct values
  83010. * @param m00 defines value for (0, 0)
  83011. * @param m01 defines value for (0, 1)
  83012. * @param m10 defines value for (1, 0)
  83013. * @param m11 defines value for (1, 1)
  83014. * @param m20 defines value for (2, 0)
  83015. * @param m21 defines value for (2, 1)
  83016. * @returns the current modified matrix
  83017. */
  83018. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  83019. /**
  83020. * Gets matrix determinant
  83021. * @returns the determinant
  83022. */
  83023. determinant(): number;
  83024. /**
  83025. * Inverses the matrix and stores it in a target matrix
  83026. * @param result defines the target matrix
  83027. * @returns the current matrix
  83028. */
  83029. invertToRef(result: Matrix2D): Matrix2D;
  83030. /**
  83031. * Multiplies the current matrix with another one
  83032. * @param other defines the second operand
  83033. * @param result defines the target matrix
  83034. * @returns the current matrix
  83035. */
  83036. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  83037. /**
  83038. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  83039. * @param x defines the x coordinate to transform
  83040. * @param y defines the x coordinate to transform
  83041. * @param result defines the target vector2
  83042. * @returns the current matrix
  83043. */
  83044. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  83045. /**
  83046. * Creates an identity matrix
  83047. * @returns a new matrix
  83048. */
  83049. static Identity(): Matrix2D;
  83050. /**
  83051. * Creates a translation matrix and stores it in a target matrix
  83052. * @param x defines the x coordinate of the translation
  83053. * @param y defines the y coordinate of the translation
  83054. * @param result defines the target matrix
  83055. */
  83056. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  83057. /**
  83058. * Creates a scaling matrix and stores it in a target matrix
  83059. * @param x defines the x coordinate of the scaling
  83060. * @param y defines the y coordinate of the scaling
  83061. * @param result defines the target matrix
  83062. */
  83063. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  83064. /**
  83065. * Creates a rotation matrix and stores it in a target matrix
  83066. * @param angle defines the rotation angle
  83067. * @param result defines the target matrix
  83068. */
  83069. static RotationToRef(angle: number, result: Matrix2D): void;
  83070. private static _TempPreTranslationMatrix;
  83071. private static _TempPostTranslationMatrix;
  83072. private static _TempRotationMatrix;
  83073. private static _TempScalingMatrix;
  83074. private static _TempCompose0;
  83075. private static _TempCompose1;
  83076. private static _TempCompose2;
  83077. /**
  83078. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  83079. * @param tx defines the x coordinate of the translation
  83080. * @param ty defines the y coordinate of the translation
  83081. * @param angle defines the rotation angle
  83082. * @param scaleX defines the x coordinate of the scaling
  83083. * @param scaleY defines the y coordinate of the scaling
  83084. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  83085. * @param result defines the target matrix
  83086. */
  83087. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  83088. }
  83089. }
  83090. declare module BABYLON.GUI {
  83091. /**
  83092. * Class used to store 2D control sizes
  83093. */
  83094. export class Measure {
  83095. /** defines left coordinate */
  83096. left: number;
  83097. /** defines top coordinate */
  83098. top: number;
  83099. /** defines width dimension */
  83100. width: number;
  83101. /** defines height dimension */
  83102. height: number;
  83103. /**
  83104. * Creates a new measure
  83105. * @param left defines left coordinate
  83106. * @param top defines top coordinate
  83107. * @param width defines width dimension
  83108. * @param height defines height dimension
  83109. */
  83110. constructor(
  83111. /** defines left coordinate */
  83112. left: number,
  83113. /** defines top coordinate */
  83114. top: number,
  83115. /** defines width dimension */
  83116. width: number,
  83117. /** defines height dimension */
  83118. height: number);
  83119. /**
  83120. * Copy from another measure
  83121. * @param other defines the other measure to copy from
  83122. */
  83123. copyFrom(other: Measure): void;
  83124. /**
  83125. * Copy from a group of 4 floats
  83126. * @param left defines left coordinate
  83127. * @param top defines top coordinate
  83128. * @param width defines width dimension
  83129. * @param height defines height dimension
  83130. */
  83131. copyFromFloats(left: number, top: number, width: number, height: number): void;
  83132. /**
  83133. * Computes the axis aligned bounding box measure for two given measures
  83134. * @param a Input measure
  83135. * @param b Input measure
  83136. * @param result the resulting bounding measure
  83137. */
  83138. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  83139. /**
  83140. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  83141. * @param transform the matrix to transform the measure before computing the AABB
  83142. * @param addX number to add to left
  83143. * @param addY number to add to top
  83144. * @param addWidth number to add to width
  83145. * @param addHeight number to add to height
  83146. * @param result the resulting AABB
  83147. */
  83148. addAndTransformToRef(transform: Matrix2D, addX: number, addY: number, addWidth: number, addHeight: number, result: Measure): void;
  83149. /**
  83150. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  83151. * @param transform the matrix to transform the measure before computing the AABB
  83152. * @param result the resulting AABB
  83153. */
  83154. transformToRef(transform: Matrix2D, result: Measure): void;
  83155. /**
  83156. * Check equality between this measure and another one
  83157. * @param other defines the other measures
  83158. * @returns true if both measures are equals
  83159. */
  83160. isEqualsTo(other: Measure): boolean;
  83161. /**
  83162. * Creates an empty measure
  83163. * @returns a new measure
  83164. */
  83165. static Empty(): Measure;
  83166. }
  83167. }
  83168. declare module BABYLON.GUI {
  83169. /**
  83170. * Class used to create texture to support 2D GUI elements
  83171. * @see https://doc.babylonjs.com/how_to/gui
  83172. */
  83173. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  83174. /** Define the Uurl to load snippets */
  83175. static SnippetUrl: string;
  83176. /** Snippet ID if the content was created from the snippet server */
  83177. snippetId: string;
  83178. private _isDirty;
  83179. private _renderObserver;
  83180. private _resizeObserver;
  83181. private _preKeyboardObserver;
  83182. private _pointerMoveObserver;
  83183. private _pointerObserver;
  83184. private _canvasPointerOutObserver;
  83185. private _canvasBlurObserver;
  83186. private _background;
  83187. /** @hidden */
  83188. _rootContainer: Container;
  83189. /** @hidden */
  83190. _lastPickedControl: Control;
  83191. /** @hidden */
  83192. _lastControlOver: {
  83193. [pointerId: number]: Control;
  83194. };
  83195. /** @hidden */
  83196. _lastControlDown: {
  83197. [pointerId: number]: Control;
  83198. };
  83199. /** @hidden */
  83200. _capturingControl: {
  83201. [pointerId: number]: Control;
  83202. };
  83203. /** @hidden */
  83204. _shouldBlockPointer: boolean;
  83205. /** @hidden */
  83206. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  83207. /** @hidden */
  83208. _linkedControls: Control[];
  83209. private _isFullscreen;
  83210. private _fullscreenViewport;
  83211. private _idealWidth;
  83212. private _idealHeight;
  83213. private _useSmallestIdeal;
  83214. private _renderAtIdealSize;
  83215. private _focusedControl;
  83216. private _blockNextFocusCheck;
  83217. private _renderScale;
  83218. private _rootElement;
  83219. private _cursorChanged;
  83220. private _defaultMousePointerId;
  83221. /** @hidden */
  83222. _numLayoutCalls: number;
  83223. /** Gets the number of layout calls made the last time the ADT has been rendered */
  83224. get numLayoutCalls(): number;
  83225. /** @hidden */
  83226. _numRenderCalls: number;
  83227. /** Gets the number of render calls made the last time the ADT has been rendered */
  83228. get numRenderCalls(): number;
  83229. /**
  83230. * Define type to string to ensure compatibility across browsers
  83231. * Safari doesn't support DataTransfer constructor
  83232. */
  83233. private _clipboardData;
  83234. /**
  83235. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  83236. */
  83237. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  83238. /**
  83239. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  83240. */
  83241. onControlPickedObservable: BABYLON.Observable<Control>;
  83242. /**
  83243. * BABYLON.Observable event triggered before layout is evaluated
  83244. */
  83245. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  83246. /**
  83247. * BABYLON.Observable event triggered after the layout was evaluated
  83248. */
  83249. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  83250. /**
  83251. * BABYLON.Observable event triggered before the texture is rendered
  83252. */
  83253. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  83254. /**
  83255. * BABYLON.Observable event triggered after the texture was rendered
  83256. */
  83257. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  83258. /**
  83259. * Gets or sets a boolean defining if alpha is stored as premultiplied
  83260. */
  83261. premulAlpha: boolean;
  83262. /**
  83263. * Gets or sets a boolean indicating that the canvas must be reverted on Y when updating the texture
  83264. */
  83265. applyYInversionOnUpdate: boolean;
  83266. /**
  83267. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  83268. * Useful when you want more antialiasing
  83269. */
  83270. get renderScale(): number;
  83271. set renderScale(value: number);
  83272. /** Gets or sets the background color */
  83273. get background(): string;
  83274. set background(value: string);
  83275. /**
  83276. * Gets or sets the ideal width used to design controls.
  83277. * The GUI will then rescale everything accordingly
  83278. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  83279. */
  83280. get idealWidth(): number;
  83281. set idealWidth(value: number);
  83282. /**
  83283. * Gets or sets the ideal height used to design controls.
  83284. * The GUI will then rescale everything accordingly
  83285. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  83286. */
  83287. get idealHeight(): number;
  83288. set idealHeight(value: number);
  83289. /**
  83290. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  83291. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  83292. */
  83293. get useSmallestIdeal(): boolean;
  83294. set useSmallestIdeal(value: boolean);
  83295. /**
  83296. * Gets or sets a boolean indicating if adaptive scaling must be used
  83297. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  83298. */
  83299. get renderAtIdealSize(): boolean;
  83300. set renderAtIdealSize(value: boolean);
  83301. /**
  83302. * Gets the ratio used when in "ideal mode"
  83303. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  83304. * */
  83305. get idealRatio(): number;
  83306. /**
  83307. * Gets the underlying layer used to render the texture when in fullscreen mode
  83308. */
  83309. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  83310. /**
  83311. * Gets the root container control
  83312. */
  83313. get rootContainer(): Container;
  83314. /**
  83315. * Returns an array containing the root container.
  83316. * This is mostly used to let the Inspector introspects the ADT
  83317. * @returns an array containing the rootContainer
  83318. */
  83319. getChildren(): Array<Container>;
  83320. /**
  83321. * Will return all controls that are inside this texture
  83322. * @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
  83323. * @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
  83324. * @return all child controls
  83325. */
  83326. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  83327. /**
  83328. * Gets or sets the current focused control
  83329. */
  83330. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  83331. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  83332. /**
  83333. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  83334. */
  83335. get isForeground(): boolean;
  83336. set isForeground(value: boolean);
  83337. /**
  83338. * Gets or set information about clipboardData
  83339. */
  83340. get clipboardData(): string;
  83341. set clipboardData(value: string);
  83342. /**
  83343. * Creates a new AdvancedDynamicTexture
  83344. * @param name defines the name of the texture
  83345. * @param width defines the width of the texture
  83346. * @param height defines the height of the texture
  83347. * @param scene defines the hosting scene
  83348. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  83349. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  83350. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  83351. */
  83352. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number, invertY?: boolean);
  83353. /**
  83354. * Get the current class name of the texture useful for serialization or dynamic coding.
  83355. * @returns "AdvancedDynamicTexture"
  83356. */
  83357. getClassName(): string;
  83358. /**
  83359. * Function used to execute a function on all controls
  83360. * @param func defines the function to execute
  83361. * @param container defines the container where controls belong. If null the root container will be used
  83362. */
  83363. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  83364. private _useInvalidateRectOptimization;
  83365. /**
  83366. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  83367. */
  83368. get useInvalidateRectOptimization(): boolean;
  83369. set useInvalidateRectOptimization(value: boolean);
  83370. private _invalidatedRectangle;
  83371. /**
  83372. * Invalidates a rectangle area on the gui texture
  83373. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  83374. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  83375. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  83376. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  83377. */
  83378. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  83379. /**
  83380. * Marks the texture as dirty forcing a complete update
  83381. */
  83382. markAsDirty(): void;
  83383. /**
  83384. * Helper function used to create a new style
  83385. * @returns a new style
  83386. * @see https://doc.babylonjs.com/how_to/gui#styles
  83387. */
  83388. createStyle(): Style;
  83389. /**
  83390. * Adds a new control to the root container
  83391. * @param control defines the control to add
  83392. * @returns the current texture
  83393. */
  83394. addControl(control: Control): AdvancedDynamicTexture;
  83395. /**
  83396. * Removes a control from the root container
  83397. * @param control defines the control to remove
  83398. * @returns the current texture
  83399. */
  83400. removeControl(control: Control): AdvancedDynamicTexture;
  83401. /**
  83402. * Release all resources
  83403. */
  83404. dispose(): void;
  83405. private _onResize;
  83406. /** @hidden */
  83407. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  83408. /**
  83409. * Get screen coordinates for a vector3
  83410. * @param position defines the position to project
  83411. * @param worldMatrix defines the world matrix to use
  83412. * @returns the projected position
  83413. */
  83414. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  83415. /**
  83416. * Get screen coordinates for a vector3
  83417. * @param position defines the position to project
  83418. * @param worldMatrix defines the world matrix to use
  83419. * @returns the projected position with Z
  83420. */
  83421. getProjectedPositionWithZ(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector3;
  83422. private _checkUpdate;
  83423. private _clearMeasure;
  83424. private _render;
  83425. /** @hidden */
  83426. _changeCursor(cursor: string): void;
  83427. /** @hidden */
  83428. _registerLastControlDown(control: Control, pointerId: number): void;
  83429. private _doPicking;
  83430. /** @hidden */
  83431. _cleanControlAfterRemovalFromList(list: {
  83432. [pointerId: number]: Control;
  83433. }, control: Control): void;
  83434. /** @hidden */
  83435. _cleanControlAfterRemoval(control: Control): void;
  83436. /** Attach to all scene events required to support pointer events */
  83437. attach(): void;
  83438. /** @hidden */
  83439. private onClipboardCopy;
  83440. /** @hidden */
  83441. private onClipboardCut;
  83442. /** @hidden */
  83443. private onClipboardPaste;
  83444. /**
  83445. * Register the clipboard Events onto the canvas
  83446. */
  83447. registerClipboardEvents(): void;
  83448. /**
  83449. * Unregister the clipboard Events from the canvas
  83450. */
  83451. unRegisterClipboardEvents(): void;
  83452. /**
  83453. * Connect the texture to a hosting mesh to enable interactions
  83454. * @param mesh defines the mesh to attach to
  83455. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  83456. */
  83457. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  83458. /**
  83459. * Move the focus to a specific control
  83460. * @param control defines the control which will receive the focus
  83461. */
  83462. moveFocusToControl(control: IFocusableControl): void;
  83463. private _manageFocus;
  83464. private _attachToOnPointerOut;
  83465. private _attachToOnBlur;
  83466. /**
  83467. * Serializes the entire GUI system
  83468. * @returns an object with the JSON serialized data
  83469. */
  83470. serializeContent(): any;
  83471. /**
  83472. * Recreate the content of the ADT from a JSON object
  83473. * @param serializedObject define the JSON serialized object to restore from
  83474. */
  83475. parseContent(serializedObject: any): void;
  83476. /**
  83477. * Recreate the content of the ADT from a snippet saved by the GUI editor
  83478. * @param snippetId defines the snippet to load
  83479. * @returns a promise that will resolve on success
  83480. */
  83481. parseFromSnippetAsync(snippetId: string): Promise<void>;
  83482. /**
  83483. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  83484. * @param mesh defines the mesh which will receive the texture
  83485. * @param width defines the texture width (1024 by default)
  83486. * @param height defines the texture height (1024 by default)
  83487. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  83488. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  83489. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  83490. * @returns a new AdvancedDynamicTexture
  83491. */
  83492. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean, invertY?: boolean): AdvancedDynamicTexture;
  83493. /**
  83494. * 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
  83495. * @param mesh defines the mesh which will receive the texture
  83496. * @param width defines the texture width (1024 by default)
  83497. * @param height defines the texture height (1024 by default)
  83498. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  83499. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  83500. * @returns a new AdvancedDynamicTexture
  83501. */
  83502. static CreateForMeshTexture(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, invertY?: boolean): AdvancedDynamicTexture;
  83503. /**
  83504. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  83505. * In this mode the texture will rely on a layer for its rendering.
  83506. * This allows it to be treated like any other layer.
  83507. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  83508. * LayerMask is set through advancedTexture.layer.layerMask
  83509. * @param name defines name for the texture
  83510. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  83511. * @param scene defines the hsoting scene
  83512. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  83513. * @returns a new AdvancedDynamicTexture
  83514. */
  83515. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  83516. }
  83517. }
  83518. declare module BABYLON.GUI {
  83519. /**
  83520. * Root class used for all 2D controls
  83521. * @see https://doc.babylonjs.com/how_to/gui#controls
  83522. */
  83523. export class Control {
  83524. /** defines the name of the control */
  83525. name?: string | undefined;
  83526. /**
  83527. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  83528. */
  83529. static AllowAlphaInheritance: boolean;
  83530. private _alpha;
  83531. private _alphaSet;
  83532. private _zIndex;
  83533. /** @hidden */
  83534. _host: AdvancedDynamicTexture;
  83535. /** Gets or sets the control parent */
  83536. parent: BABYLON.Nullable<Container>;
  83537. /** @hidden */
  83538. _currentMeasure: Measure;
  83539. private _fontFamily;
  83540. private _fontStyle;
  83541. private _fontWeight;
  83542. private _fontSize;
  83543. private _font;
  83544. /** @hidden */
  83545. _width: ValueAndUnit;
  83546. /** @hidden */
  83547. _height: ValueAndUnit;
  83548. /** @hidden */
  83549. protected _fontOffset: {
  83550. ascent: number;
  83551. height: number;
  83552. descent: number;
  83553. };
  83554. private _color;
  83555. private _style;
  83556. private _styleObserver;
  83557. /** @hidden */
  83558. protected _horizontalAlignment: number;
  83559. /** @hidden */
  83560. protected _verticalAlignment: number;
  83561. /** @hidden */
  83562. protected _isDirty: boolean;
  83563. /** @hidden */
  83564. protected _wasDirty: boolean;
  83565. /** @hidden */
  83566. _tempParentMeasure: Measure;
  83567. /** @hidden */
  83568. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  83569. /** @hidden */
  83570. protected _cachedParentMeasure: Measure;
  83571. private _paddingLeft;
  83572. private _paddingRight;
  83573. private _paddingTop;
  83574. private _paddingBottom;
  83575. /** @hidden */
  83576. _left: ValueAndUnit;
  83577. /** @hidden */
  83578. _top: ValueAndUnit;
  83579. private _scaleX;
  83580. private _scaleY;
  83581. private _rotation;
  83582. private _transformCenterX;
  83583. private _transformCenterY;
  83584. /** @hidden */
  83585. _transformMatrix: Matrix2D;
  83586. /** @hidden */
  83587. protected _invertTransformMatrix: Matrix2D;
  83588. /** @hidden */
  83589. protected _transformedPosition: BABYLON.Vector2;
  83590. private _isMatrixDirty;
  83591. private _cachedOffsetX;
  83592. private _cachedOffsetY;
  83593. private _isVisible;
  83594. private _isHighlighted;
  83595. /** @hidden */
  83596. _linkedMesh: BABYLON.Nullable<BABYLON.TransformNode>;
  83597. private _fontSet;
  83598. private _dummyVector2;
  83599. private _downCount;
  83600. private _enterCount;
  83601. private _doNotRender;
  83602. private _downPointerIds;
  83603. protected _isEnabled: boolean;
  83604. protected _disabledColor: string;
  83605. protected _disabledColorItem: string;
  83606. /** @hidden */
  83607. protected _rebuildLayout: boolean;
  83608. /** @hidden */
  83609. _customData: any;
  83610. /** @hidden */
  83611. _isClipped: boolean;
  83612. /** @hidden */
  83613. _automaticSize: boolean;
  83614. /** @hidden */
  83615. _tag: any;
  83616. /**
  83617. * 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
  83618. */
  83619. uniqueId: number;
  83620. /**
  83621. * Gets or sets an object used to store user defined information for the node
  83622. */
  83623. metadata: any;
  83624. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  83625. isHitTestVisible: boolean;
  83626. /** Gets or sets a boolean indicating if the control can block pointer events */
  83627. isPointerBlocker: boolean;
  83628. /** Gets or sets a boolean indicating if the control can be focusable */
  83629. isFocusInvisible: boolean;
  83630. /**
  83631. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  83632. * 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
  83633. */
  83634. clipChildren: boolean;
  83635. /**
  83636. * Gets or sets a boolean indicating that control content must be clipped
  83637. * 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
  83638. */
  83639. clipContent: boolean;
  83640. /**
  83641. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  83642. */
  83643. useBitmapCache: boolean;
  83644. private _cacheData;
  83645. private _shadowOffsetX;
  83646. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  83647. get shadowOffsetX(): number;
  83648. set shadowOffsetX(value: number);
  83649. private _shadowOffsetY;
  83650. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  83651. get shadowOffsetY(): number;
  83652. set shadowOffsetY(value: number);
  83653. private _shadowBlur;
  83654. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  83655. get shadowBlur(): number;
  83656. set shadowBlur(value: number);
  83657. private _shadowColor;
  83658. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  83659. get shadowColor(): string;
  83660. set shadowColor(value: string);
  83661. /** Gets or sets the cursor to use when the control is hovered */
  83662. hoverCursor: string;
  83663. /** @hidden */
  83664. protected _linkOffsetX: ValueAndUnit;
  83665. /** @hidden */
  83666. protected _linkOffsetY: ValueAndUnit;
  83667. /** Gets the control type name */
  83668. get typeName(): string;
  83669. /**
  83670. * Get the current class name of the control.
  83671. * @returns current class name
  83672. */
  83673. getClassName(): string;
  83674. /**
  83675. * An event triggered when pointer wheel is scrolled
  83676. */
  83677. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  83678. /**
  83679. * An event triggered when the pointer move over the control.
  83680. */
  83681. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  83682. /**
  83683. * An event triggered when the pointer move out of the control.
  83684. */
  83685. onPointerOutObservable: BABYLON.Observable<Control>;
  83686. /**
  83687. * An event triggered when the pointer taps the control
  83688. */
  83689. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  83690. /**
  83691. * An event triggered when pointer up
  83692. */
  83693. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  83694. /**
  83695. * An event triggered when a control is clicked on
  83696. */
  83697. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  83698. /**
  83699. * An event triggered when pointer enters the control
  83700. */
  83701. onPointerEnterObservable: BABYLON.Observable<Control>;
  83702. /**
  83703. * An event triggered when the control is marked as dirty
  83704. */
  83705. onDirtyObservable: BABYLON.Observable<Control>;
  83706. /**
  83707. * An event triggered before drawing the control
  83708. */
  83709. onBeforeDrawObservable: BABYLON.Observable<Control>;
  83710. /**
  83711. * An event triggered after the control was drawn
  83712. */
  83713. onAfterDrawObservable: BABYLON.Observable<Control>;
  83714. /**
  83715. * An event triggered when the control has been disposed
  83716. */
  83717. onDisposeObservable: BABYLON.Observable<Control>;
  83718. /**
  83719. * Get the hosting AdvancedDynamicTexture
  83720. */
  83721. get host(): AdvancedDynamicTexture;
  83722. /** Gets or set information about font offsets (used to render and align text) */
  83723. get fontOffset(): {
  83724. ascent: number;
  83725. height: number;
  83726. descent: number;
  83727. };
  83728. set fontOffset(offset: {
  83729. ascent: number;
  83730. height: number;
  83731. descent: number;
  83732. });
  83733. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  83734. get alpha(): number;
  83735. set alpha(value: number);
  83736. /**
  83737. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  83738. */
  83739. get isHighlighted(): boolean;
  83740. set isHighlighted(value: boolean);
  83741. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  83742. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  83743. */
  83744. get scaleX(): number;
  83745. set scaleX(value: number);
  83746. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  83747. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  83748. */
  83749. get scaleY(): number;
  83750. set scaleY(value: number);
  83751. /** Gets or sets the rotation angle (0 by default)
  83752. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  83753. */
  83754. get rotation(): number;
  83755. set rotation(value: number);
  83756. /** Gets or sets the transformation center on Y axis (0 by default)
  83757. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  83758. */
  83759. get transformCenterY(): number;
  83760. set transformCenterY(value: number);
  83761. /** Gets or sets the transformation center on X axis (0 by default)
  83762. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  83763. */
  83764. get transformCenterX(): number;
  83765. set transformCenterX(value: number);
  83766. /**
  83767. * Gets or sets the horizontal alignment
  83768. * @see https://doc.babylonjs.com/how_to/gui#alignments
  83769. */
  83770. get horizontalAlignment(): number;
  83771. set horizontalAlignment(value: number);
  83772. /**
  83773. * Gets or sets the vertical alignment
  83774. * @see https://doc.babylonjs.com/how_to/gui#alignments
  83775. */
  83776. get verticalAlignment(): number;
  83777. set verticalAlignment(value: number);
  83778. /**
  83779. * Gets or sets a fixed ratio for this control.
  83780. * When different from 0, the ratio is used to compute the "second" dimension.
  83781. * The first dimension used in the computation is the last one set (by setting width / widthInPixels or height / heightInPixels), and the
  83782. * second dimension is computed as first dimension * fixedRatio
  83783. */
  83784. fixedRatio: number;
  83785. private _fixedRatioMasterIsWidth;
  83786. /**
  83787. * Gets or sets control width
  83788. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83789. */
  83790. get width(): string | number;
  83791. set width(value: string | number);
  83792. /**
  83793. * Gets or sets the control width in pixel
  83794. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83795. */
  83796. get widthInPixels(): number;
  83797. set widthInPixels(value: number);
  83798. /**
  83799. * Gets or sets control height
  83800. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83801. */
  83802. get height(): string | number;
  83803. set height(value: string | number);
  83804. /**
  83805. * Gets or sets control height in pixel
  83806. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83807. */
  83808. get heightInPixels(): number;
  83809. set heightInPixels(value: number);
  83810. /** Gets or set font family */
  83811. get fontFamily(): string;
  83812. set fontFamily(value: string);
  83813. /** Gets or sets font style */
  83814. get fontStyle(): string;
  83815. set fontStyle(value: string);
  83816. /** Gets or sets font weight */
  83817. get fontWeight(): string;
  83818. set fontWeight(value: string);
  83819. /**
  83820. * Gets or sets style
  83821. * @see https://doc.babylonjs.com/how_to/gui#styles
  83822. */
  83823. get style(): BABYLON.Nullable<Style>;
  83824. set style(value: BABYLON.Nullable<Style>);
  83825. /** @hidden */
  83826. get _isFontSizeInPercentage(): boolean;
  83827. /** Gets or sets font size in pixels */
  83828. get fontSizeInPixels(): number;
  83829. set fontSizeInPixels(value: number);
  83830. /** Gets or sets font size */
  83831. get fontSize(): string | number;
  83832. set fontSize(value: string | number);
  83833. /** Gets or sets foreground color */
  83834. get color(): string;
  83835. set color(value: string);
  83836. /** Gets or sets z index which is used to reorder controls on the z axis */
  83837. get zIndex(): number;
  83838. set zIndex(value: number);
  83839. /** Gets or sets a boolean indicating if the control can be rendered */
  83840. get notRenderable(): boolean;
  83841. set notRenderable(value: boolean);
  83842. /** Gets or sets a boolean indicating if the control is visible */
  83843. get isVisible(): boolean;
  83844. set isVisible(value: boolean);
  83845. /** Gets a boolean indicating that the control needs to update its rendering */
  83846. get isDirty(): boolean;
  83847. /**
  83848. * Gets the current linked mesh (or null if none)
  83849. */
  83850. get linkedMesh(): BABYLON.Nullable<BABYLON.TransformNode>;
  83851. /**
  83852. * Gets or sets a value indicating the padding to use on the left of the control
  83853. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83854. */
  83855. get paddingLeft(): string | number;
  83856. set paddingLeft(value: string | number);
  83857. /**
  83858. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  83859. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83860. */
  83861. get paddingLeftInPixels(): number;
  83862. set paddingLeftInPixels(value: number);
  83863. /**
  83864. * Gets or sets a value indicating the padding to use on the right of the control
  83865. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83866. */
  83867. get paddingRight(): string | number;
  83868. set paddingRight(value: string | number);
  83869. /**
  83870. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  83871. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83872. */
  83873. get paddingRightInPixels(): number;
  83874. set paddingRightInPixels(value: number);
  83875. /**
  83876. * Gets or sets a value indicating the padding to use on the top of the control
  83877. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83878. */
  83879. get paddingTop(): string | number;
  83880. set paddingTop(value: string | number);
  83881. /**
  83882. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  83883. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83884. */
  83885. get paddingTopInPixels(): number;
  83886. set paddingTopInPixels(value: number);
  83887. /**
  83888. * Gets or sets a value indicating the padding to use on the bottom of the control
  83889. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83890. */
  83891. get paddingBottom(): string | number;
  83892. set paddingBottom(value: string | number);
  83893. /**
  83894. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  83895. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83896. */
  83897. get paddingBottomInPixels(): number;
  83898. set paddingBottomInPixels(value: number);
  83899. /**
  83900. * Gets or sets a value indicating the left coordinate of the control
  83901. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83902. */
  83903. get left(): string | number;
  83904. set left(value: string | number);
  83905. /**
  83906. * Gets or sets a value indicating the left coordinate in pixels of the control
  83907. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83908. */
  83909. get leftInPixels(): number;
  83910. set leftInPixels(value: number);
  83911. /**
  83912. * Gets or sets a value indicating the top coordinate of the control
  83913. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83914. */
  83915. get top(): string | number;
  83916. set top(value: string | number);
  83917. /**
  83918. * Gets or sets a value indicating the top coordinate in pixels of the control
  83919. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83920. */
  83921. get topInPixels(): number;
  83922. set topInPixels(value: number);
  83923. /**
  83924. * Gets or sets a value indicating the offset on X axis to the linked mesh
  83925. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  83926. */
  83927. get linkOffsetX(): string | number;
  83928. set linkOffsetX(value: string | number);
  83929. /**
  83930. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  83931. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  83932. */
  83933. get linkOffsetXInPixels(): number;
  83934. set linkOffsetXInPixels(value: number);
  83935. /**
  83936. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  83937. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  83938. */
  83939. get linkOffsetY(): string | number;
  83940. set linkOffsetY(value: string | number);
  83941. /**
  83942. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  83943. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  83944. */
  83945. get linkOffsetYInPixels(): number;
  83946. set linkOffsetYInPixels(value: number);
  83947. /** Gets the center coordinate on X axis */
  83948. get centerX(): number;
  83949. /** Gets the center coordinate on Y axis */
  83950. get centerY(): number;
  83951. /** Gets or sets if control is Enabled */
  83952. get isEnabled(): boolean;
  83953. set isEnabled(value: boolean);
  83954. /** Gets or sets background color of control if it's disabled */
  83955. get disabledColor(): string;
  83956. set disabledColor(value: string);
  83957. /** Gets or sets front color of control if it's disabled */
  83958. get disabledColorItem(): string;
  83959. set disabledColorItem(value: string);
  83960. /**
  83961. * Creates a new control
  83962. * @param name defines the name of the control
  83963. */
  83964. constructor(
  83965. /** defines the name of the control */
  83966. name?: string | undefined);
  83967. /** @hidden */
  83968. protected _getTypeName(): string;
  83969. /**
  83970. * Gets the first ascendant in the hierarchy of the given type
  83971. * @param className defines the required type
  83972. * @returns the ascendant or null if not found
  83973. */
  83974. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  83975. /** @hidden */
  83976. _resetFontCache(): void;
  83977. /**
  83978. * Determines if a container is an ascendant of the current control
  83979. * @param container defines the container to look for
  83980. * @returns true if the container is one of the ascendant of the control
  83981. */
  83982. isAscendant(container: Control): boolean;
  83983. /**
  83984. * Gets coordinates in local control space
  83985. * @param globalCoordinates defines the coordinates to transform
  83986. * @returns the new coordinates in local space
  83987. */
  83988. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  83989. /**
  83990. * Gets coordinates in local control space
  83991. * @param globalCoordinates defines the coordinates to transform
  83992. * @param result defines the target vector2 where to store the result
  83993. * @returns the current control
  83994. */
  83995. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  83996. /**
  83997. * Gets coordinates in parent local control space
  83998. * @param globalCoordinates defines the coordinates to transform
  83999. * @returns the new coordinates in parent local space
  84000. */
  84001. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  84002. /**
  84003. * Move the current control to a vector3 position projected onto the screen.
  84004. * @param position defines the target position
  84005. * @param scene defines the hosting scene
  84006. */
  84007. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  84008. /**
  84009. * Will store all controls that have this control as ascendant in a given array
  84010. * @param results defines the array where to store the descendants
  84011. * @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
  84012. * @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
  84013. */
  84014. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  84015. /**
  84016. * Will return all controls that have this control as ascendant
  84017. * @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
  84018. * @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
  84019. * @return all child controls
  84020. */
  84021. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  84022. /**
  84023. * Link current control with a target mesh
  84024. * @param mesh defines the mesh to link with
  84025. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  84026. */
  84027. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.TransformNode>): void;
  84028. /**
  84029. * Shorthand funtion to set the top, right, bottom, and left padding values on the control.
  84030. * @param { string | number} paddingTop - The value of the top padding.
  84031. * @param { string | number} paddingRight - The value of the right padding. If omitted, top is used.
  84032. * @param { string | number} paddingBottom - The value of the bottom padding. If omitted, top is used.
  84033. * @param { string | number} paddingLeft - The value of the left padding. If omitted, right is used.
  84034. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  84035. */
  84036. setPadding(paddingTop: string | number, paddingRight?: string | number, paddingBottom?: string | number, paddingLeft?: string | number): void;
  84037. /**
  84038. * Shorthand funtion to set the top, right, bottom, and left padding values in pixels on the control.
  84039. * @param { number} paddingTop - The value in pixels of the top padding.
  84040. * @param { number} paddingRight - The value in pixels of the right padding. If omitted, top is used.
  84041. * @param { number} paddingBottom - The value in pixels of the bottom padding. If omitted, top is used.
  84042. * @param { number} paddingLeft - The value in pixels of the left padding. If omitted, right is used.
  84043. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  84044. */
  84045. setPaddingInPixels(paddingTop: number, paddingRight?: number, paddingBottom?: number, paddingLeft?: number): void;
  84046. /** @hidden */
  84047. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  84048. /** @hidden */
  84049. _offsetLeft(offset: number): void;
  84050. /** @hidden */
  84051. _offsetTop(offset: number): void;
  84052. /** @hidden */
  84053. _markMatrixAsDirty(): void;
  84054. /** @hidden */
  84055. _flagDescendantsAsMatrixDirty(): void;
  84056. /** @hidden */
  84057. _intersectsRect(rect: Measure): boolean;
  84058. /** @hidden */
  84059. protected invalidateRect(): void;
  84060. /** @hidden */
  84061. _markAsDirty(force?: boolean): void;
  84062. /** @hidden */
  84063. _markAllAsDirty(): void;
  84064. /** @hidden */
  84065. _link(host: AdvancedDynamicTexture): void;
  84066. /** @hidden */
  84067. protected _transform(context?: CanvasRenderingContext2D): void;
  84068. /** @hidden */
  84069. _renderHighlight(context: CanvasRenderingContext2D): void;
  84070. /** @hidden */
  84071. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  84072. /** @hidden */
  84073. protected _applyStates(context: CanvasRenderingContext2D): void;
  84074. /** @hidden */
  84075. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  84076. /** @hidden */
  84077. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84078. protected _evaluateClippingState(parentMeasure: Measure): void;
  84079. /** @hidden */
  84080. _measure(): void;
  84081. /** @hidden */
  84082. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84083. /** @hidden */
  84084. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84085. /** @hidden */
  84086. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84087. /** @hidden */
  84088. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  84089. private static _ClipMeasure;
  84090. private _tmpMeasureA;
  84091. private _clip;
  84092. /** @hidden */
  84093. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  84094. /** @hidden */
  84095. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  84096. /**
  84097. * Tests if a given coordinates belong to the current control
  84098. * @param x defines x coordinate to test
  84099. * @param y defines y coordinate to test
  84100. * @returns true if the coordinates are inside the control
  84101. */
  84102. contains(x: number, y: number): boolean;
  84103. /** @hidden */
  84104. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  84105. /** @hidden */
  84106. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  84107. /** @hidden */
  84108. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  84109. /** @hidden */
  84110. _onPointerOut(target: Control, pi: BABYLON.Nullable<BABYLON.PointerInfoBase>, force?: boolean): void;
  84111. /** @hidden */
  84112. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  84113. /** @hidden */
  84114. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi?: BABYLON.PointerInfoBase): void;
  84115. /** @hidden */
  84116. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  84117. /** @hidden */
  84118. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  84119. /** @hidden */
  84120. _onCanvasBlur(): void;
  84121. /** @hidden */
  84122. _processObservables(type: number, x: number, y: number, pi: BABYLON.PointerInfoBase, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  84123. private _prepareFont;
  84124. /**
  84125. * Serializes the current control
  84126. * @param serializationObject defined the JSON serialized object
  84127. */
  84128. serialize(serializationObject: any): void;
  84129. /** @hidden */
  84130. _parseFromContent(serializedObject: any, host: AdvancedDynamicTexture): void;
  84131. /** Releases associated resources */
  84132. dispose(): void;
  84133. private static _HORIZONTAL_ALIGNMENT_LEFT;
  84134. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  84135. private static _HORIZONTAL_ALIGNMENT_CENTER;
  84136. private static _VERTICAL_ALIGNMENT_TOP;
  84137. private static _VERTICAL_ALIGNMENT_BOTTOM;
  84138. private static _VERTICAL_ALIGNMENT_CENTER;
  84139. /** HORIZONTAL_ALIGNMENT_LEFT */
  84140. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  84141. /** HORIZONTAL_ALIGNMENT_RIGHT */
  84142. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  84143. /** HORIZONTAL_ALIGNMENT_CENTER */
  84144. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  84145. /** VERTICAL_ALIGNMENT_TOP */
  84146. static get VERTICAL_ALIGNMENT_TOP(): number;
  84147. /** VERTICAL_ALIGNMENT_BOTTOM */
  84148. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  84149. /** VERTICAL_ALIGNMENT_CENTER */
  84150. static get VERTICAL_ALIGNMENT_CENTER(): number;
  84151. private static _FontHeightSizes;
  84152. /** @hidden */
  84153. static _GetFontOffset(font: string): {
  84154. ascent: number;
  84155. height: number;
  84156. descent: number;
  84157. };
  84158. /**
  84159. * Creates a Control from parsed data
  84160. * @param serializedObject defines parsed data
  84161. * @param host defines the hosting AdvancedDynamicTexture
  84162. * @returns a new Control
  84163. */
  84164. static Parse(serializedObject: any, host: AdvancedDynamicTexture): Control;
  84165. /**
  84166. * Creates a stack panel that can be used to render headers
  84167. * @param control defines the control to associate with the header
  84168. * @param text defines the text of the header
  84169. * @param size defines the size of the header
  84170. * @param options defines options used to configure the header
  84171. * @returns a new StackPanel
  84172. * @ignore
  84173. * @hidden
  84174. */
  84175. static AddHeader: (control: Control, text: string, size: string | number, options: {
  84176. isHorizontal: boolean;
  84177. controlFirst: boolean;
  84178. }) => any;
  84179. /** @hidden */
  84180. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  84181. }
  84182. }
  84183. declare module BABYLON.GUI {
  84184. /**
  84185. * Root class for 2D containers
  84186. * @see https://doc.babylonjs.com/how_to/gui#containers
  84187. */
  84188. export class Container extends Control {
  84189. name?: string | undefined;
  84190. /** @hidden */
  84191. _children: Control[];
  84192. /** @hidden */
  84193. protected _measureForChildren: Measure;
  84194. /** @hidden */
  84195. protected _background: string;
  84196. /** @hidden */
  84197. protected _adaptWidthToChildren: boolean;
  84198. /** @hidden */
  84199. protected _adaptHeightToChildren: boolean;
  84200. /**
  84201. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  84202. */
  84203. logLayoutCycleErrors: boolean;
  84204. /**
  84205. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  84206. */
  84207. maxLayoutCycle: number;
  84208. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  84209. get adaptHeightToChildren(): boolean;
  84210. set adaptHeightToChildren(value: boolean);
  84211. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  84212. get adaptWidthToChildren(): boolean;
  84213. set adaptWidthToChildren(value: boolean);
  84214. /** Gets or sets background color */
  84215. get background(): string;
  84216. set background(value: string);
  84217. /** Gets the list of children */
  84218. get children(): Control[];
  84219. /**
  84220. * Creates a new Container
  84221. * @param name defines the name of the container
  84222. */
  84223. constructor(name?: string | undefined);
  84224. protected _getTypeName(): string;
  84225. _flagDescendantsAsMatrixDirty(): void;
  84226. /**
  84227. * Gets a child using its name
  84228. * @param name defines the child name to look for
  84229. * @returns the child control if found
  84230. */
  84231. getChildByName(name: string): BABYLON.Nullable<Control>;
  84232. /**
  84233. * Gets a child using its type and its name
  84234. * @param name defines the child name to look for
  84235. * @param type defines the child type to look for
  84236. * @returns the child control if found
  84237. */
  84238. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  84239. /**
  84240. * Search for a specific control in children
  84241. * @param control defines the control to look for
  84242. * @returns true if the control is in child list
  84243. */
  84244. containsControl(control: Control): boolean;
  84245. /**
  84246. * Adds a new control to the current container
  84247. * @param control defines the control to add
  84248. * @returns the current container
  84249. */
  84250. addControl(control: BABYLON.Nullable<Control>): Container;
  84251. /**
  84252. * Removes all controls from the current container
  84253. * @returns the current container
  84254. */
  84255. clearControls(): Container;
  84256. /**
  84257. * Removes a control from the current container
  84258. * @param control defines the control to remove
  84259. * @returns the current container
  84260. */
  84261. removeControl(control: Control): Container;
  84262. /** @hidden */
  84263. _reOrderControl(control: Control): void;
  84264. /** @hidden */
  84265. _offsetLeft(offset: number): void;
  84266. /** @hidden */
  84267. _offsetTop(offset: number): void;
  84268. /** @hidden */
  84269. _markAllAsDirty(): void;
  84270. /** @hidden */
  84271. protected _localDraw(context: CanvasRenderingContext2D): void;
  84272. /** @hidden */
  84273. _link(host: AdvancedDynamicTexture): void;
  84274. /** @hidden */
  84275. protected _beforeLayout(): void;
  84276. /** @hidden */
  84277. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84278. /** @hidden */
  84279. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  84280. protected _postMeasure(): void;
  84281. /** @hidden */
  84282. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  84283. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  84284. /** @hidden */
  84285. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  84286. /** @hidden */
  84287. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84288. /**
  84289. * Serializes the current control
  84290. * @param serializationObject defined the JSON serialized object
  84291. */
  84292. serialize(serializationObject: any): void;
  84293. /** Releases associated resources */
  84294. dispose(): void;
  84295. /** @hidden */
  84296. _parseFromContent(serializedObject: any, host: AdvancedDynamicTexture): void;
  84297. }
  84298. }
  84299. declare module BABYLON.GUI {
  84300. /** Class used to create rectangle container */
  84301. export class Rectangle extends Container {
  84302. name?: string | undefined;
  84303. private _thickness;
  84304. private _cornerRadius;
  84305. /** Gets or sets border thickness */
  84306. get thickness(): number;
  84307. set thickness(value: number);
  84308. /** Gets or sets the corner radius angle */
  84309. get cornerRadius(): number;
  84310. set cornerRadius(value: number);
  84311. /**
  84312. * Creates a new Rectangle
  84313. * @param name defines the control name
  84314. */
  84315. constructor(name?: string | undefined);
  84316. protected _getTypeName(): string;
  84317. protected _localDraw(context: CanvasRenderingContext2D): void;
  84318. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84319. private _drawRoundedRect;
  84320. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  84321. }
  84322. }
  84323. declare module BABYLON.GUI {
  84324. /**
  84325. * Enum that determines the text-wrapping mode to use.
  84326. */
  84327. export enum TextWrapping {
  84328. /**
  84329. * Clip the text when it's larger than Control.width; this is the default mode.
  84330. */
  84331. Clip = 0,
  84332. /**
  84333. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  84334. */
  84335. WordWrap = 1,
  84336. /**
  84337. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  84338. */
  84339. Ellipsis = 2
  84340. }
  84341. /**
  84342. * Class used to create text block control
  84343. */
  84344. export class TextBlock extends Control {
  84345. /**
  84346. * Defines the name of the control
  84347. */
  84348. name?: string | undefined;
  84349. private _text;
  84350. private _textWrapping;
  84351. private _textHorizontalAlignment;
  84352. private _textVerticalAlignment;
  84353. private _lines;
  84354. private _resizeToFit;
  84355. private _lineSpacing;
  84356. private _outlineWidth;
  84357. private _outlineColor;
  84358. private _underline;
  84359. private _lineThrough;
  84360. /**
  84361. * An event triggered after the text is changed
  84362. */
  84363. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  84364. /**
  84365. * An event triggered after the text was broken up into lines
  84366. */
  84367. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  84368. /**
  84369. * Function used to split a string into words. By default, a string is split at each space character found
  84370. */
  84371. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  84372. /**
  84373. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  84374. */
  84375. get lines(): any[];
  84376. /**
  84377. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  84378. */
  84379. get resizeToFit(): boolean;
  84380. /**
  84381. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  84382. */
  84383. set resizeToFit(value: boolean);
  84384. /**
  84385. * Gets or sets a boolean indicating if text must be wrapped
  84386. */
  84387. get textWrapping(): TextWrapping | boolean;
  84388. /**
  84389. * Gets or sets a boolean indicating if text must be wrapped
  84390. */
  84391. set textWrapping(value: TextWrapping | boolean);
  84392. /**
  84393. * Gets or sets text to display
  84394. */
  84395. get text(): string;
  84396. /**
  84397. * Gets or sets text to display
  84398. */
  84399. set text(value: string);
  84400. /**
  84401. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  84402. */
  84403. get textHorizontalAlignment(): number;
  84404. /**
  84405. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  84406. */
  84407. set textHorizontalAlignment(value: number);
  84408. /**
  84409. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  84410. */
  84411. get textVerticalAlignment(): number;
  84412. /**
  84413. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  84414. */
  84415. set textVerticalAlignment(value: number);
  84416. /**
  84417. * Gets or sets line spacing value
  84418. */
  84419. set lineSpacing(value: string | number);
  84420. /**
  84421. * Gets or sets line spacing value
  84422. */
  84423. get lineSpacing(): string | number;
  84424. /**
  84425. * Gets or sets outlineWidth of the text to display
  84426. */
  84427. get outlineWidth(): number;
  84428. /**
  84429. * Gets or sets outlineWidth of the text to display
  84430. */
  84431. set outlineWidth(value: number);
  84432. /**
  84433. * Gets or sets a boolean indicating that text must have underline
  84434. */
  84435. get underline(): boolean;
  84436. /**
  84437. * Gets or sets a boolean indicating that text must have underline
  84438. */
  84439. set underline(value: boolean);
  84440. /**
  84441. * Gets or sets an boolean indicating that text must be crossed out
  84442. */
  84443. get lineThrough(): boolean;
  84444. /**
  84445. * Gets or sets an boolean indicating that text must be crossed out
  84446. */
  84447. set lineThrough(value: boolean);
  84448. /**
  84449. * Gets or sets outlineColor of the text to display
  84450. */
  84451. get outlineColor(): string;
  84452. /**
  84453. * Gets or sets outlineColor of the text to display
  84454. */
  84455. set outlineColor(value: string);
  84456. /**
  84457. * Creates a new TextBlock object
  84458. * @param name defines the name of the control
  84459. * @param text defines the text to display (emptry string by default)
  84460. */
  84461. constructor(
  84462. /**
  84463. * Defines the name of the control
  84464. */
  84465. name?: string | undefined, text?: string);
  84466. protected _getTypeName(): string;
  84467. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84468. private _drawText;
  84469. /** @hidden */
  84470. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  84471. protected _applyStates(context: CanvasRenderingContext2D): void;
  84472. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  84473. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  84474. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  84475. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  84476. protected _renderLines(context: CanvasRenderingContext2D): void;
  84477. /**
  84478. * Given a width constraint applied on the text block, find the expected height
  84479. * @returns expected height
  84480. */
  84481. computeExpectedHeight(): number;
  84482. dispose(): void;
  84483. }
  84484. }
  84485. declare module BABYLON.GUI {
  84486. /**
  84487. * Class used to create 2D images
  84488. */
  84489. export class Image extends Control {
  84490. name?: string | undefined;
  84491. private _workingCanvas;
  84492. private _domImage;
  84493. private _imageWidth;
  84494. private _imageHeight;
  84495. private _loaded;
  84496. private _stretch;
  84497. private _source;
  84498. private _autoScale;
  84499. private _sourceLeft;
  84500. private _sourceTop;
  84501. private _sourceWidth;
  84502. private _sourceHeight;
  84503. private _svgAttributesComputationCompleted;
  84504. private _isSVG;
  84505. private _cellWidth;
  84506. private _cellHeight;
  84507. private _cellId;
  84508. private _populateNinePatchSlicesFromImage;
  84509. private _sliceLeft;
  84510. private _sliceRight;
  84511. private _sliceTop;
  84512. private _sliceBottom;
  84513. private _detectPointerOnOpaqueOnly;
  84514. private _imageDataCache;
  84515. /**
  84516. * BABYLON.Observable notified when the content is loaded
  84517. */
  84518. onImageLoadedObservable: BABYLON.Observable<Image>;
  84519. /**
  84520. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  84521. */
  84522. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  84523. /**
  84524. * Gets a boolean indicating that the content is loaded
  84525. */
  84526. get isLoaded(): boolean;
  84527. /**
  84528. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  84529. */
  84530. get populateNinePatchSlicesFromImage(): boolean;
  84531. set populateNinePatchSlicesFromImage(value: boolean);
  84532. /**
  84533. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  84534. * Beware using this as this will comsume more memory as the image has to be stored twice
  84535. */
  84536. get detectPointerOnOpaqueOnly(): boolean;
  84537. set detectPointerOnOpaqueOnly(value: boolean);
  84538. /**
  84539. * Gets or sets the left value for slicing (9-patch)
  84540. */
  84541. get sliceLeft(): number;
  84542. set sliceLeft(value: number);
  84543. /**
  84544. * Gets or sets the right value for slicing (9-patch)
  84545. */
  84546. get sliceRight(): number;
  84547. set sliceRight(value: number);
  84548. /**
  84549. * Gets or sets the top value for slicing (9-patch)
  84550. */
  84551. get sliceTop(): number;
  84552. set sliceTop(value: number);
  84553. /**
  84554. * Gets or sets the bottom value for slicing (9-patch)
  84555. */
  84556. get sliceBottom(): number;
  84557. set sliceBottom(value: number);
  84558. /**
  84559. * Gets or sets the left coordinate in the source image
  84560. */
  84561. get sourceLeft(): number;
  84562. set sourceLeft(value: number);
  84563. /**
  84564. * Gets or sets the top coordinate in the source image
  84565. */
  84566. get sourceTop(): number;
  84567. set sourceTop(value: number);
  84568. /**
  84569. * Gets or sets the width to capture in the source image
  84570. */
  84571. get sourceWidth(): number;
  84572. set sourceWidth(value: number);
  84573. /**
  84574. * Gets or sets the height to capture in the source image
  84575. */
  84576. get sourceHeight(): number;
  84577. set sourceHeight(value: number);
  84578. /** Indicates if the format of the image is SVG */
  84579. get isSVG(): boolean;
  84580. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  84581. get svgAttributesComputationCompleted(): boolean;
  84582. /**
  84583. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  84584. * @see https://doc.babylonjs.com/how_to/gui#image
  84585. */
  84586. get autoScale(): boolean;
  84587. set autoScale(value: boolean);
  84588. /** Gets or sets the streching mode used by the image */
  84589. get stretch(): number;
  84590. set stretch(value: number);
  84591. /** @hidden */
  84592. _rotate90(n: number, preserveProperties?: boolean): Image;
  84593. private _handleRotationForSVGImage;
  84594. private _rotate90SourceProperties;
  84595. /**
  84596. * Gets or sets the internal DOM image used to render the control
  84597. */
  84598. set domImage(value: HTMLImageElement);
  84599. get domImage(): HTMLImageElement;
  84600. private _onImageLoaded;
  84601. private _extractNinePatchSliceDataFromImage;
  84602. /**
  84603. * Gets the image source url
  84604. */
  84605. get source(): BABYLON.Nullable<string>;
  84606. /**
  84607. * Gets or sets image source url
  84608. */
  84609. set source(value: BABYLON.Nullable<string>);
  84610. /**
  84611. * Checks for svg document with icon id present
  84612. */
  84613. private _svgCheck;
  84614. /**
  84615. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  84616. * given external svg file and icon id
  84617. */
  84618. private _getSVGAttribs;
  84619. /**
  84620. * Gets or sets the cell width to use when animation sheet is enabled
  84621. * @see https://doc.babylonjs.com/how_to/gui#image
  84622. */
  84623. get cellWidth(): number;
  84624. set cellWidth(value: number);
  84625. /**
  84626. * Gets or sets the cell height to use when animation sheet is enabled
  84627. * @see https://doc.babylonjs.com/how_to/gui#image
  84628. */
  84629. get cellHeight(): number;
  84630. set cellHeight(value: number);
  84631. /**
  84632. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  84633. * @see https://doc.babylonjs.com/how_to/gui#image
  84634. */
  84635. get cellId(): number;
  84636. set cellId(value: number);
  84637. /**
  84638. * Creates a new Image
  84639. * @param name defines the control name
  84640. * @param url defines the image url
  84641. */
  84642. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  84643. /**
  84644. * Tests if a given coordinates belong to the current control
  84645. * @param x defines x coordinate to test
  84646. * @param y defines y coordinate to test
  84647. * @returns true if the coordinates are inside the control
  84648. */
  84649. contains(x: number, y: number): boolean;
  84650. protected _getTypeName(): string;
  84651. /** Force the control to synchronize with its content */
  84652. synchronizeSizeWithContent(): void;
  84653. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84654. private _prepareWorkingCanvasForOpaqueDetection;
  84655. private _drawImage;
  84656. _draw(context: CanvasRenderingContext2D): void;
  84657. private _renderCornerPatch;
  84658. private _renderNinePatch;
  84659. dispose(): void;
  84660. /** STRETCH_NONE */
  84661. static readonly STRETCH_NONE: number;
  84662. /** STRETCH_FILL */
  84663. static readonly STRETCH_FILL: number;
  84664. /** STRETCH_UNIFORM */
  84665. static readonly STRETCH_UNIFORM: number;
  84666. /** STRETCH_EXTEND */
  84667. static readonly STRETCH_EXTEND: number;
  84668. /** NINE_PATCH */
  84669. static readonly STRETCH_NINE_PATCH: number;
  84670. }
  84671. }
  84672. declare module BABYLON.GUI {
  84673. /**
  84674. * Class used to create 2D buttons
  84675. */
  84676. export class Button extends Rectangle {
  84677. name?: string | undefined;
  84678. /**
  84679. * Function called to generate a pointer enter animation
  84680. */
  84681. pointerEnterAnimation: () => void;
  84682. /**
  84683. * Function called to generate a pointer out animation
  84684. */
  84685. pointerOutAnimation: () => void;
  84686. /**
  84687. * Function called to generate a pointer down animation
  84688. */
  84689. pointerDownAnimation: () => void;
  84690. /**
  84691. * Function called to generate a pointer up animation
  84692. */
  84693. pointerUpAnimation: () => void;
  84694. /**
  84695. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  84696. */
  84697. delegatePickingToChildren: boolean;
  84698. private _image;
  84699. /**
  84700. * Returns the image part of the button (if any)
  84701. */
  84702. get image(): BABYLON.Nullable<Image>;
  84703. private _textBlock;
  84704. /**
  84705. * Returns the image part of the button (if any)
  84706. */
  84707. get textBlock(): BABYLON.Nullable<TextBlock>;
  84708. /**
  84709. * Creates a new Button
  84710. * @param name defines the name of the button
  84711. */
  84712. constructor(name?: string | undefined);
  84713. protected _getTypeName(): string;
  84714. /** @hidden */
  84715. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  84716. /** @hidden */
  84717. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  84718. /** @hidden */
  84719. _onPointerOut(target: Control, pi: BABYLON.PointerInfoBase, force?: boolean): void;
  84720. /** @hidden */
  84721. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  84722. /** @hidden */
  84723. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  84724. /**
  84725. * Creates a new button made with an image and a text
  84726. * @param name defines the name of the button
  84727. * @param text defines the text of the button
  84728. * @param imageUrl defines the url of the image
  84729. * @returns a new Button
  84730. */
  84731. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  84732. /**
  84733. * Creates a new button made with an image
  84734. * @param name defines the name of the button
  84735. * @param imageUrl defines the url of the image
  84736. * @returns a new Button
  84737. */
  84738. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  84739. /**
  84740. * Creates a new button made with a text
  84741. * @param name defines the name of the button
  84742. * @param text defines the text of the button
  84743. * @returns a new Button
  84744. */
  84745. static CreateSimpleButton(name: string, text: string): Button;
  84746. /**
  84747. * Creates a new button made with an image and a centered text
  84748. * @param name defines the name of the button
  84749. * @param text defines the text of the button
  84750. * @param imageUrl defines the url of the image
  84751. * @returns a new Button
  84752. */
  84753. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  84754. }
  84755. }
  84756. declare module BABYLON.GUI {
  84757. /**
  84758. * Class used to create a 2D stack panel container
  84759. */
  84760. export class StackPanel extends Container {
  84761. name?: string | undefined;
  84762. private _isVertical;
  84763. private _manualWidth;
  84764. private _manualHeight;
  84765. private _doNotTrackManualChanges;
  84766. /**
  84767. * Gets or sets a boolean indicating that layou warnings should be ignored
  84768. */
  84769. ignoreLayoutWarnings: boolean;
  84770. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  84771. get isVertical(): boolean;
  84772. set isVertical(value: boolean);
  84773. /**
  84774. * Gets or sets panel width.
  84775. * This value should not be set when in horizontal mode as it will be computed automatically
  84776. */
  84777. set width(value: string | number);
  84778. get width(): string | number;
  84779. /**
  84780. * Gets or sets panel height.
  84781. * This value should not be set when in vertical mode as it will be computed automatically
  84782. */
  84783. set height(value: string | number);
  84784. get height(): string | number;
  84785. /**
  84786. * Creates a new StackPanel
  84787. * @param name defines control name
  84788. */
  84789. constructor(name?: string | undefined);
  84790. protected _getTypeName(): string;
  84791. /** @hidden */
  84792. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84793. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84794. protected _postMeasure(): void;
  84795. /**
  84796. * Serializes the current control
  84797. * @param serializationObject defined the JSON serialized object
  84798. */
  84799. serialize(serializationObject: any): void;
  84800. /** @hidden */
  84801. _parseFromContent(serializedObject: any, host: AdvancedDynamicTexture): void;
  84802. }
  84803. }
  84804. declare module BABYLON.GUI {
  84805. /**
  84806. * Class used to represent a 2D checkbox
  84807. */
  84808. export class Checkbox extends Control {
  84809. name?: string | undefined;
  84810. private _isChecked;
  84811. private _background;
  84812. private _checkSizeRatio;
  84813. private _thickness;
  84814. /** Gets or sets border thickness */
  84815. get thickness(): number;
  84816. set thickness(value: number);
  84817. /**
  84818. * BABYLON.Observable raised when isChecked property changes
  84819. */
  84820. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  84821. /** Gets or sets a value indicating the ratio between overall size and check size */
  84822. get checkSizeRatio(): number;
  84823. set checkSizeRatio(value: number);
  84824. /** Gets or sets background color */
  84825. get background(): string;
  84826. set background(value: string);
  84827. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  84828. get isChecked(): boolean;
  84829. set isChecked(value: boolean);
  84830. /**
  84831. * Creates a new CheckBox
  84832. * @param name defines the control name
  84833. */
  84834. constructor(name?: string | undefined);
  84835. protected _getTypeName(): string;
  84836. /** @hidden */
  84837. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  84838. /** @hidden */
  84839. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  84840. /**
  84841. * Utility function to easily create a checkbox with a header
  84842. * @param title defines the label to use for the header
  84843. * @param onValueChanged defines the callback to call when value changes
  84844. * @returns a StackPanel containing the checkbox and a textBlock
  84845. */
  84846. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  84847. }
  84848. }
  84849. declare module BABYLON.GUI {
  84850. /**
  84851. * Class used to store key control properties
  84852. */
  84853. export class KeyPropertySet {
  84854. /** Width */
  84855. width?: string;
  84856. /** Height */
  84857. height?: string;
  84858. /** Left padding */
  84859. paddingLeft?: string;
  84860. /** Right padding */
  84861. paddingRight?: string;
  84862. /** Top padding */
  84863. paddingTop?: string;
  84864. /** Bottom padding */
  84865. paddingBottom?: string;
  84866. /** Foreground color */
  84867. color?: string;
  84868. /** Background color */
  84869. background?: string;
  84870. }
  84871. /**
  84872. * Class used to create virtual keyboard
  84873. */
  84874. export class VirtualKeyboard extends StackPanel {
  84875. /** BABYLON.Observable raised when a key is pressed */
  84876. onKeyPressObservable: BABYLON.Observable<string>;
  84877. /** Gets or sets default key button width */
  84878. defaultButtonWidth: string;
  84879. /** Gets or sets default key button height */
  84880. defaultButtonHeight: string;
  84881. /** Gets or sets default key button left padding */
  84882. defaultButtonPaddingLeft: string;
  84883. /** Gets or sets default key button right padding */
  84884. defaultButtonPaddingRight: string;
  84885. /** Gets or sets default key button top padding */
  84886. defaultButtonPaddingTop: string;
  84887. /** Gets or sets default key button bottom padding */
  84888. defaultButtonPaddingBottom: string;
  84889. /** Gets or sets default key button foreground color */
  84890. defaultButtonColor: string;
  84891. /** Gets or sets default key button background color */
  84892. defaultButtonBackground: string;
  84893. /** Gets or sets shift button foreground color */
  84894. shiftButtonColor: string;
  84895. /** Gets or sets shift button thickness*/
  84896. selectedShiftThickness: number;
  84897. /** Gets shift key state */
  84898. shiftState: number;
  84899. protected _getTypeName(): string;
  84900. private _createKey;
  84901. /**
  84902. * Adds a new row of keys
  84903. * @param keys defines the list of keys to add
  84904. * @param propertySets defines the associated property sets
  84905. */
  84906. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  84907. /**
  84908. * Set the shift key to a specific state
  84909. * @param shiftState defines the new shift state
  84910. */
  84911. applyShiftState(shiftState: number): void;
  84912. private _currentlyConnectedInputText;
  84913. private _connectedInputTexts;
  84914. private _onKeyPressObserver;
  84915. /** Gets the input text control currently attached to the keyboard */
  84916. get connectedInputText(): BABYLON.Nullable<InputText>;
  84917. /**
  84918. * Connects the keyboard with an input text control
  84919. *
  84920. * @param input defines the target control
  84921. */
  84922. connect(input: InputText): void;
  84923. /**
  84924. * Disconnects the keyboard from connected InputText controls
  84925. *
  84926. * @param input optionally defines a target control, otherwise all are disconnected
  84927. */
  84928. disconnect(input?: InputText): void;
  84929. private _removeConnectedInputObservables;
  84930. /**
  84931. * Release all resources
  84932. */
  84933. dispose(): void;
  84934. /**
  84935. * Creates a new keyboard using a default layout
  84936. *
  84937. * @param name defines control name
  84938. * @returns a new VirtualKeyboard
  84939. */
  84940. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  84941. }
  84942. }
  84943. declare module BABYLON.GUI {
  84944. /** @hidden */
  84945. export class TextWrapper {
  84946. private _text;
  84947. private _characters;
  84948. get text(): string;
  84949. set text(txt: string);
  84950. get length(): number;
  84951. removePart(idxStart: number, idxEnd: number, insertTxt?: string): void;
  84952. charAt(idx: number): string;
  84953. substr(from: number, length?: number): string;
  84954. substring(from: number, to?: number): string;
  84955. isWord(index: number): boolean;
  84956. }
  84957. }
  84958. declare module BABYLON.GUI {
  84959. /**
  84960. * Class used to create input text control
  84961. */
  84962. export class InputText extends Control implements IFocusableControl {
  84963. name?: string | undefined;
  84964. private _textWrapper;
  84965. private _placeholderText;
  84966. private _background;
  84967. private _focusedBackground;
  84968. private _focusedColor;
  84969. private _placeholderColor;
  84970. private _thickness;
  84971. private _margin;
  84972. private _autoStretchWidth;
  84973. private _maxWidth;
  84974. private _isFocused;
  84975. private _blinkTimeout;
  84976. private _blinkIsEven;
  84977. private _cursorOffset;
  84978. private _scrollLeft;
  84979. private _textWidth;
  84980. private _clickedCoordinate;
  84981. private _deadKey;
  84982. private _addKey;
  84983. private _currentKey;
  84984. private _isTextHighlightOn;
  84985. private _textHighlightColor;
  84986. private _highligherOpacity;
  84987. private _highlightedText;
  84988. private _startHighlightIndex;
  84989. private _endHighlightIndex;
  84990. private _cursorIndex;
  84991. private _onFocusSelectAll;
  84992. private _isPointerDown;
  84993. private _onClipboardObserver;
  84994. private _onPointerDblTapObserver;
  84995. /** @hidden */
  84996. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  84997. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  84998. promptMessage: string;
  84999. /** Force disable prompt on mobile device */
  85000. disableMobilePrompt: boolean;
  85001. /** BABYLON.Observable raised when the text changes */
  85002. onTextChangedObservable: BABYLON.Observable<InputText>;
  85003. /** BABYLON.Observable raised just before an entered character is to be added */
  85004. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  85005. /** BABYLON.Observable raised when the control gets the focus */
  85006. onFocusObservable: BABYLON.Observable<InputText>;
  85007. /** BABYLON.Observable raised when the control loses the focus */
  85008. onBlurObservable: BABYLON.Observable<InputText>;
  85009. /**Observable raised when the text is highlighted */
  85010. onTextHighlightObservable: BABYLON.Observable<InputText>;
  85011. /**Observable raised when copy event is triggered */
  85012. onTextCopyObservable: BABYLON.Observable<InputText>;
  85013. /** BABYLON.Observable raised when cut event is triggered */
  85014. onTextCutObservable: BABYLON.Observable<InputText>;
  85015. /** BABYLON.Observable raised when paste event is triggered */
  85016. onTextPasteObservable: BABYLON.Observable<InputText>;
  85017. /** BABYLON.Observable raised when a key event was processed */
  85018. onKeyboardEventProcessedObservable: BABYLON.Observable<BABYLON.IKeyboardEvent>;
  85019. /** Gets or sets the maximum width allowed by the control */
  85020. get maxWidth(): string | number;
  85021. /** Gets the maximum width allowed by the control in pixels */
  85022. get maxWidthInPixels(): number;
  85023. set maxWidth(value: string | number);
  85024. /** Gets or sets the text highlighter transparency; default: 0.4 */
  85025. get highligherOpacity(): number;
  85026. set highligherOpacity(value: number);
  85027. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  85028. get onFocusSelectAll(): boolean;
  85029. set onFocusSelectAll(value: boolean);
  85030. /** Gets or sets the text hightlight color */
  85031. get textHighlightColor(): string;
  85032. set textHighlightColor(value: string);
  85033. /** Gets or sets control margin */
  85034. get margin(): string;
  85035. /** Gets control margin in pixels */
  85036. get marginInPixels(): number;
  85037. set margin(value: string);
  85038. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  85039. get autoStretchWidth(): boolean;
  85040. set autoStretchWidth(value: boolean);
  85041. /** Gets or sets border thickness */
  85042. get thickness(): number;
  85043. set thickness(value: number);
  85044. /** Gets or sets the background color when focused */
  85045. get focusedBackground(): string;
  85046. set focusedBackground(value: string);
  85047. /** Gets or sets the background color when focused */
  85048. get focusedColor(): string;
  85049. set focusedColor(value: string);
  85050. /** Gets or sets the background color */
  85051. get background(): string;
  85052. set background(value: string);
  85053. /** Gets or sets the placeholder color */
  85054. get placeholderColor(): string;
  85055. set placeholderColor(value: string);
  85056. /** Gets or sets the text displayed when the control is empty */
  85057. get placeholderText(): string;
  85058. set placeholderText(value: string);
  85059. /** Gets or sets the dead key flag */
  85060. get deadKey(): boolean;
  85061. set deadKey(flag: boolean);
  85062. /** Gets or sets the highlight text */
  85063. get highlightedText(): string;
  85064. set highlightedText(text: string);
  85065. /** Gets or sets if the current key should be added */
  85066. get addKey(): boolean;
  85067. set addKey(flag: boolean);
  85068. /** Gets or sets the value of the current key being entered */
  85069. get currentKey(): string;
  85070. set currentKey(key: string);
  85071. /** Gets or sets the text displayed in the control */
  85072. get text(): string;
  85073. set text(value: string);
  85074. private _textHasChanged;
  85075. /** Gets or sets control width */
  85076. get width(): string | number;
  85077. set width(value: string | number);
  85078. /**
  85079. * Creates a new InputText
  85080. * @param name defines the control name
  85081. * @param text defines the text of the control
  85082. */
  85083. constructor(name?: string | undefined, text?: string);
  85084. /** @hidden */
  85085. onBlur(): void;
  85086. /** @hidden */
  85087. onFocus(): void;
  85088. /**
  85089. * Function to focus an inputText programmatically
  85090. */
  85091. focus(): void;
  85092. /**
  85093. * Function to unfocus an inputText programmatically
  85094. */
  85095. blur(): void;
  85096. protected _getTypeName(): string;
  85097. /**
  85098. * Function called to get the list of controls that should not steal the focus from this control
  85099. * @returns an array of controls
  85100. */
  85101. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  85102. /** @hidden */
  85103. processKey(keyCode: number, key?: string, evt?: BABYLON.IKeyboardEvent): void;
  85104. /** @hidden */
  85105. private _updateValueFromCursorIndex;
  85106. /** @hidden */
  85107. private _processDblClick;
  85108. /** @hidden */
  85109. private _selectAllText;
  85110. /**
  85111. * Handles the keyboard event
  85112. * @param evt Defines the KeyboardEvent
  85113. */
  85114. processKeyboard(evt: BABYLON.IKeyboardEvent): void;
  85115. /** @hidden */
  85116. private _onCopyText;
  85117. /** @hidden */
  85118. private _onCutText;
  85119. /** @hidden */
  85120. private _onPasteText;
  85121. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  85122. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  85123. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  85124. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  85125. protected _beforeRenderText(textWrapper: TextWrapper): TextWrapper;
  85126. dispose(): void;
  85127. }
  85128. }
  85129. declare module BABYLON.GUI {
  85130. /**
  85131. * Class used to create a 2D grid container
  85132. */
  85133. export class Grid extends Container {
  85134. name?: string | undefined;
  85135. private _rowDefinitions;
  85136. private _columnDefinitions;
  85137. private _cells;
  85138. private _childControls;
  85139. /**
  85140. * Gets the number of columns
  85141. */
  85142. get columnCount(): number;
  85143. /**
  85144. * Gets the number of rows
  85145. */
  85146. get rowCount(): number;
  85147. /** Gets the list of children */
  85148. get children(): Control[];
  85149. /** Gets the list of cells (e.g. the containers) */
  85150. get cells(): {
  85151. [key: string]: Container;
  85152. };
  85153. /**
  85154. * Gets the definition of a specific row
  85155. * @param index defines the index of the row
  85156. * @returns the row definition
  85157. */
  85158. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  85159. /**
  85160. * Gets the definition of a specific column
  85161. * @param index defines the index of the column
  85162. * @returns the column definition
  85163. */
  85164. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  85165. /**
  85166. * Adds a new row to the grid
  85167. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  85168. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  85169. * @returns the current grid
  85170. */
  85171. addRowDefinition(height: number, isPixel?: boolean): Grid;
  85172. /**
  85173. * Adds a new column to the grid
  85174. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  85175. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  85176. * @returns the current grid
  85177. */
  85178. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  85179. /**
  85180. * Update a row definition
  85181. * @param index defines the index of the row to update
  85182. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  85183. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  85184. * @returns the current grid
  85185. */
  85186. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  85187. /**
  85188. * Update a column definition
  85189. * @param index defines the index of the column to update
  85190. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  85191. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  85192. * @returns the current grid
  85193. */
  85194. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  85195. /**
  85196. * Gets the list of children stored in a specific cell
  85197. * @param row defines the row to check
  85198. * @param column defines the column to check
  85199. * @returns the list of controls
  85200. */
  85201. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  85202. /**
  85203. * Gets a string representing the child cell info (row x column)
  85204. * @param child defines the control to get info from
  85205. * @returns a string containing the child cell info (row x column)
  85206. */
  85207. getChildCellInfo(child: Control): string;
  85208. private _removeCell;
  85209. private _offsetCell;
  85210. /**
  85211. * Remove a column definition at specified index
  85212. * @param index defines the index of the column to remove
  85213. * @returns the current grid
  85214. */
  85215. removeColumnDefinition(index: number): Grid;
  85216. /**
  85217. * Remove a row definition at specified index
  85218. * @param index defines the index of the row to remove
  85219. * @returns the current grid
  85220. */
  85221. removeRowDefinition(index: number): Grid;
  85222. /**
  85223. * Adds a new control to the current grid
  85224. * @param control defines the control to add
  85225. * @param row defines the row where to add the control (0 by default)
  85226. * @param column defines the column where to add the control (0 by default)
  85227. * @returns the current grid
  85228. */
  85229. addControl(control: Control, row?: number, column?: number): Grid;
  85230. /**
  85231. * Removes a control from the current container
  85232. * @param control defines the control to remove
  85233. * @returns the current container
  85234. */
  85235. removeControl(control: Control): Container;
  85236. /**
  85237. * Creates a new Grid
  85238. * @param name defines control name
  85239. */
  85240. constructor(name?: string | undefined);
  85241. protected _getTypeName(): string;
  85242. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  85243. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  85244. _flagDescendantsAsMatrixDirty(): void;
  85245. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  85246. /** Releases associated resources */
  85247. dispose(): void;
  85248. }
  85249. }
  85250. declare module BABYLON.GUI {
  85251. /** Class used to create color pickers */
  85252. export class ColorPicker extends Control {
  85253. name?: string | undefined;
  85254. private static _Epsilon;
  85255. private _colorWheelCanvas;
  85256. private _value;
  85257. private _tmpColor;
  85258. private _pointerStartedOnSquare;
  85259. private _pointerStartedOnWheel;
  85260. private _squareLeft;
  85261. private _squareTop;
  85262. private _squareSize;
  85263. private _h;
  85264. private _s;
  85265. private _v;
  85266. private _lastPointerDownID;
  85267. /**
  85268. * BABYLON.Observable raised when the value changes
  85269. */
  85270. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  85271. /** Gets or sets the color of the color picker */
  85272. get value(): BABYLON.Color3;
  85273. set value(value: BABYLON.Color3);
  85274. /**
  85275. * Gets or sets control width
  85276. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  85277. */
  85278. get width(): string | number;
  85279. set width(value: string | number);
  85280. /**
  85281. * Gets or sets control height
  85282. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  85283. */
  85284. get height(): string | number;
  85285. /** Gets or sets control height */
  85286. set height(value: string | number);
  85287. /** Gets or sets control size */
  85288. get size(): string | number;
  85289. set size(value: string | number);
  85290. /**
  85291. * Creates a new ColorPicker
  85292. * @param name defines the control name
  85293. */
  85294. constructor(name?: string | undefined);
  85295. protected _getTypeName(): string;
  85296. /** @hidden */
  85297. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  85298. private _updateSquareProps;
  85299. private _drawGradientSquare;
  85300. private _drawCircle;
  85301. private _createColorWheelCanvas;
  85302. /** @hidden */
  85303. _draw(context: CanvasRenderingContext2D): void;
  85304. private _pointerIsDown;
  85305. private _updateValueFromPointer;
  85306. private _isPointOnSquare;
  85307. private _isPointOnWheel;
  85308. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  85309. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  85310. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  85311. _onCanvasBlur(): void;
  85312. /**
  85313. * This function expands the color picker by creating a color picker dialog with manual
  85314. * color value input and the ability to save colors into an array to be used later in
  85315. * subsequent launches of the dialogue.
  85316. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  85317. * @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.
  85318. * @returns picked color as a hex string and the saved colors array as hex strings.
  85319. */
  85320. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  85321. pickerWidth?: string;
  85322. pickerHeight?: string;
  85323. headerHeight?: string;
  85324. lastColor?: string;
  85325. swatchLimit?: number;
  85326. numSwatchesPerLine?: number;
  85327. savedColors?: Array<string>;
  85328. }): Promise<{
  85329. savedColors?: string[];
  85330. pickedColor: string;
  85331. }>;
  85332. }
  85333. }
  85334. declare module BABYLON.GUI {
  85335. /** Class used to create 2D ellipse containers */
  85336. export class Ellipse extends Container {
  85337. name?: string | undefined;
  85338. private _thickness;
  85339. /** Gets or sets border thickness */
  85340. get thickness(): number;
  85341. set thickness(value: number);
  85342. /**
  85343. * Creates a new Ellipse
  85344. * @param name defines the control name
  85345. */
  85346. constructor(name?: string | undefined);
  85347. protected _getTypeName(): string;
  85348. protected _localDraw(context: CanvasRenderingContext2D): void;
  85349. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  85350. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  85351. }
  85352. }
  85353. declare module BABYLON.GUI {
  85354. /**
  85355. * Class used to create a focusable button that can easily handle keyboard events
  85356. */
  85357. export class FocusableButton extends Button implements IFocusableControl {
  85358. name?: string | undefined;
  85359. /** Highlight color when button is focused */
  85360. focusedColor: BABYLON.Nullable<string>;
  85361. private _isFocused;
  85362. private _unfocusedColor;
  85363. /** BABYLON.Observable raised when the control gets the focus */
  85364. onFocusObservable: BABYLON.Observable<Button>;
  85365. /** BABYLON.Observable raised when the control loses the focus */
  85366. onBlurObservable: BABYLON.Observable<Button>;
  85367. /** BABYLON.Observable raised when a key event was processed */
  85368. onKeyboardEventProcessedObservable: BABYLON.Observable<BABYLON.IKeyboardEvent>;
  85369. constructor(name?: string | undefined);
  85370. /** @hidden */
  85371. onBlur(): void;
  85372. /** @hidden */
  85373. onFocus(): void;
  85374. /**
  85375. * Function called to get the list of controls that should not steal the focus from this control
  85376. * @returns an array of controls
  85377. */
  85378. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  85379. /**
  85380. * Function to focus a button programmatically
  85381. */
  85382. focus(): void;
  85383. /**
  85384. * Function to unfocus a button programmatically
  85385. */
  85386. blur(): void;
  85387. /**
  85388. * Handles the keyboard event
  85389. * @param evt Defines the KeyboardEvent
  85390. */
  85391. processKeyboard(evt: BABYLON.IKeyboardEvent): void;
  85392. /** @hidden */
  85393. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  85394. /** @hidden */
  85395. displose(): void;
  85396. }
  85397. }
  85398. declare module BABYLON.GUI {
  85399. /**
  85400. * Class used to create a password control
  85401. */
  85402. export class InputPassword extends InputText {
  85403. protected _beforeRenderText(textWrapper: TextWrapper): TextWrapper;
  85404. }
  85405. }
  85406. declare module BABYLON.GUI {
  85407. /** Class used to render 2D lines */
  85408. export class Line extends Control {
  85409. name?: string | undefined;
  85410. private _lineWidth;
  85411. private _x1;
  85412. private _y1;
  85413. private _x2;
  85414. private _y2;
  85415. private _dash;
  85416. private _connectedControl;
  85417. private _connectedControlDirtyObserver;
  85418. /** Gets or sets the dash pattern */
  85419. get dash(): Array<number>;
  85420. set dash(value: Array<number>);
  85421. /** Gets or sets the control connected with the line end */
  85422. get connectedControl(): Control;
  85423. set connectedControl(value: Control);
  85424. /** Gets or sets start coordinates on X axis */
  85425. get x1(): string | number;
  85426. set x1(value: string | number);
  85427. /** Gets or sets start coordinates on Y axis */
  85428. get y1(): string | number;
  85429. set y1(value: string | number);
  85430. /** Gets or sets end coordinates on X axis */
  85431. get x2(): string | number;
  85432. set x2(value: string | number);
  85433. /** Gets or sets end coordinates on Y axis */
  85434. get y2(): string | number;
  85435. set y2(value: string | number);
  85436. /** Gets or sets line width */
  85437. get lineWidth(): number;
  85438. set lineWidth(value: number);
  85439. /** Gets or sets horizontal alignment */
  85440. set horizontalAlignment(value: number);
  85441. /** Gets or sets vertical alignment */
  85442. set verticalAlignment(value: number);
  85443. private get _effectiveX2();
  85444. private get _effectiveY2();
  85445. /**
  85446. * Creates a new Line
  85447. * @param name defines the control name
  85448. */
  85449. constructor(name?: string | undefined);
  85450. protected _getTypeName(): string;
  85451. _draw(context: CanvasRenderingContext2D): void;
  85452. _measure(): void;
  85453. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  85454. /**
  85455. * Move one end of the line given 3D cartesian coordinates.
  85456. * @param position Targeted world position
  85457. * @param scene BABYLON.Scene
  85458. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  85459. */
  85460. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  85461. /**
  85462. * Move one end of the line to a position in screen absolute space.
  85463. * @param projectedPosition Position in screen absolute space (X, Y)
  85464. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  85465. */
  85466. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  85467. }
  85468. }
  85469. declare module BABYLON.GUI {
  85470. /**
  85471. * Class used to store a point for a MultiLine object.
  85472. * The point can be pure 2D coordinates, a mesh or a control
  85473. */
  85474. export class MultiLinePoint {
  85475. private _multiLine;
  85476. private _x;
  85477. private _y;
  85478. private _control;
  85479. private _mesh;
  85480. private _controlObserver;
  85481. private _meshObserver;
  85482. /** @hidden */
  85483. _point: BABYLON.Vector3;
  85484. /**
  85485. * Creates a new MultiLinePoint
  85486. * @param multiLine defines the source MultiLine object
  85487. */
  85488. constructor(multiLine: MultiLine);
  85489. /** Gets or sets x coordinate */
  85490. get x(): string | number;
  85491. set x(value: string | number);
  85492. /** Gets or sets y coordinate */
  85493. get y(): string | number;
  85494. set y(value: string | number);
  85495. /** Gets or sets the control associated with this point */
  85496. get control(): BABYLON.Nullable<Control>;
  85497. set control(value: BABYLON.Nullable<Control>);
  85498. /** Gets or sets the mesh associated with this point */
  85499. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  85500. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  85501. /** Resets links */
  85502. resetLinks(): void;
  85503. /**
  85504. * Gets a translation vector with Z component
  85505. * @returns the translation vector
  85506. */
  85507. translate(): BABYLON.Vector3;
  85508. private _translatePoint;
  85509. /** Release associated resources */
  85510. dispose(): void;
  85511. }
  85512. }
  85513. declare module BABYLON.GUI {
  85514. /**
  85515. * Class used to create multi line control
  85516. */
  85517. export class MultiLine extends Control {
  85518. name?: string | undefined;
  85519. private _lineWidth;
  85520. private _dash;
  85521. private _points;
  85522. private _minX;
  85523. private _minY;
  85524. private _maxX;
  85525. private _maxY;
  85526. /**
  85527. * Creates a new MultiLine
  85528. * @param name defines the control name
  85529. */
  85530. constructor(name?: string | undefined);
  85531. /** Gets or sets dash pattern */
  85532. get dash(): Array<number>;
  85533. set dash(value: Array<number>);
  85534. /**
  85535. * Gets point stored at specified index
  85536. * @param index defines the index to look for
  85537. * @returns the requested point if found
  85538. */
  85539. getAt(index: number): MultiLinePoint;
  85540. /** Function called when a point is updated */
  85541. onPointUpdate: () => void;
  85542. /**
  85543. * Adds new points to the point collection
  85544. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  85545. * @returns the list of created MultiLinePoint
  85546. */
  85547. add(...items: (AbstractMesh | Control | {
  85548. x: string | number;
  85549. y: string | number;
  85550. })[]): MultiLinePoint[];
  85551. /**
  85552. * Adds a new point to the point collection
  85553. * @param item defines the item (mesh, control or 2d coordiantes) to add
  85554. * @returns the created MultiLinePoint
  85555. */
  85556. push(item?: (AbstractMesh | Control | {
  85557. x: string | number;
  85558. y: string | number;
  85559. })): MultiLinePoint;
  85560. /**
  85561. * Remove a specific value or point from the active point collection
  85562. * @param value defines the value or point to remove
  85563. */
  85564. remove(value: number | MultiLinePoint): void;
  85565. /**
  85566. * Resets this object to initial state (no point)
  85567. */
  85568. reset(): void;
  85569. /**
  85570. * Resets all links
  85571. */
  85572. resetLinks(): void;
  85573. /** Gets or sets line width */
  85574. get lineWidth(): number;
  85575. set lineWidth(value: number);
  85576. set horizontalAlignment(value: number);
  85577. set verticalAlignment(value: number);
  85578. protected _getTypeName(): string;
  85579. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  85580. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  85581. _measure(): void;
  85582. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  85583. dispose(): void;
  85584. }
  85585. }
  85586. declare module BABYLON.GUI {
  85587. /**
  85588. * Class used to create radio button controls
  85589. */
  85590. export class RadioButton extends Control {
  85591. name?: string | undefined;
  85592. private _isChecked;
  85593. private _background;
  85594. private _checkSizeRatio;
  85595. private _thickness;
  85596. /** Gets or sets border thickness */
  85597. get thickness(): number;
  85598. set thickness(value: number);
  85599. /** Gets or sets group name */
  85600. group: string;
  85601. /** BABYLON.Observable raised when isChecked is changed */
  85602. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  85603. /** Gets or sets a value indicating the ratio between overall size and check size */
  85604. get checkSizeRatio(): number;
  85605. set checkSizeRatio(value: number);
  85606. /** Gets or sets background color */
  85607. get background(): string;
  85608. set background(value: string);
  85609. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  85610. get isChecked(): boolean;
  85611. set isChecked(value: boolean);
  85612. /**
  85613. * Creates a new RadioButton
  85614. * @param name defines the control name
  85615. */
  85616. constructor(name?: string | undefined);
  85617. protected _getTypeName(): string;
  85618. _draw(context: CanvasRenderingContext2D): void;
  85619. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  85620. /**
  85621. * Utility function to easily create a radio button with a header
  85622. * @param title defines the label to use for the header
  85623. * @param group defines the group to use for the radio button
  85624. * @param isChecked defines the initial state of the radio button
  85625. * @param onValueChanged defines the callback to call when value changes
  85626. * @returns a StackPanel containing the radio button and a textBlock
  85627. */
  85628. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  85629. }
  85630. }
  85631. declare module BABYLON.GUI {
  85632. /**
  85633. * Class used to create slider controls
  85634. */
  85635. export class BaseSlider extends Control {
  85636. name?: string | undefined;
  85637. protected _thumbWidth: ValueAndUnit;
  85638. private _minimum;
  85639. private _maximum;
  85640. private _value;
  85641. private _isVertical;
  85642. protected _barOffset: ValueAndUnit;
  85643. private _isThumbClamped;
  85644. protected _displayThumb: boolean;
  85645. private _step;
  85646. private _lastPointerDownID;
  85647. protected _effectiveBarOffset: number;
  85648. protected _renderLeft: number;
  85649. protected _renderTop: number;
  85650. protected _renderWidth: number;
  85651. protected _renderHeight: number;
  85652. protected _backgroundBoxLength: number;
  85653. protected _backgroundBoxThickness: number;
  85654. protected _effectiveThumbThickness: number;
  85655. /** BABYLON.Observable raised when the sldier value changes */
  85656. onValueChangedObservable: BABYLON.Observable<number>;
  85657. /** Gets or sets a boolean indicating if the thumb must be rendered */
  85658. get displayThumb(): boolean;
  85659. set displayThumb(value: boolean);
  85660. /** Gets or sets a step to apply to values (0 by default) */
  85661. get step(): number;
  85662. set step(value: number);
  85663. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  85664. get barOffset(): string | number;
  85665. /** Gets main bar offset in pixels*/
  85666. get barOffsetInPixels(): number;
  85667. set barOffset(value: string | number);
  85668. /** Gets or sets thumb width */
  85669. get thumbWidth(): string | number;
  85670. /** Gets thumb width in pixels */
  85671. get thumbWidthInPixels(): number;
  85672. set thumbWidth(value: string | number);
  85673. /** Gets or sets minimum value */
  85674. get minimum(): number;
  85675. set minimum(value: number);
  85676. /** Gets or sets maximum value */
  85677. get maximum(): number;
  85678. set maximum(value: number);
  85679. /** Gets or sets current value */
  85680. get value(): number;
  85681. set value(value: number);
  85682. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  85683. get isVertical(): boolean;
  85684. set isVertical(value: boolean);
  85685. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  85686. get isThumbClamped(): boolean;
  85687. set isThumbClamped(value: boolean);
  85688. /**
  85689. * Creates a new BaseSlider
  85690. * @param name defines the control name
  85691. */
  85692. constructor(name?: string | undefined);
  85693. protected _getTypeName(): string;
  85694. protected _getThumbPosition(): number;
  85695. protected _getThumbThickness(type: string): number;
  85696. protected _prepareRenderingData(type: string): void;
  85697. private _pointerIsDown;
  85698. /** @hidden */
  85699. protected _updateValueFromPointer(x: number, y: number): void;
  85700. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  85701. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  85702. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  85703. _onCanvasBlur(): void;
  85704. }
  85705. }
  85706. declare module BABYLON.GUI {
  85707. /**
  85708. * Class used to create slider controls
  85709. */
  85710. export class Slider extends BaseSlider {
  85711. name?: string | undefined;
  85712. private _background;
  85713. private _borderColor;
  85714. private _thumbColor;
  85715. private _isThumbCircle;
  85716. protected _displayValueBar: boolean;
  85717. /** Gets or sets a boolean indicating if the value bar must be rendered */
  85718. get displayValueBar(): boolean;
  85719. set displayValueBar(value: boolean);
  85720. /** Gets or sets border color */
  85721. get borderColor(): string;
  85722. set borderColor(value: string);
  85723. /** Gets or sets background color */
  85724. get background(): string;
  85725. set background(value: string);
  85726. /** Gets or sets thumb's color */
  85727. get thumbColor(): string;
  85728. set thumbColor(value: string);
  85729. /** Gets or sets a boolean indicating if the thumb should be round or square */
  85730. get isThumbCircle(): boolean;
  85731. set isThumbCircle(value: boolean);
  85732. /**
  85733. * Creates a new Slider
  85734. * @param name defines the control name
  85735. */
  85736. constructor(name?: string | undefined);
  85737. protected _getTypeName(): string;
  85738. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  85739. }
  85740. }
  85741. declare module BABYLON.GUI {
  85742. /** Class used to create a RadioGroup
  85743. * which contains groups of radio buttons
  85744. */
  85745. export class SelectorGroup {
  85746. /** name of SelectorGroup */
  85747. name: string;
  85748. private _groupPanel;
  85749. private _selectors;
  85750. private _groupHeader;
  85751. /**
  85752. * Creates a new SelectorGroup
  85753. * @param name of group, used as a group heading
  85754. */
  85755. constructor(
  85756. /** name of SelectorGroup */
  85757. name: string);
  85758. /** Gets the groupPanel of the SelectorGroup */
  85759. get groupPanel(): StackPanel;
  85760. /** Gets the selectors array */
  85761. get selectors(): StackPanel[];
  85762. /** Gets and sets the group header */
  85763. get header(): string;
  85764. set header(label: string);
  85765. /** @hidden */
  85766. private _addGroupHeader;
  85767. /** @hidden*/
  85768. _getSelector(selectorNb: number): StackPanel | undefined;
  85769. /** Removes the selector at the given position
  85770. * @param selectorNb the position of the selector within the group
  85771. */
  85772. removeSelector(selectorNb: number): void;
  85773. }
  85774. /** Class used to create a CheckboxGroup
  85775. * which contains groups of checkbox buttons
  85776. */
  85777. export class CheckboxGroup extends SelectorGroup {
  85778. /** Adds a checkbox as a control
  85779. * @param text is the label for the selector
  85780. * @param func is the function called when the Selector is checked
  85781. * @param checked is true when Selector is checked
  85782. */
  85783. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  85784. /** @hidden */
  85785. _setSelectorLabel(selectorNb: number, label: string): void;
  85786. /** @hidden */
  85787. _setSelectorLabelColor(selectorNb: number, color: string): void;
  85788. /** @hidden */
  85789. _setSelectorButtonColor(selectorNb: number, color: string): void;
  85790. /** @hidden */
  85791. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  85792. }
  85793. /** Class used to create a RadioGroup
  85794. * which contains groups of radio buttons
  85795. */
  85796. export class RadioGroup extends SelectorGroup {
  85797. private _selectNb;
  85798. /** Adds a radio button as a control
  85799. * @param label is the label for the selector
  85800. * @param func is the function called when the Selector is checked
  85801. * @param checked is true when Selector is checked
  85802. */
  85803. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  85804. /** @hidden */
  85805. _setSelectorLabel(selectorNb: number, label: string): void;
  85806. /** @hidden */
  85807. _setSelectorLabelColor(selectorNb: number, color: string): void;
  85808. /** @hidden */
  85809. _setSelectorButtonColor(selectorNb: number, color: string): void;
  85810. /** @hidden */
  85811. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  85812. }
  85813. /** Class used to create a SliderGroup
  85814. * which contains groups of slider buttons
  85815. */
  85816. export class SliderGroup extends SelectorGroup {
  85817. /**
  85818. * Adds a slider to the SelectorGroup
  85819. * @param label is the label for the SliderBar
  85820. * @param func is the function called when the Slider moves
  85821. * @param unit is a string describing the units used, eg degrees or metres
  85822. * @param min is the minimum value for the Slider
  85823. * @param max is the maximum value for the Slider
  85824. * @param value is the start value for the Slider between min and max
  85825. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  85826. */
  85827. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  85828. /** @hidden */
  85829. _setSelectorLabel(selectorNb: number, label: string): void;
  85830. /** @hidden */
  85831. _setSelectorLabelColor(selectorNb: number, color: string): void;
  85832. /** @hidden */
  85833. _setSelectorButtonColor(selectorNb: number, color: string): void;
  85834. /** @hidden */
  85835. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  85836. }
  85837. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  85838. * @see https://doc.babylonjs.com/how_to/selector
  85839. */
  85840. export class SelectionPanel extends Rectangle {
  85841. /** name of SelectionPanel */
  85842. name: string;
  85843. /** an array of SelectionGroups */
  85844. groups: SelectorGroup[];
  85845. private _panel;
  85846. private _buttonColor;
  85847. private _buttonBackground;
  85848. private _headerColor;
  85849. private _barColor;
  85850. private _barHeight;
  85851. private _spacerHeight;
  85852. private _labelColor;
  85853. private _groups;
  85854. private _bars;
  85855. /**
  85856. * Creates a new SelectionPanel
  85857. * @param name of SelectionPanel
  85858. * @param groups is an array of SelectionGroups
  85859. */
  85860. constructor(
  85861. /** name of SelectionPanel */
  85862. name: string,
  85863. /** an array of SelectionGroups */
  85864. groups?: SelectorGroup[]);
  85865. protected _getTypeName(): string;
  85866. /** Gets the (stack) panel of the SelectionPanel */
  85867. get panel(): StackPanel;
  85868. /** Gets or sets the headerColor */
  85869. get headerColor(): string;
  85870. set headerColor(color: string);
  85871. private _setHeaderColor;
  85872. /** Gets or sets the button color */
  85873. get buttonColor(): string;
  85874. set buttonColor(color: string);
  85875. private _setbuttonColor;
  85876. /** Gets or sets the label color */
  85877. get labelColor(): string;
  85878. set labelColor(color: string);
  85879. private _setLabelColor;
  85880. /** Gets or sets the button background */
  85881. get buttonBackground(): string;
  85882. set buttonBackground(color: string);
  85883. private _setButtonBackground;
  85884. /** Gets or sets the color of separator bar */
  85885. get barColor(): string;
  85886. set barColor(color: string);
  85887. private _setBarColor;
  85888. /** Gets or sets the height of separator bar */
  85889. get barHeight(): string;
  85890. set barHeight(value: string);
  85891. private _setBarHeight;
  85892. /** Gets or sets the height of spacers*/
  85893. get spacerHeight(): string;
  85894. set spacerHeight(value: string);
  85895. private _setSpacerHeight;
  85896. /** Adds a bar between groups */
  85897. private _addSpacer;
  85898. /** Add a group to the selection panel
  85899. * @param group is the selector group to add
  85900. */
  85901. addGroup(group: SelectorGroup): void;
  85902. /** Remove the group from the given position
  85903. * @param groupNb is the position of the group in the list
  85904. */
  85905. removeGroup(groupNb: number): void;
  85906. /** Change a group header label
  85907. * @param label is the new group header label
  85908. * @param groupNb is the number of the group to relabel
  85909. * */
  85910. setHeaderName(label: string, groupNb: number): void;
  85911. /** Change selector label to the one given
  85912. * @param label is the new selector label
  85913. * @param groupNb is the number of the groupcontaining the selector
  85914. * @param selectorNb is the number of the selector within a group to relabel
  85915. * */
  85916. relabel(label: string, groupNb: number, selectorNb: number): void;
  85917. /** For a given group position remove the selector at the given position
  85918. * @param groupNb is the number of the group to remove the selector from
  85919. * @param selectorNb is the number of the selector within the group
  85920. */
  85921. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  85922. /** For a given group position of correct type add a checkbox button
  85923. * @param groupNb is the number of the group to remove the selector from
  85924. * @param label is the label for the selector
  85925. * @param func is the function called when the Selector is checked
  85926. * @param checked is true when Selector is checked
  85927. */
  85928. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  85929. /** For a given group position of correct type add a radio button
  85930. * @param groupNb is the number of the group to remove the selector from
  85931. * @param label is the label for the selector
  85932. * @param func is the function called when the Selector is checked
  85933. * @param checked is true when Selector is checked
  85934. */
  85935. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  85936. /**
  85937. * For a given slider group add a slider
  85938. * @param groupNb is the number of the group to add the slider to
  85939. * @param label is the label for the Slider
  85940. * @param func is the function called when the Slider moves
  85941. * @param unit is a string describing the units used, eg degrees or metres
  85942. * @param min is the minimum value for the Slider
  85943. * @param max is the maximum value for the Slider
  85944. * @param value is the start value for the Slider between min and max
  85945. * @param onVal is the function used to format the value displayed, eg radians to degrees
  85946. */
  85947. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  85948. }
  85949. }
  85950. declare module BABYLON.GUI {
  85951. /**
  85952. * Class used to hold a the container for ScrollViewer
  85953. * @hidden
  85954. */
  85955. export class _ScrollViewerWindow extends Container {
  85956. parentClientWidth: number;
  85957. parentClientHeight: number;
  85958. private _freezeControls;
  85959. private _parentMeasure;
  85960. private _oldLeft;
  85961. private _oldTop;
  85962. get freezeControls(): boolean;
  85963. set freezeControls(value: boolean);
  85964. private _bucketWidth;
  85965. private _bucketHeight;
  85966. private _buckets;
  85967. private _bucketLen;
  85968. get bucketWidth(): number;
  85969. get bucketHeight(): number;
  85970. setBucketSizes(width: number, height: number): void;
  85971. private _useBuckets;
  85972. private _makeBuckets;
  85973. private _dispatchInBuckets;
  85974. private _updateMeasures;
  85975. private _updateChildrenMeasures;
  85976. private _restoreMeasures;
  85977. /**
  85978. * Creates a new ScrollViewerWindow
  85979. * @param name of ScrollViewerWindow
  85980. */
  85981. constructor(name?: string);
  85982. protected _getTypeName(): string;
  85983. /** @hidden */
  85984. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  85985. /** @hidden */
  85986. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  85987. private _scrollChildren;
  85988. private _scrollChildrenWithBuckets;
  85989. /** @hidden */
  85990. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  85991. protected _postMeasure(): void;
  85992. }
  85993. }
  85994. declare module BABYLON.GUI {
  85995. /**
  85996. * Class used to create slider controls
  85997. */
  85998. export class ScrollBar extends BaseSlider {
  85999. name?: string | undefined;
  86000. private _background;
  86001. private _borderColor;
  86002. private _tempMeasure;
  86003. /** Gets or sets border color */
  86004. get borderColor(): string;
  86005. set borderColor(value: string);
  86006. /** Gets or sets background color */
  86007. get background(): string;
  86008. set background(value: string);
  86009. /**
  86010. * Creates a new Slider
  86011. * @param name defines the control name
  86012. */
  86013. constructor(name?: string | undefined);
  86014. protected _getTypeName(): string;
  86015. protected _getThumbThickness(): number;
  86016. _draw(context: CanvasRenderingContext2D): void;
  86017. private _first;
  86018. private _originX;
  86019. private _originY;
  86020. /** @hidden */
  86021. protected _updateValueFromPointer(x: number, y: number): void;
  86022. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  86023. }
  86024. }
  86025. declare module BABYLON.GUI {
  86026. /**
  86027. * Class used to create slider controls
  86028. */
  86029. export class ImageScrollBar extends BaseSlider {
  86030. name?: string | undefined;
  86031. private _backgroundBaseImage;
  86032. private _backgroundImage;
  86033. private _thumbImage;
  86034. private _thumbBaseImage;
  86035. private _thumbLength;
  86036. private _thumbHeight;
  86037. private _barImageHeight;
  86038. private _tempMeasure;
  86039. /** Number of 90° rotation to apply on the images when in vertical mode */
  86040. num90RotationInVerticalMode: number;
  86041. /**
  86042. * Gets or sets the image used to render the background for horizontal bar
  86043. */
  86044. get backgroundImage(): Image;
  86045. set backgroundImage(value: Image);
  86046. /**
  86047. * Gets or sets the image used to render the thumb
  86048. */
  86049. get thumbImage(): Image;
  86050. set thumbImage(value: Image);
  86051. /**
  86052. * Gets or sets the length of the thumb
  86053. */
  86054. get thumbLength(): number;
  86055. set thumbLength(value: number);
  86056. /**
  86057. * Gets or sets the height of the thumb
  86058. */
  86059. get thumbHeight(): number;
  86060. set thumbHeight(value: number);
  86061. /**
  86062. * Gets or sets the height of the bar image
  86063. */
  86064. get barImageHeight(): number;
  86065. set barImageHeight(value: number);
  86066. /**
  86067. * Creates a new ImageScrollBar
  86068. * @param name defines the control name
  86069. */
  86070. constructor(name?: string | undefined);
  86071. protected _getTypeName(): string;
  86072. protected _getThumbThickness(): number;
  86073. _draw(context: CanvasRenderingContext2D): void;
  86074. private _first;
  86075. private _originX;
  86076. private _originY;
  86077. /** @hidden */
  86078. protected _updateValueFromPointer(x: number, y: number): void;
  86079. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  86080. }
  86081. }
  86082. declare module BABYLON.GUI {
  86083. /**
  86084. * Class used to hold a viewer window and sliders in a grid
  86085. */
  86086. export class ScrollViewer extends Rectangle {
  86087. private _grid;
  86088. private _horizontalBarSpace;
  86089. private _verticalBarSpace;
  86090. private _dragSpace;
  86091. private _horizontalBar;
  86092. private _verticalBar;
  86093. private _barColor;
  86094. private _barBackground;
  86095. private _barImage;
  86096. private _horizontalBarImage;
  86097. private _verticalBarImage;
  86098. private _barBackgroundImage;
  86099. private _horizontalBarBackgroundImage;
  86100. private _verticalBarBackgroundImage;
  86101. private _barSize;
  86102. private _window;
  86103. private _pointerIsOver;
  86104. private _wheelPrecision;
  86105. private _onWheelObserver;
  86106. private _clientWidth;
  86107. private _clientHeight;
  86108. private _useImageBar;
  86109. private _thumbLength;
  86110. private _thumbHeight;
  86111. private _barImageHeight;
  86112. private _horizontalBarImageHeight;
  86113. private _verticalBarImageHeight;
  86114. private _oldWindowContentsWidth;
  86115. private _oldWindowContentsHeight;
  86116. /**
  86117. * Gets the horizontal scrollbar
  86118. */
  86119. get horizontalBar(): ScrollBar | ImageScrollBar;
  86120. /**
  86121. * Gets the vertical scrollbar
  86122. */
  86123. get verticalBar(): ScrollBar | ImageScrollBar;
  86124. /**
  86125. * Adds a new control to the current container
  86126. * @param control defines the control to add
  86127. * @returns the current container
  86128. */
  86129. addControl(control: BABYLON.Nullable<Control>): Container;
  86130. /**
  86131. * Removes a control from the current container
  86132. * @param control defines the control to remove
  86133. * @returns the current container
  86134. */
  86135. removeControl(control: Control): Container;
  86136. /** Gets the list of children */
  86137. get children(): Control[];
  86138. _flagDescendantsAsMatrixDirty(): void;
  86139. /**
  86140. * Freezes or unfreezes the controls in the window.
  86141. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  86142. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  86143. */
  86144. get freezeControls(): boolean;
  86145. set freezeControls(value: boolean);
  86146. /** Gets the bucket width */
  86147. get bucketWidth(): number;
  86148. /** Gets the bucket height */
  86149. get bucketHeight(): number;
  86150. /**
  86151. * Sets the bucket sizes.
  86152. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  86153. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  86154. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  86155. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  86156. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  86157. * used), that's why it is not enabled by default.
  86158. * @param width width of the bucket
  86159. * @param height height of the bucket
  86160. */
  86161. setBucketSizes(width: number, height: number): void;
  86162. private _forceHorizontalBar;
  86163. private _forceVerticalBar;
  86164. /**
  86165. * Forces the horizontal scroll bar to be displayed
  86166. */
  86167. get forceHorizontalBar(): boolean;
  86168. set forceHorizontalBar(value: boolean);
  86169. /**
  86170. * Forces the vertical scroll bar to be displayed
  86171. */
  86172. get forceVerticalBar(): boolean;
  86173. set forceVerticalBar(value: boolean);
  86174. /**
  86175. * Creates a new ScrollViewer
  86176. * @param name of ScrollViewer
  86177. */
  86178. constructor(name?: string, isImageBased?: boolean);
  86179. /** Reset the scroll viewer window to initial size */
  86180. resetWindow(): void;
  86181. protected _getTypeName(): string;
  86182. private _buildClientSizes;
  86183. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  86184. protected _postMeasure(): void;
  86185. /**
  86186. * Gets or sets the mouse wheel precision
  86187. * from 0 to 1 with a default value of 0.05
  86188. * */
  86189. get wheelPrecision(): number;
  86190. set wheelPrecision(value: number);
  86191. /** Gets or sets the scroll bar container background color */
  86192. get scrollBackground(): string;
  86193. set scrollBackground(color: string);
  86194. /** Gets or sets the bar color */
  86195. get barColor(): string;
  86196. set barColor(color: string);
  86197. /** Gets or sets the bar image */
  86198. get thumbImage(): Image;
  86199. set thumbImage(value: Image);
  86200. /** Gets or sets the horizontal bar image */
  86201. get horizontalThumbImage(): Image;
  86202. set horizontalThumbImage(value: Image);
  86203. /** Gets or sets the vertical bar image */
  86204. get verticalThumbImage(): Image;
  86205. set verticalThumbImage(value: Image);
  86206. /** Gets or sets the size of the bar */
  86207. get barSize(): number;
  86208. set barSize(value: number);
  86209. /** Gets or sets the length of the thumb */
  86210. get thumbLength(): number;
  86211. set thumbLength(value: number);
  86212. /** Gets or sets the height of the thumb */
  86213. get thumbHeight(): number;
  86214. set thumbHeight(value: number);
  86215. /** Gets or sets the height of the bar image */
  86216. get barImageHeight(): number;
  86217. set barImageHeight(value: number);
  86218. /** Gets or sets the height of the horizontal bar image */
  86219. get horizontalBarImageHeight(): number;
  86220. set horizontalBarImageHeight(value: number);
  86221. /** Gets or sets the height of the vertical bar image */
  86222. get verticalBarImageHeight(): number;
  86223. set verticalBarImageHeight(value: number);
  86224. /** Gets or sets the bar background */
  86225. get barBackground(): string;
  86226. set barBackground(color: string);
  86227. /** Gets or sets the bar background image */
  86228. get barImage(): Image;
  86229. set barImage(value: Image);
  86230. /** Gets or sets the horizontal bar background image */
  86231. get horizontalBarImage(): Image;
  86232. set horizontalBarImage(value: Image);
  86233. /** Gets or sets the vertical bar background image */
  86234. get verticalBarImage(): Image;
  86235. set verticalBarImage(value: Image);
  86236. private _setWindowPosition;
  86237. /** @hidden */
  86238. private _updateScroller;
  86239. _link(host: AdvancedDynamicTexture): void;
  86240. /** @hidden */
  86241. private _addBar;
  86242. /** @hidden */
  86243. private _attachWheel;
  86244. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  86245. /** Releases associated resources */
  86246. dispose(): void;
  86247. }
  86248. }
  86249. declare module BABYLON.GUI {
  86250. /**
  86251. * Class used to create toggle buttons
  86252. */
  86253. export class ToggleButton extends Rectangle {
  86254. name?: string | undefined;
  86255. /**
  86256. * Function called to generate the toActive animation
  86257. */
  86258. toActiveAnimation: () => void;
  86259. /**
  86260. * Function called to generate the toInactive animation
  86261. */
  86262. toInactiveAnimation: () => void;
  86263. /**
  86264. * Function called to generate a pointer enter animation when the toggle button is active.
  86265. */
  86266. pointerEnterActiveAnimation: () => void;
  86267. /**
  86268. * Function called to generate a pointer out animation when the toggle button is active.
  86269. */
  86270. pointerOutActiveAnimation: () => void;
  86271. /**
  86272. * Function called to generate a pointer down animation when the toggle button is active.
  86273. */
  86274. pointerDownActiveAnimation: () => void;
  86275. /**
  86276. * Function called to generate a pointer up animation when the toggle button is active.
  86277. */
  86278. pointerUpActiveAnimation: () => void;
  86279. /**
  86280. * Function called to generate a pointer enter animation when the toggle button is inactive.
  86281. */
  86282. pointerEnterInactiveAnimation: () => void;
  86283. /**
  86284. * Function called to generate a pointer out animation when the toggle button is inactive.
  86285. */
  86286. pointerOutInactiveAnimation: () => void;
  86287. /**
  86288. * Function called to generate a pointer down animation when the toggle button is inactive.
  86289. */
  86290. pointerDownInactiveAnimation: () => void;
  86291. /**
  86292. * Function called to generate a pointer up animation when the toggle button is inactive.
  86293. */
  86294. pointerUpInactiveAnimation: () => void;
  86295. /** BABYLON.Observable raised when isActive is changed */
  86296. onIsActiveChangedObservable: BABYLON.Observable<boolean>;
  86297. /**
  86298. * 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
  86299. */
  86300. delegatePickingToChildren: boolean;
  86301. private _image;
  86302. /**
  86303. * Returns the ToggleButton's image control if it exists
  86304. */
  86305. get image(): BABYLON.Nullable<Image>;
  86306. private _textBlock;
  86307. /**
  86308. * Returns the ToggleButton's child TextBlock control if it exists
  86309. */
  86310. get textBlock(): BABYLON.Nullable<TextBlock>;
  86311. private _group;
  86312. /** Gets or sets group name this toggle button belongs to */
  86313. get group(): string;
  86314. set group(value: string);
  86315. private _isActive;
  86316. /** Gets or sets a boolean indicating if the toogle button is active or not */
  86317. get isActive(): boolean;
  86318. set isActive(value: boolean);
  86319. /**
  86320. * Creates a new ToggleButton
  86321. * @param name defines the control name
  86322. * @param group defines the toggle group this toggle belongs to
  86323. */
  86324. constructor(name?: string | undefined, group?: string);
  86325. protected _getTypeName(): string;
  86326. /** @hidden */
  86327. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  86328. /** @hidden */
  86329. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  86330. /** @hidden */
  86331. _onPointerOut(target: Control, pi: BABYLON.PointerInfoBase, force?: boolean): void;
  86332. /** @hidden */
  86333. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  86334. /** @hidden */
  86335. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  86336. }
  86337. }
  86338. declare module BABYLON.GUI {
  86339. /** Class used to render a grid */
  86340. export class DisplayGrid extends Control {
  86341. name?: string | undefined;
  86342. private _cellWidth;
  86343. private _cellHeight;
  86344. private _minorLineTickness;
  86345. private _minorLineColor;
  86346. private _majorLineTickness;
  86347. private _majorLineColor;
  86348. private _majorLineFrequency;
  86349. private _background;
  86350. private _displayMajorLines;
  86351. private _displayMinorLines;
  86352. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  86353. get displayMinorLines(): boolean;
  86354. set displayMinorLines(value: boolean);
  86355. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  86356. get displayMajorLines(): boolean;
  86357. set displayMajorLines(value: boolean);
  86358. /** Gets or sets background color (Black by default) */
  86359. get background(): string;
  86360. set background(value: string);
  86361. /** Gets or sets the width of each cell (20 by default) */
  86362. get cellWidth(): number;
  86363. set cellWidth(value: number);
  86364. /** Gets or sets the height of each cell (20 by default) */
  86365. get cellHeight(): number;
  86366. set cellHeight(value: number);
  86367. /** Gets or sets the tickness of minor lines (1 by default) */
  86368. get minorLineTickness(): number;
  86369. set minorLineTickness(value: number);
  86370. /** Gets or sets the color of minor lines (DarkGray by default) */
  86371. get minorLineColor(): string;
  86372. set minorLineColor(value: string);
  86373. /** Gets or sets the tickness of major lines (2 by default) */
  86374. get majorLineTickness(): number;
  86375. set majorLineTickness(value: number);
  86376. /** Gets or sets the color of major lines (White by default) */
  86377. get majorLineColor(): string;
  86378. set majorLineColor(value: string);
  86379. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  86380. get majorLineFrequency(): number;
  86381. set majorLineFrequency(value: number);
  86382. /**
  86383. * Creates a new GridDisplayRectangle
  86384. * @param name defines the control name
  86385. */
  86386. constructor(name?: string | undefined);
  86387. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  86388. protected _getTypeName(): string;
  86389. }
  86390. }
  86391. declare module BABYLON.GUI {
  86392. /**
  86393. * Class used to create slider controls based on images
  86394. */
  86395. export class ImageBasedSlider extends BaseSlider {
  86396. name?: string | undefined;
  86397. private _backgroundImage;
  86398. private _thumbImage;
  86399. private _valueBarImage;
  86400. private _tempMeasure;
  86401. get displayThumb(): boolean;
  86402. set displayThumb(value: boolean);
  86403. /**
  86404. * Gets or sets the image used to render the background
  86405. */
  86406. get backgroundImage(): Image;
  86407. set backgroundImage(value: Image);
  86408. /**
  86409. * Gets or sets the image used to render the value bar
  86410. */
  86411. get valueBarImage(): Image;
  86412. set valueBarImage(value: Image);
  86413. /**
  86414. * Gets or sets the image used to render the thumb
  86415. */
  86416. get thumbImage(): Image;
  86417. set thumbImage(value: Image);
  86418. /**
  86419. * Creates a new ImageBasedSlider
  86420. * @param name defines the control name
  86421. */
  86422. constructor(name?: string | undefined);
  86423. protected _getTypeName(): string;
  86424. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  86425. }
  86426. }
  86427. declare module BABYLON.GUI {
  86428. /**
  86429. * Forcing an export so that this code will execute
  86430. * @hidden
  86431. */
  86432. const name = "Statics";
  86433. }
  86434. declare module BABYLON.GUI {
  86435. /**
  86436. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  86437. */
  86438. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  86439. /**
  86440. * Define the instrumented AdvancedDynamicTexture.
  86441. */
  86442. texture: AdvancedDynamicTexture;
  86443. private _captureRenderTime;
  86444. private _renderTime;
  86445. private _captureLayoutTime;
  86446. private _layoutTime;
  86447. private _onBeginRenderObserver;
  86448. private _onEndRenderObserver;
  86449. private _onBeginLayoutObserver;
  86450. private _onEndLayoutObserver;
  86451. /**
  86452. * Gets the perf counter used to capture render time
  86453. */
  86454. get renderTimeCounter(): BABYLON.PerfCounter;
  86455. /**
  86456. * Gets the perf counter used to capture layout time
  86457. */
  86458. get layoutTimeCounter(): BABYLON.PerfCounter;
  86459. /**
  86460. * Enable or disable the render time capture
  86461. */
  86462. get captureRenderTime(): boolean;
  86463. set captureRenderTime(value: boolean);
  86464. /**
  86465. * Enable or disable the layout time capture
  86466. */
  86467. get captureLayoutTime(): boolean;
  86468. set captureLayoutTime(value: boolean);
  86469. /**
  86470. * Instantiates a new advanced dynamic texture instrumentation.
  86471. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  86472. * @param texture Defines the AdvancedDynamicTexture to instrument
  86473. */
  86474. constructor(
  86475. /**
  86476. * Define the instrumented AdvancedDynamicTexture.
  86477. */
  86478. texture: AdvancedDynamicTexture);
  86479. /**
  86480. * Dispose and release associated resources.
  86481. */
  86482. dispose(): void;
  86483. }
  86484. }
  86485. declare module BABYLON.GUI {
  86486. /**
  86487. * Class used to load GUI via XML.
  86488. */
  86489. export class XmlLoader {
  86490. private _nodes;
  86491. private _nodeTypes;
  86492. private _isLoaded;
  86493. private _objectAttributes;
  86494. private _parentClass;
  86495. /**
  86496. * Create a new xml loader
  86497. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  86498. */
  86499. constructor(parentClass?: null);
  86500. private _getChainElement;
  86501. private _getClassAttribute;
  86502. private _createGuiElement;
  86503. private _parseGrid;
  86504. private _parseElement;
  86505. private _prepareSourceElement;
  86506. private _parseElementsFromSource;
  86507. private _parseXml;
  86508. /**
  86509. * Gets if the loading has finished.
  86510. * @returns whether the loading has finished or not
  86511. */
  86512. isLoaded(): boolean;
  86513. /**
  86514. * Gets a loaded node / control by id.
  86515. * @param id the Controls id set in the xml
  86516. * @returns element of type Control
  86517. */
  86518. getNodeById(id: string): any;
  86519. /**
  86520. * Gets all loaded nodes / controls
  86521. * @returns Array of controls
  86522. */
  86523. getNodes(): any;
  86524. /**
  86525. * Initiates the xml layout loading
  86526. * @param xmlFile defines the xml layout to load
  86527. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  86528. * @param callback defines the callback called on layout load.
  86529. */
  86530. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  86531. }
  86532. }
  86533. declare module BABYLON.GUI {
  86534. /**
  86535. * Class used to create containers for controls
  86536. */
  86537. export class Container3D extends Control3D {
  86538. private _blockLayout;
  86539. /**
  86540. * Gets the list of child controls
  86541. */
  86542. protected _children: Control3D[];
  86543. /**
  86544. * Gets the list of child controls
  86545. */
  86546. get children(): Array<Control3D>;
  86547. /**
  86548. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  86549. * This is helpful to optimize layout operation when adding multiple children in a row
  86550. */
  86551. get blockLayout(): boolean;
  86552. set blockLayout(value: boolean);
  86553. /**
  86554. * Creates a new container
  86555. * @param name defines the container name
  86556. */
  86557. constructor(name?: string);
  86558. /**
  86559. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  86560. * @returns the current container
  86561. */
  86562. updateLayout(): Container3D;
  86563. /**
  86564. * Gets a boolean indicating if the given control is in the children of this control
  86565. * @param control defines the control to check
  86566. * @returns true if the control is in the child list
  86567. */
  86568. containsControl(control: Control3D): boolean;
  86569. /**
  86570. * Adds a control to the children of this control
  86571. * @param control defines the control to add
  86572. * @returns the current container
  86573. */
  86574. addControl(control: Control3D): Container3D;
  86575. /**
  86576. * This function will be called everytime a new control is added
  86577. */
  86578. protected _arrangeChildren(): void;
  86579. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  86580. /**
  86581. * Removes a control from the children of this control
  86582. * @param control defines the control to remove
  86583. * @returns the current container
  86584. */
  86585. removeControl(control: Control3D): Container3D;
  86586. protected _getTypeName(): string;
  86587. /**
  86588. * Releases all associated resources
  86589. */
  86590. dispose(): void;
  86591. /** Control rotation will remain unchanged */
  86592. static readonly UNSET_ORIENTATION: number;
  86593. /** Control will rotate to make it look at sphere central axis */
  86594. static readonly FACEORIGIN_ORIENTATION: number;
  86595. /** Control will rotate to make it look back at sphere central axis */
  86596. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  86597. /** Control will rotate to look at z axis (0, 0, 1) */
  86598. static readonly FACEFORWARD_ORIENTATION: number;
  86599. /** Control will rotate to look at negative z axis (0, 0, -1) */
  86600. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  86601. }
  86602. }
  86603. declare module BABYLON.GUI {
  86604. /**
  86605. * Class used to create a button in 3D
  86606. */
  86607. export class Button3D extends AbstractButton3D {
  86608. /** @hidden */
  86609. protected _currentMaterial: BABYLON.Material;
  86610. private _facadeTexture;
  86611. private _content;
  86612. private _contentResolution;
  86613. private _contentScaleRatio;
  86614. /**
  86615. * Gets or sets the texture resolution used to render content (512 by default)
  86616. */
  86617. get contentResolution(): BABYLON.int;
  86618. set contentResolution(value: BABYLON.int);
  86619. /**
  86620. * Gets or sets the texture scale ratio used to render content (2 by default)
  86621. */
  86622. get contentScaleRatio(): number;
  86623. set contentScaleRatio(value: number);
  86624. protected _disposeFacadeTexture(): void;
  86625. protected _resetContent(): void;
  86626. /**
  86627. * Creates a new button
  86628. * @param name defines the control name
  86629. */
  86630. constructor(name?: string);
  86631. /**
  86632. * Gets or sets the GUI 2D content used to display the button's facade
  86633. */
  86634. get content(): Control;
  86635. set content(value: Control);
  86636. /**
  86637. * Apply the facade texture (created from the content property).
  86638. * This function can be overloaded by child classes
  86639. * @param facadeTexture defines the AdvancedDynamicTexture to use
  86640. */
  86641. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  86642. protected _getTypeName(): string;
  86643. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  86644. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  86645. /**
  86646. * Releases all associated resources
  86647. */
  86648. dispose(): void;
  86649. }
  86650. }
  86651. declare module BABYLON.GUI {
  86652. /**
  86653. * Class used to create a touchable button in 3D
  86654. */
  86655. export class TouchButton3D extends Button3D {
  86656. private _collisionMesh;
  86657. private _collidableFrontDirection;
  86658. private _lastTouchPoint;
  86659. private _tempButtonForwardRay;
  86660. private _lastKnownCollidableScale;
  86661. private _collidableInitialized;
  86662. private _frontOffset;
  86663. private _backOffset;
  86664. private _hoverOffset;
  86665. private _pushThroughBackOffset;
  86666. private _activeInteractions;
  86667. private _previousHeight;
  86668. /**
  86669. * Creates a new touchable button
  86670. * @param name defines the control name
  86671. * @param collisionMesh mesh to track collisions with
  86672. */
  86673. constructor(name?: string, collisionMesh?: BABYLON.Mesh);
  86674. /**
  86675. * Sets the front-facing direction of the button
  86676. * @param frontDir the forward direction of the button
  86677. */
  86678. set collidableFrontDirection(frontWorldDir: BABYLON.Vector3);
  86679. private _getWorldMatrixData;
  86680. /**
  86681. * Sets the mesh used for testing input collision
  86682. * @param collisionMesh the new collision mesh for the button
  86683. */
  86684. set collisionMesh(collisionMesh: BABYLON.Mesh);
  86685. private _getShortestDistancePointToLine;
  86686. private _isPrimedForInteraction;
  86687. private _getPointOnButton;
  86688. private _updateDistanceOffsets;
  86689. private _getHeightFromButtonCenter;
  86690. private _getDistanceOffPlane;
  86691. private _updateButtonState;
  86692. /** @hidden */
  86693. _collisionCheckForStateChange(mesh: BABYLON.AbstractMesh): void;
  86694. protected _getTypeName(): string;
  86695. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  86696. /**
  86697. * Releases all associated resources
  86698. */
  86699. dispose(): void;
  86700. }
  86701. }
  86702. declare module BABYLON.GUI {
  86703. /**
  86704. * Class used to manage 3D user interface
  86705. * @see https://doc.babylonjs.com/how_to/gui3d
  86706. */
  86707. export class GUI3DManager implements BABYLON.IDisposable {
  86708. private _scene;
  86709. private _sceneDisposeObserver;
  86710. private _utilityLayer;
  86711. private _rootContainer;
  86712. private _pointerObserver;
  86713. private _pointerOutObserver;
  86714. private _touchableButtons;
  86715. /** @hidden */
  86716. _lastPickedControl: Control3D;
  86717. /** @hidden */
  86718. _lastControlOver: {
  86719. [pointerId: number]: Control3D;
  86720. };
  86721. /** @hidden */
  86722. _lastControlDown: {
  86723. [pointerId: number]: Control3D;
  86724. };
  86725. /**
  86726. * BABYLON.Observable raised when the point picked by the pointer events changed
  86727. */
  86728. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  86729. /** @hidden */
  86730. _sharedMaterials: {
  86731. [key: string]: BABYLON.Material;
  86732. };
  86733. /** @hidden */
  86734. _touchSharedMaterials: {
  86735. [key: string]: BABYLON.Material;
  86736. };
  86737. /** Gets the hosting scene */
  86738. get scene(): BABYLON.Scene;
  86739. /** Gets associated utility layer */
  86740. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  86741. /**
  86742. * Creates a new GUI3DManager
  86743. * @param scene
  86744. */
  86745. constructor(scene?: BABYLON.Scene);
  86746. private _handlePointerOut;
  86747. private _doPicking;
  86748. private _processTouchControls;
  86749. /**
  86750. * Gets the root container
  86751. */
  86752. get rootContainer(): Container3D;
  86753. /**
  86754. * Gets a boolean indicating if the given control is in the root child list
  86755. * @param control defines the control to check
  86756. * @returns true if the control is in the root child list
  86757. */
  86758. containsControl(control: Control3D): boolean;
  86759. /**
  86760. * Adds a control to the root child list
  86761. * @param control defines the control to add
  86762. * @returns the current manager
  86763. */
  86764. addControl(control: Control3D): GUI3DManager;
  86765. /**
  86766. * Removes a control from the root child list
  86767. * @param control defines the control to remove
  86768. * @returns the current container
  86769. */
  86770. removeControl(control: Control3D): GUI3DManager;
  86771. /**
  86772. * Releases all associated resources
  86773. */
  86774. dispose(): void;
  86775. }
  86776. }
  86777. declare module BABYLON.GUI {
  86778. /**
  86779. * Class used to transport BABYLON.Vector3 information for pointer events
  86780. */
  86781. export class Vector3WithInfo extends BABYLON.Vector3 {
  86782. /** defines the current mouse button index */
  86783. buttonIndex: number;
  86784. /**
  86785. * Creates a new Vector3WithInfo
  86786. * @param source defines the vector3 data to transport
  86787. * @param buttonIndex defines the current mouse button index
  86788. */
  86789. constructor(source: BABYLON.Vector3,
  86790. /** defines the current mouse button index */
  86791. buttonIndex?: number);
  86792. }
  86793. }
  86794. declare module BABYLON.GUI {
  86795. /**
  86796. * Class used as base class for controls
  86797. */
  86798. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  86799. /** Defines the control name */
  86800. name?: string | undefined;
  86801. /** @hidden */
  86802. _host: GUI3DManager;
  86803. private _node;
  86804. private _downCount;
  86805. private _enterCount;
  86806. private _downPointerIds;
  86807. private _isVisible;
  86808. /** Gets or sets the control position in world space */
  86809. get position(): BABYLON.Vector3;
  86810. set position(value: BABYLON.Vector3);
  86811. /** Gets or sets the control scaling in world space */
  86812. get scaling(): BABYLON.Vector3;
  86813. set scaling(value: BABYLON.Vector3);
  86814. /** Callback used to start pointer enter animation */
  86815. pointerEnterAnimation: () => void;
  86816. /** Callback used to start pointer out animation */
  86817. pointerOutAnimation: () => void;
  86818. /** Callback used to start pointer down animation */
  86819. pointerDownAnimation: () => void;
  86820. /** Callback used to start pointer up animation */
  86821. pointerUpAnimation: () => void;
  86822. /**
  86823. * An event triggered when the pointer move over the control
  86824. */
  86825. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  86826. /**
  86827. * An event triggered when the pointer move out of the control
  86828. */
  86829. onPointerOutObservable: BABYLON.Observable<Control3D>;
  86830. /**
  86831. * An event triggered when the pointer taps the control
  86832. */
  86833. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  86834. /**
  86835. * An event triggered when pointer is up
  86836. */
  86837. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  86838. /**
  86839. * An event triggered when a control is clicked on (with a mouse)
  86840. */
  86841. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  86842. /**
  86843. * An event triggered when pointer enters the control
  86844. */
  86845. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  86846. /**
  86847. * Gets or sets the parent container
  86848. */
  86849. parent: BABYLON.Nullable<Container3D>;
  86850. private _behaviors;
  86851. /**
  86852. * Gets the list of attached behaviors
  86853. * @see https://doc.babylonjs.com/features/behaviour
  86854. */
  86855. get behaviors(): BABYLON.Behavior<Control3D>[];
  86856. /**
  86857. * Attach a behavior to the control
  86858. * @see https://doc.babylonjs.com/features/behaviour
  86859. * @param behavior defines the behavior to attach
  86860. * @returns the current control
  86861. */
  86862. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  86863. /**
  86864. * Remove an attached behavior
  86865. * @see https://doc.babylonjs.com/features/behaviour
  86866. * @param behavior defines the behavior to attach
  86867. * @returns the current control
  86868. */
  86869. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  86870. /**
  86871. * Gets an attached behavior by name
  86872. * @param name defines the name of the behavior to look for
  86873. * @see https://doc.babylonjs.com/features/behaviour
  86874. * @returns null if behavior was not found else the requested behavior
  86875. */
  86876. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  86877. /** Gets or sets a boolean indicating if the control is visible */
  86878. get isVisible(): boolean;
  86879. set isVisible(value: boolean);
  86880. /**
  86881. * Creates a new control
  86882. * @param name defines the control name
  86883. */
  86884. constructor(
  86885. /** Defines the control name */
  86886. name?: string | undefined);
  86887. /**
  86888. * Gets a string representing the class name
  86889. */
  86890. get typeName(): string;
  86891. /**
  86892. * Get the current class name of the control.
  86893. * @returns current class name
  86894. */
  86895. getClassName(): string;
  86896. protected _getTypeName(): string;
  86897. /**
  86898. * Gets the transform node used by this control
  86899. */
  86900. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  86901. /**
  86902. * Gets the mesh used to render this control
  86903. */
  86904. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  86905. /**
  86906. * Link the control as child of the given node
  86907. * @param node defines the node to link to. Use null to unlink the control
  86908. * @returns the current control
  86909. */
  86910. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  86911. /** @hidden **/
  86912. _prepareNode(scene: BABYLON.Scene): void;
  86913. protected _injectGUI3DMetadata(node: BABYLON.TransformNode): any;
  86914. /**
  86915. * Node creation.
  86916. * Can be overriden by children
  86917. * @param scene defines the scene where the node must be attached
  86918. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  86919. */
  86920. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  86921. /**
  86922. * Affect a material to the given mesh
  86923. * @param mesh defines the mesh which will represent the control
  86924. */
  86925. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  86926. /** @hidden */
  86927. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  86928. /** @hidden */
  86929. _onPointerEnter(target: Control3D): boolean;
  86930. /** @hidden */
  86931. _onPointerOut(target: Control3D): void;
  86932. /** @hidden */
  86933. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  86934. /** @hidden */
  86935. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  86936. /** @hidden */
  86937. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  86938. /** @hidden */
  86939. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  86940. /** @hidden */
  86941. _disposeNode(): void;
  86942. /**
  86943. * Releases all associated resources
  86944. */
  86945. dispose(): void;
  86946. }
  86947. }
  86948. declare module BABYLON.GUI {
  86949. /**
  86950. * Class used as a root to all buttons
  86951. */
  86952. export class AbstractButton3D extends Control3D {
  86953. /**
  86954. * Creates a new button
  86955. * @param name defines the control name
  86956. */
  86957. constructor(name?: string);
  86958. protected _getTypeName(): string;
  86959. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  86960. }
  86961. }
  86962. declare module BABYLON.GUI {
  86963. /**
  86964. * Abstract class used to create a container panel deployed on the surface of a volume
  86965. */
  86966. export abstract class VolumeBasedPanel extends Container3D {
  86967. private _columns;
  86968. private _rows;
  86969. private _rowThenColum;
  86970. private _orientation;
  86971. protected _cellWidth: number;
  86972. protected _cellHeight: number;
  86973. /**
  86974. * Gets or sets the distance between elements
  86975. */
  86976. margin: number;
  86977. /**
  86978. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  86979. * | Value | Type | Description |
  86980. * | ----- | ----------------------------------- | ----------- |
  86981. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  86982. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  86983. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  86984. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  86985. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  86986. */
  86987. get orientation(): number;
  86988. set orientation(value: number);
  86989. /**
  86990. * Gets or sets the number of columns requested (10 by default).
  86991. * The panel will automatically compute the number of rows based on number of child controls.
  86992. */
  86993. get columns(): BABYLON.int;
  86994. set columns(value: BABYLON.int);
  86995. /**
  86996. * Gets or sets a the number of rows requested.
  86997. * The panel will automatically compute the number of columns based on number of child controls.
  86998. */
  86999. get rows(): BABYLON.int;
  87000. set rows(value: BABYLON.int);
  87001. /**
  87002. * Creates new VolumeBasedPanel
  87003. */
  87004. constructor();
  87005. protected _arrangeChildren(): void;
  87006. /** Child classes must implement this function to provide correct control positioning */
  87007. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  87008. /** Child classes can implement this function to provide additional processing */
  87009. protected _finalProcessing(): void;
  87010. }
  87011. }
  87012. declare module BABYLON.GUI {
  87013. /**
  87014. * Class used to create a container panel deployed on the surface of a cylinder
  87015. */
  87016. export class CylinderPanel extends VolumeBasedPanel {
  87017. private _radius;
  87018. /**
  87019. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  87020. */
  87021. get radius(): BABYLON.float;
  87022. set radius(value: BABYLON.float);
  87023. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  87024. private _cylindricalMapping;
  87025. }
  87026. }
  87027. declare module BABYLON.GUI {
  87028. /** @hidden */
  87029. export var fluentVertexShader: {
  87030. name: string;
  87031. shader: string;
  87032. };
  87033. }
  87034. declare module BABYLON.GUI {
  87035. /** @hidden */
  87036. export var fluentPixelShader: {
  87037. name: string;
  87038. shader: string;
  87039. };
  87040. }
  87041. declare module BABYLON.GUI {
  87042. /** @hidden */
  87043. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  87044. INNERGLOW: boolean;
  87045. BORDER: boolean;
  87046. HOVERLIGHT: boolean;
  87047. TEXTURE: boolean;
  87048. constructor();
  87049. }
  87050. /**
  87051. * Class used to render controls with fluent desgin
  87052. */
  87053. export class FluentMaterial extends BABYLON.PushMaterial {
  87054. /**
  87055. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  87056. */
  87057. innerGlowColorIntensity: number;
  87058. /**
  87059. * Gets or sets the inner glow color (white by default)
  87060. */
  87061. innerGlowColor: BABYLON.Color3;
  87062. /**
  87063. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  87064. */
  87065. albedoColor: BABYLON.Color3;
  87066. /**
  87067. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  87068. */
  87069. renderBorders: boolean;
  87070. /**
  87071. * Gets or sets border width (default is 0.5)
  87072. */
  87073. borderWidth: number;
  87074. /**
  87075. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  87076. */
  87077. edgeSmoothingValue: number;
  87078. /**
  87079. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  87080. */
  87081. borderMinValue: number;
  87082. /**
  87083. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  87084. */
  87085. renderHoverLight: boolean;
  87086. /**
  87087. * Gets or sets the radius used to render the hover light (default is 1.0)
  87088. */
  87089. hoverRadius: number;
  87090. /**
  87091. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  87092. */
  87093. hoverColor: BABYLON.Color4;
  87094. /**
  87095. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  87096. */
  87097. hoverPosition: BABYLON.Vector3;
  87098. private _albedoTexture;
  87099. /** Gets or sets the texture to use for albedo color */
  87100. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  87101. /**
  87102. * Creates a new Fluent material
  87103. * @param name defines the name of the material
  87104. * @param scene defines the hosting scene
  87105. */
  87106. constructor(name: string, scene: BABYLON.Scene);
  87107. needAlphaBlending(): boolean;
  87108. needAlphaTesting(): boolean;
  87109. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87110. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87111. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87112. getActiveTextures(): BABYLON.BaseTexture[];
  87113. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87114. dispose(forceDisposeEffect?: boolean): void;
  87115. clone(name: string): FluentMaterial;
  87116. serialize(): any;
  87117. getClassName(): string;
  87118. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  87119. }
  87120. }
  87121. declare module BABYLON.GUI {
  87122. /**
  87123. * Class used to create a holographic button in 3D
  87124. */
  87125. export class HolographicButton extends Button3D {
  87126. private _backPlate;
  87127. private _textPlate;
  87128. private _frontPlate;
  87129. private _text;
  87130. private _imageUrl;
  87131. private _shareMaterials;
  87132. private _frontMaterial;
  87133. private _backMaterial;
  87134. private _plateMaterial;
  87135. private _pickedPointObserver;
  87136. private _tooltipFade;
  87137. private _tooltipTextBlock;
  87138. private _tooltipTexture;
  87139. private _tooltipMesh;
  87140. private _tooltipHoverObserver;
  87141. private _tooltipOutObserver;
  87142. private _disposeTooltip;
  87143. /**
  87144. * Rendering ground id of all the mesh in the button
  87145. */
  87146. set renderingGroupId(id: number);
  87147. get renderingGroupId(): number;
  87148. /**
  87149. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  87150. */
  87151. set tooltipText(text: BABYLON.Nullable<string>);
  87152. get tooltipText(): BABYLON.Nullable<string>;
  87153. /**
  87154. * Gets or sets text for the button
  87155. */
  87156. get text(): string;
  87157. set text(value: string);
  87158. /**
  87159. * Gets or sets the image url for the button
  87160. */
  87161. get imageUrl(): string;
  87162. set imageUrl(value: string);
  87163. /**
  87164. * Gets the back material used by this button
  87165. */
  87166. get backMaterial(): FluentMaterial;
  87167. /**
  87168. * Gets the front material used by this button
  87169. */
  87170. get frontMaterial(): FluentMaterial;
  87171. /**
  87172. * Gets the plate material used by this button
  87173. */
  87174. get plateMaterial(): BABYLON.StandardMaterial;
  87175. /**
  87176. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  87177. */
  87178. get shareMaterials(): boolean;
  87179. /**
  87180. * Creates a new button
  87181. * @param name defines the control name
  87182. */
  87183. constructor(name?: string, shareMaterials?: boolean);
  87184. protected _getTypeName(): string;
  87185. private _rebuildContent;
  87186. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  87187. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  87188. private _createBackMaterial;
  87189. private _createFrontMaterial;
  87190. private _createPlateMaterial;
  87191. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  87192. /**
  87193. * Releases all associated resources
  87194. */
  87195. dispose(): void;
  87196. }
  87197. }
  87198. declare module BABYLON.GUI {
  87199. /**
  87200. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  87201. */
  87202. export class MeshButton3D extends Button3D {
  87203. /** @hidden */
  87204. protected _currentMesh: BABYLON.Mesh;
  87205. /**
  87206. * Creates a new 3D button based on a mesh
  87207. * @param mesh mesh to become a 3D button
  87208. * @param name defines the control name
  87209. */
  87210. constructor(mesh: BABYLON.Mesh, name?: string);
  87211. protected _getTypeName(): string;
  87212. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  87213. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  87214. }
  87215. }
  87216. declare module BABYLON.GUI {
  87217. /**
  87218. * Class used to create a container panel deployed on the surface of a plane
  87219. */
  87220. export class PlanePanel extends VolumeBasedPanel {
  87221. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  87222. }
  87223. }
  87224. declare module BABYLON.GUI {
  87225. /**
  87226. * Class used to create a container panel where items get randomized planar mapping
  87227. */
  87228. export class ScatterPanel extends VolumeBasedPanel {
  87229. private _iteration;
  87230. /**
  87231. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  87232. */
  87233. get iteration(): BABYLON.float;
  87234. set iteration(value: BABYLON.float);
  87235. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  87236. private _scatterMapping;
  87237. protected _finalProcessing(): void;
  87238. }
  87239. }
  87240. declare module BABYLON.GUI {
  87241. /**
  87242. * Class used to create a container panel deployed on the surface of a sphere
  87243. */
  87244. export class SpherePanel extends VolumeBasedPanel {
  87245. private _radius;
  87246. /**
  87247. * Gets or sets the radius of the sphere where to project controls (5 by default)
  87248. */
  87249. get radius(): BABYLON.float;
  87250. set radius(value: BABYLON.float);
  87251. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  87252. private _sphericalMapping;
  87253. }
  87254. }
  87255. declare module BABYLON.GUI {
  87256. /**
  87257. * Class used to create a stack panel in 3D on XY plane
  87258. */
  87259. export class StackPanel3D extends Container3D {
  87260. private _isVertical;
  87261. /**
  87262. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  87263. */
  87264. get isVertical(): boolean;
  87265. set isVertical(value: boolean);
  87266. /**
  87267. * Gets or sets the distance between elements
  87268. */
  87269. margin: number;
  87270. /**
  87271. * Creates new StackPanel
  87272. * @param isVertical
  87273. */
  87274. constructor(isVertical?: boolean);
  87275. protected _arrangeChildren(): void;
  87276. }
  87277. }
  87278. declare module BABYLON.GUI {
  87279. /**
  87280. * Class used to create an interactable object. It's a touchable 3D button using a mesh coming from the current scene
  87281. */
  87282. export class TouchMeshButton3D extends TouchButton3D {
  87283. /** @hidden */
  87284. protected _currentMesh: BABYLON.Mesh;
  87285. /**
  87286. * Creates a new 3D button based on a mesh
  87287. * @param mesh mesh to become a 3D button
  87288. * @param collisionMesh mesh to track collisions with
  87289. * @param name defines the control name
  87290. */
  87291. constructor(mesh: BABYLON.Mesh, options: {
  87292. collisionMesh: BABYLON.Mesh;
  87293. useDynamicMesh?: boolean;
  87294. }, name?: string);
  87295. protected _getTypeName(): string;
  87296. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  87297. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  87298. }
  87299. }
  87300. declare module BABYLON.GUI {
  87301. /**
  87302. * Class used to create a holographic button in 3D
  87303. */
  87304. export class TouchHolographicButton extends TouchButton3D {
  87305. private _backPlate;
  87306. private _textPlate;
  87307. private _frontPlate;
  87308. private _text;
  87309. private _imageUrl;
  87310. private _shareMaterials;
  87311. private _frontMaterial;
  87312. private _backMaterial;
  87313. private _plateMaterial;
  87314. private _pickedPointObserver;
  87315. private _tooltipFade;
  87316. private _tooltipTextBlock;
  87317. private _tooltipTexture;
  87318. private _tooltipMesh;
  87319. private _tooltipHoverObserver;
  87320. private _tooltipOutObserver;
  87321. private _disposeTooltip;
  87322. /**
  87323. * Rendering ground id of all the mesh in the button
  87324. */
  87325. set renderingGroupId(id: number);
  87326. get renderingGroupId(): number;
  87327. /**
  87328. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  87329. */
  87330. set tooltipText(text: BABYLON.Nullable<string>);
  87331. get tooltipText(): BABYLON.Nullable<string>;
  87332. /**
  87333. * Gets or sets text for the button
  87334. */
  87335. get text(): string;
  87336. set text(value: string);
  87337. /**
  87338. * Gets or sets the image url for the button
  87339. */
  87340. get imageUrl(): string;
  87341. set imageUrl(value: string);
  87342. /**
  87343. * Gets the back material used by this button
  87344. */
  87345. get backMaterial(): FluentMaterial;
  87346. /**
  87347. * Gets the front material used by this button
  87348. */
  87349. get frontMaterial(): FluentMaterial;
  87350. /**
  87351. * Gets the plate material used by this button
  87352. */
  87353. get plateMaterial(): BABYLON.StandardMaterial;
  87354. /**
  87355. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  87356. */
  87357. get shareMaterials(): boolean;
  87358. /**
  87359. * Creates a new button
  87360. * @param name defines the control name
  87361. */
  87362. constructor(name?: string, shareMaterials?: boolean);
  87363. protected _getTypeName(): string;
  87364. private _rebuildContent;
  87365. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  87366. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  87367. private _createBackMaterial;
  87368. private _createFrontMaterial;
  87369. private _createPlateMaterial;
  87370. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  87371. /**
  87372. * Releases all associated resources
  87373. */
  87374. dispose(): void;
  87375. }
  87376. }
  87377. declare module BABYLON {
  87378. /**
  87379. * Configuration for glTF validation
  87380. */
  87381. export interface IGLTFValidationConfiguration {
  87382. /**
  87383. * The url of the glTF validator.
  87384. */
  87385. url: string;
  87386. }
  87387. /**
  87388. * glTF validation
  87389. */
  87390. export class GLTFValidation {
  87391. /**
  87392. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  87393. */
  87394. static Configuration: IGLTFValidationConfiguration;
  87395. private static _LoadScriptPromise;
  87396. /**
  87397. * Validate a glTF asset using the glTF-Validator.
  87398. * @param data The JSON of a glTF or the array buffer of a binary glTF
  87399. * @param rootUrl The root url for the glTF
  87400. * @param fileName The file name for the glTF
  87401. * @param getExternalResource The callback to get external resources for the glTF validator
  87402. * @returns A promise that resolves with the glTF validation results once complete
  87403. */
  87404. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  87405. }
  87406. }
  87407. declare module BABYLON {
  87408. /**
  87409. * Mode that determines the coordinate system to use.
  87410. */
  87411. export enum GLTFLoaderCoordinateSystemMode {
  87412. /**
  87413. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  87414. */
  87415. AUTO = 0,
  87416. /**
  87417. * Sets the useRightHandedSystem flag on the scene.
  87418. */
  87419. FORCE_RIGHT_HANDED = 1
  87420. }
  87421. /**
  87422. * Mode that determines what animations will start.
  87423. */
  87424. export enum GLTFLoaderAnimationStartMode {
  87425. /**
  87426. * No animation will start.
  87427. */
  87428. NONE = 0,
  87429. /**
  87430. * The first animation will start.
  87431. */
  87432. FIRST = 1,
  87433. /**
  87434. * All animations will start.
  87435. */
  87436. ALL = 2
  87437. }
  87438. /**
  87439. * Interface that contains the data for the glTF asset.
  87440. */
  87441. export interface IGLTFLoaderData {
  87442. /**
  87443. * The object that represents the glTF JSON.
  87444. */
  87445. json: Object;
  87446. /**
  87447. * The BIN chunk of a binary glTF.
  87448. */
  87449. bin: Nullable<IDataBuffer>;
  87450. }
  87451. /**
  87452. * Interface for extending the loader.
  87453. */
  87454. export interface IGLTFLoaderExtension {
  87455. /**
  87456. * The name of this extension.
  87457. */
  87458. readonly name: string;
  87459. /**
  87460. * Defines whether this extension is enabled.
  87461. */
  87462. enabled: boolean;
  87463. /**
  87464. * Defines the order of this extension.
  87465. * The loader sorts the extensions using these values when loading.
  87466. */
  87467. order?: number;
  87468. }
  87469. /**
  87470. * Loader state.
  87471. */
  87472. export enum GLTFLoaderState {
  87473. /**
  87474. * The asset is loading.
  87475. */
  87476. LOADING = 0,
  87477. /**
  87478. * The asset is ready for rendering.
  87479. */
  87480. READY = 1,
  87481. /**
  87482. * The asset is completely loaded.
  87483. */
  87484. COMPLETE = 2
  87485. }
  87486. /** @hidden */
  87487. export interface IGLTFLoader extends IDisposable {
  87488. readonly state: Nullable<GLTFLoaderState>;
  87489. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<ISceneLoaderAsyncResult>;
  87490. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  87491. }
  87492. /**
  87493. * File loader for loading glTF files into a scene.
  87494. */
  87495. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  87496. /** @hidden */
  87497. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  87498. /** @hidden */
  87499. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  87500. /**
  87501. * Raised when the asset has been parsed
  87502. */
  87503. onParsedObservable: Observable<IGLTFLoaderData>;
  87504. private _onParsedObserver;
  87505. /**
  87506. * Raised when the asset has been parsed
  87507. */
  87508. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  87509. /**
  87510. * 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.
  87511. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  87512. * Defaults to true.
  87513. * @hidden
  87514. */
  87515. static IncrementalLoading: boolean;
  87516. /**
  87517. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  87518. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  87519. * @hidden
  87520. */
  87521. static HomogeneousCoordinates: boolean;
  87522. /**
  87523. * The coordinate system mode. Defaults to AUTO.
  87524. */
  87525. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  87526. /**
  87527. * The animation start mode. Defaults to FIRST.
  87528. */
  87529. animationStartMode: GLTFLoaderAnimationStartMode;
  87530. /**
  87531. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  87532. */
  87533. compileMaterials: boolean;
  87534. /**
  87535. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  87536. */
  87537. useClipPlane: boolean;
  87538. /**
  87539. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  87540. */
  87541. compileShadowGenerators: boolean;
  87542. /**
  87543. * Defines if the Alpha blended materials are only applied as coverage.
  87544. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  87545. * If true, no extra effects are applied to transparent pixels.
  87546. */
  87547. transparencyAsCoverage: boolean;
  87548. /**
  87549. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  87550. * Enabling will disable offline support and glTF validator.
  87551. * Defaults to false.
  87552. */
  87553. useRangeRequests: boolean;
  87554. /**
  87555. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  87556. */
  87557. createInstances: boolean;
  87558. /**
  87559. * 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.
  87560. */
  87561. alwaysComputeBoundingBox: boolean;
  87562. /**
  87563. * If true, load all materials defined in the file, even if not used by any mesh. Defaults to false.
  87564. */
  87565. loadAllMaterials: boolean;
  87566. /**
  87567. * Function called before loading a url referenced by the asset.
  87568. */
  87569. preprocessUrlAsync: (url: string) => Promise<string>;
  87570. /**
  87571. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  87572. * 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, ...)
  87573. */
  87574. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  87575. private _onMeshLoadedObserver;
  87576. /**
  87577. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  87578. * 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, ...)
  87579. */
  87580. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  87581. /**
  87582. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  87583. */
  87584. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  87585. private _onTextureLoadedObserver;
  87586. /**
  87587. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  87588. */
  87589. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  87590. /**
  87591. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  87592. */
  87593. readonly onMaterialLoadedObservable: Observable<Material>;
  87594. private _onMaterialLoadedObserver;
  87595. /**
  87596. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  87597. */
  87598. set onMaterialLoaded(callback: (material: Material) => void);
  87599. /**
  87600. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  87601. */
  87602. readonly onCameraLoadedObservable: Observable<Camera>;
  87603. private _onCameraLoadedObserver;
  87604. /**
  87605. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  87606. */
  87607. set onCameraLoaded(callback: (camera: Camera) => void);
  87608. /**
  87609. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  87610. * For assets with LODs, raised when all of the LODs are complete.
  87611. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  87612. */
  87613. readonly onCompleteObservable: Observable<void>;
  87614. private _onCompleteObserver;
  87615. /**
  87616. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  87617. * For assets with LODs, raised when all of the LODs are complete.
  87618. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  87619. */
  87620. set onComplete(callback: () => void);
  87621. /**
  87622. * Observable raised when an error occurs.
  87623. */
  87624. readonly onErrorObservable: Observable<any>;
  87625. private _onErrorObserver;
  87626. /**
  87627. * Callback raised when an error occurs.
  87628. */
  87629. set onError(callback: (reason: any) => void);
  87630. /**
  87631. * Observable raised after the loader is disposed.
  87632. */
  87633. readonly onDisposeObservable: Observable<void>;
  87634. private _onDisposeObserver;
  87635. /**
  87636. * Callback raised after the loader is disposed.
  87637. */
  87638. set onDispose(callback: () => void);
  87639. /**
  87640. * Observable raised after a loader extension is created.
  87641. * Set additional options for a loader extension in this event.
  87642. */
  87643. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  87644. private _onExtensionLoadedObserver;
  87645. /**
  87646. * Callback raised after a loader extension is created.
  87647. */
  87648. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  87649. /**
  87650. * Defines if the loader logging is enabled.
  87651. */
  87652. get loggingEnabled(): boolean;
  87653. set loggingEnabled(value: boolean);
  87654. /**
  87655. * Defines if the loader should capture performance counters.
  87656. */
  87657. get capturePerformanceCounters(): boolean;
  87658. set capturePerformanceCounters(value: boolean);
  87659. /**
  87660. * Defines if the loader should validate the asset.
  87661. */
  87662. validate: boolean;
  87663. /**
  87664. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  87665. */
  87666. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  87667. private _onValidatedObserver;
  87668. /**
  87669. * Callback raised after a loader extension is created.
  87670. */
  87671. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  87672. private _loader;
  87673. private _progressCallback?;
  87674. private _requests;
  87675. private static magicBase64Encoded;
  87676. /**
  87677. * Name of the loader ("gltf")
  87678. */
  87679. name: string;
  87680. /** @hidden */
  87681. extensions: ISceneLoaderPluginExtensions;
  87682. /**
  87683. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  87684. */
  87685. dispose(): void;
  87686. /** @hidden */
  87687. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  87688. /** @hidden */
  87689. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  87690. /** @hidden */
  87691. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  87692. /** @hidden */
  87693. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  87694. /** @hidden */
  87695. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  87696. /** @hidden */
  87697. canDirectLoad(data: string): boolean;
  87698. /** @hidden */
  87699. directLoad(scene: Scene, data: string): Promise<any>;
  87700. /**
  87701. * The callback that allows custom handling of the root url based on the response url.
  87702. * @param rootUrl the original root url
  87703. * @param responseURL the response url if available
  87704. * @returns the new root url
  87705. */
  87706. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  87707. /** @hidden */
  87708. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  87709. /**
  87710. * The loader state or null if the loader is not active.
  87711. */
  87712. get loaderState(): Nullable<GLTFLoaderState>;
  87713. /**
  87714. * Returns a promise that resolves when the asset is completely loaded.
  87715. * @returns a promise that resolves when the asset is completely loaded.
  87716. */
  87717. whenCompleteAsync(): Promise<void>;
  87718. /** @hidden */
  87719. _loadFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer) => void, useArrayBuffer?: boolean, onError?: (request?: WebRequest) => void): IFileRequest;
  87720. /** @hidden */
  87721. _requestFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  87722. private _onProgress;
  87723. private _validate;
  87724. private _getLoader;
  87725. private _parseJson;
  87726. private _unpackBinaryAsync;
  87727. private _unpackBinaryV1Async;
  87728. private _unpackBinaryV2Async;
  87729. private static _parseVersion;
  87730. private static _compareVersion;
  87731. private static readonly _logSpaces;
  87732. private _logIndentLevel;
  87733. private _loggingEnabled;
  87734. /** @hidden */
  87735. _log: (message: string) => void;
  87736. /** @hidden */
  87737. _logOpen(message: string): void;
  87738. /** @hidden */
  87739. _logClose(): void;
  87740. private _logEnabled;
  87741. private _logDisabled;
  87742. private _capturePerformanceCounters;
  87743. /** @hidden */
  87744. _startPerformanceCounter: (counterName: string) => void;
  87745. /** @hidden */
  87746. _endPerformanceCounter: (counterName: string) => void;
  87747. private _startPerformanceCounterEnabled;
  87748. private _startPerformanceCounterDisabled;
  87749. private _endPerformanceCounterEnabled;
  87750. private _endPerformanceCounterDisabled;
  87751. }
  87752. }
  87753. declare module BABYLON.GLTF1 {
  87754. /**
  87755. * Enums
  87756. * @hidden
  87757. */
  87758. export enum EComponentType {
  87759. BYTE = 5120,
  87760. UNSIGNED_BYTE = 5121,
  87761. SHORT = 5122,
  87762. UNSIGNED_SHORT = 5123,
  87763. FLOAT = 5126
  87764. }
  87765. /** @hidden */
  87766. export enum EShaderType {
  87767. FRAGMENT = 35632,
  87768. VERTEX = 35633
  87769. }
  87770. /** @hidden */
  87771. export enum EParameterType {
  87772. BYTE = 5120,
  87773. UNSIGNED_BYTE = 5121,
  87774. SHORT = 5122,
  87775. UNSIGNED_SHORT = 5123,
  87776. INT = 5124,
  87777. UNSIGNED_INT = 5125,
  87778. FLOAT = 5126,
  87779. FLOAT_VEC2 = 35664,
  87780. FLOAT_VEC3 = 35665,
  87781. FLOAT_VEC4 = 35666,
  87782. INT_VEC2 = 35667,
  87783. INT_VEC3 = 35668,
  87784. INT_VEC4 = 35669,
  87785. BOOL = 35670,
  87786. BOOL_VEC2 = 35671,
  87787. BOOL_VEC3 = 35672,
  87788. BOOL_VEC4 = 35673,
  87789. FLOAT_MAT2 = 35674,
  87790. FLOAT_MAT3 = 35675,
  87791. FLOAT_MAT4 = 35676,
  87792. SAMPLER_2D = 35678
  87793. }
  87794. /** @hidden */
  87795. export enum ETextureWrapMode {
  87796. CLAMP_TO_EDGE = 33071,
  87797. MIRRORED_REPEAT = 33648,
  87798. REPEAT = 10497
  87799. }
  87800. /** @hidden */
  87801. export enum ETextureFilterType {
  87802. NEAREST = 9728,
  87803. LINEAR = 9728,
  87804. NEAREST_MIPMAP_NEAREST = 9984,
  87805. LINEAR_MIPMAP_NEAREST = 9985,
  87806. NEAREST_MIPMAP_LINEAR = 9986,
  87807. LINEAR_MIPMAP_LINEAR = 9987
  87808. }
  87809. /** @hidden */
  87810. export enum ETextureFormat {
  87811. ALPHA = 6406,
  87812. RGB = 6407,
  87813. RGBA = 6408,
  87814. LUMINANCE = 6409,
  87815. LUMINANCE_ALPHA = 6410
  87816. }
  87817. /** @hidden */
  87818. export enum ECullingType {
  87819. FRONT = 1028,
  87820. BACK = 1029,
  87821. FRONT_AND_BACK = 1032
  87822. }
  87823. /** @hidden */
  87824. export enum EBlendingFunction {
  87825. ZERO = 0,
  87826. ONE = 1,
  87827. SRC_COLOR = 768,
  87828. ONE_MINUS_SRC_COLOR = 769,
  87829. DST_COLOR = 774,
  87830. ONE_MINUS_DST_COLOR = 775,
  87831. SRC_ALPHA = 770,
  87832. ONE_MINUS_SRC_ALPHA = 771,
  87833. DST_ALPHA = 772,
  87834. ONE_MINUS_DST_ALPHA = 773,
  87835. CONSTANT_COLOR = 32769,
  87836. ONE_MINUS_CONSTANT_COLOR = 32770,
  87837. CONSTANT_ALPHA = 32771,
  87838. ONE_MINUS_CONSTANT_ALPHA = 32772,
  87839. SRC_ALPHA_SATURATE = 776
  87840. }
  87841. /** @hidden */
  87842. export interface IGLTFProperty {
  87843. extensions?: {
  87844. [key: string]: any;
  87845. };
  87846. extras?: Object;
  87847. }
  87848. /** @hidden */
  87849. export interface IGLTFChildRootProperty extends IGLTFProperty {
  87850. name?: string;
  87851. }
  87852. /** @hidden */
  87853. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  87854. bufferView: string;
  87855. byteOffset: number;
  87856. byteStride: number;
  87857. count: number;
  87858. type: string;
  87859. componentType: EComponentType;
  87860. max?: number[];
  87861. min?: number[];
  87862. name?: string;
  87863. }
  87864. /** @hidden */
  87865. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  87866. buffer: string;
  87867. byteOffset: number;
  87868. byteLength: number;
  87869. byteStride: number;
  87870. target?: number;
  87871. }
  87872. /** @hidden */
  87873. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  87874. uri: string;
  87875. byteLength?: number;
  87876. type?: string;
  87877. }
  87878. /** @hidden */
  87879. export interface IGLTFShader extends IGLTFChildRootProperty {
  87880. uri: string;
  87881. type: EShaderType;
  87882. }
  87883. /** @hidden */
  87884. export interface IGLTFProgram extends IGLTFChildRootProperty {
  87885. attributes: string[];
  87886. fragmentShader: string;
  87887. vertexShader: string;
  87888. }
  87889. /** @hidden */
  87890. export interface IGLTFTechniqueParameter {
  87891. type: number;
  87892. count?: number;
  87893. semantic?: string;
  87894. node?: string;
  87895. value?: number | boolean | string | Array<any>;
  87896. source?: string;
  87897. babylonValue?: any;
  87898. }
  87899. /** @hidden */
  87900. export interface IGLTFTechniqueCommonProfile {
  87901. lightingModel: string;
  87902. texcoordBindings: Object;
  87903. parameters?: Array<any>;
  87904. }
  87905. /** @hidden */
  87906. export interface IGLTFTechniqueStatesFunctions {
  87907. blendColor?: number[];
  87908. blendEquationSeparate?: number[];
  87909. blendFuncSeparate?: number[];
  87910. colorMask: boolean[];
  87911. cullFace: number[];
  87912. }
  87913. /** @hidden */
  87914. export interface IGLTFTechniqueStates {
  87915. enable: number[];
  87916. functions: IGLTFTechniqueStatesFunctions;
  87917. }
  87918. /** @hidden */
  87919. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  87920. parameters: {
  87921. [key: string]: IGLTFTechniqueParameter;
  87922. };
  87923. program: string;
  87924. attributes: {
  87925. [key: string]: string;
  87926. };
  87927. uniforms: {
  87928. [key: string]: string;
  87929. };
  87930. states: IGLTFTechniqueStates;
  87931. }
  87932. /** @hidden */
  87933. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  87934. technique?: string;
  87935. values: string[];
  87936. }
  87937. /** @hidden */
  87938. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  87939. attributes: {
  87940. [key: string]: string;
  87941. };
  87942. indices: string;
  87943. material: string;
  87944. mode?: number;
  87945. }
  87946. /** @hidden */
  87947. export interface IGLTFMesh extends IGLTFChildRootProperty {
  87948. primitives: IGLTFMeshPrimitive[];
  87949. }
  87950. /** @hidden */
  87951. export interface IGLTFImage extends IGLTFChildRootProperty {
  87952. uri: string;
  87953. }
  87954. /** @hidden */
  87955. export interface IGLTFSampler extends IGLTFChildRootProperty {
  87956. magFilter?: number;
  87957. minFilter?: number;
  87958. wrapS?: number;
  87959. wrapT?: number;
  87960. }
  87961. /** @hidden */
  87962. export interface IGLTFTexture extends IGLTFChildRootProperty {
  87963. sampler: string;
  87964. source: string;
  87965. format?: ETextureFormat;
  87966. internalFormat?: ETextureFormat;
  87967. target?: number;
  87968. type?: number;
  87969. babylonTexture?: Texture;
  87970. }
  87971. /** @hidden */
  87972. export interface IGLTFAmbienLight {
  87973. color?: number[];
  87974. }
  87975. /** @hidden */
  87976. export interface IGLTFDirectionalLight {
  87977. color?: number[];
  87978. }
  87979. /** @hidden */
  87980. export interface IGLTFPointLight {
  87981. color?: number[];
  87982. constantAttenuation?: number;
  87983. linearAttenuation?: number;
  87984. quadraticAttenuation?: number;
  87985. }
  87986. /** @hidden */
  87987. export interface IGLTFSpotLight {
  87988. color?: number[];
  87989. constantAttenuation?: number;
  87990. fallOfAngle?: number;
  87991. fallOffExponent?: number;
  87992. linearAttenuation?: number;
  87993. quadraticAttenuation?: number;
  87994. }
  87995. /** @hidden */
  87996. export interface IGLTFLight extends IGLTFChildRootProperty {
  87997. type: string;
  87998. }
  87999. /** @hidden */
  88000. export interface IGLTFCameraOrthographic {
  88001. xmag: number;
  88002. ymag: number;
  88003. zfar: number;
  88004. znear: number;
  88005. }
  88006. /** @hidden */
  88007. export interface IGLTFCameraPerspective {
  88008. aspectRatio: number;
  88009. yfov: number;
  88010. zfar: number;
  88011. znear: number;
  88012. }
  88013. /** @hidden */
  88014. export interface IGLTFCamera extends IGLTFChildRootProperty {
  88015. type: string;
  88016. }
  88017. /** @hidden */
  88018. export interface IGLTFAnimationChannelTarget {
  88019. id: string;
  88020. path: string;
  88021. }
  88022. /** @hidden */
  88023. export interface IGLTFAnimationChannel {
  88024. sampler: string;
  88025. target: IGLTFAnimationChannelTarget;
  88026. }
  88027. /** @hidden */
  88028. export interface IGLTFAnimationSampler {
  88029. input: string;
  88030. output: string;
  88031. interpolation?: string;
  88032. }
  88033. /** @hidden */
  88034. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  88035. channels?: IGLTFAnimationChannel[];
  88036. parameters?: {
  88037. [key: string]: string;
  88038. };
  88039. samplers?: {
  88040. [key: string]: IGLTFAnimationSampler;
  88041. };
  88042. }
  88043. /** @hidden */
  88044. export interface IGLTFNodeInstanceSkin {
  88045. skeletons: string[];
  88046. skin: string;
  88047. meshes: string[];
  88048. }
  88049. /** @hidden */
  88050. export interface IGLTFSkins extends IGLTFChildRootProperty {
  88051. bindShapeMatrix: number[];
  88052. inverseBindMatrices: string;
  88053. jointNames: string[];
  88054. babylonSkeleton?: Skeleton;
  88055. }
  88056. /** @hidden */
  88057. export interface IGLTFNode extends IGLTFChildRootProperty {
  88058. camera?: string;
  88059. children: string[];
  88060. skin?: string;
  88061. jointName?: string;
  88062. light?: string;
  88063. matrix: number[];
  88064. mesh?: string;
  88065. meshes?: string[];
  88066. rotation?: number[];
  88067. scale?: number[];
  88068. translation?: number[];
  88069. babylonNode?: Node;
  88070. }
  88071. /** @hidden */
  88072. export interface IGLTFScene extends IGLTFChildRootProperty {
  88073. nodes: string[];
  88074. }
  88075. /** @hidden */
  88076. export interface IGLTFRuntime {
  88077. extensions: {
  88078. [key: string]: any;
  88079. };
  88080. accessors: {
  88081. [key: string]: IGLTFAccessor;
  88082. };
  88083. buffers: {
  88084. [key: string]: IGLTFBuffer;
  88085. };
  88086. bufferViews: {
  88087. [key: string]: IGLTFBufferView;
  88088. };
  88089. meshes: {
  88090. [key: string]: IGLTFMesh;
  88091. };
  88092. lights: {
  88093. [key: string]: IGLTFLight;
  88094. };
  88095. cameras: {
  88096. [key: string]: IGLTFCamera;
  88097. };
  88098. nodes: {
  88099. [key: string]: IGLTFNode;
  88100. };
  88101. images: {
  88102. [key: string]: IGLTFImage;
  88103. };
  88104. textures: {
  88105. [key: string]: IGLTFTexture;
  88106. };
  88107. shaders: {
  88108. [key: string]: IGLTFShader;
  88109. };
  88110. programs: {
  88111. [key: string]: IGLTFProgram;
  88112. };
  88113. samplers: {
  88114. [key: string]: IGLTFSampler;
  88115. };
  88116. techniques: {
  88117. [key: string]: IGLTFTechnique;
  88118. };
  88119. materials: {
  88120. [key: string]: IGLTFMaterial;
  88121. };
  88122. animations: {
  88123. [key: string]: IGLTFAnimation;
  88124. };
  88125. skins: {
  88126. [key: string]: IGLTFSkins;
  88127. };
  88128. currentScene?: Object;
  88129. scenes: {
  88130. [key: string]: IGLTFScene;
  88131. };
  88132. extensionsUsed: string[];
  88133. extensionsRequired?: string[];
  88134. buffersCount: number;
  88135. shaderscount: number;
  88136. scene: Scene;
  88137. rootUrl: string;
  88138. loadedBufferCount: number;
  88139. loadedBufferViews: {
  88140. [name: string]: ArrayBufferView;
  88141. };
  88142. loadedShaderCount: number;
  88143. importOnlyMeshes: boolean;
  88144. importMeshesNames?: string[];
  88145. dummyNodes: Node[];
  88146. forAssetContainer: boolean;
  88147. }
  88148. /** @hidden */
  88149. export interface INodeToRoot {
  88150. bone: Bone;
  88151. node: IGLTFNode;
  88152. id: string;
  88153. }
  88154. /** @hidden */
  88155. export interface IJointNode {
  88156. node: IGLTFNode;
  88157. id: string;
  88158. }
  88159. }
  88160. declare module BABYLON.GLTF1 {
  88161. /**
  88162. * Utils functions for GLTF
  88163. * @hidden
  88164. */
  88165. export class GLTFUtils {
  88166. /**
  88167. * Sets the given "parameter" matrix
  88168. * @param scene: the Scene object
  88169. * @param source: the source node where to pick the matrix
  88170. * @param parameter: the GLTF technique parameter
  88171. * @param uniformName: the name of the shader's uniform
  88172. * @param shaderMaterial: the shader material
  88173. */
  88174. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  88175. /**
  88176. * Sets the given "parameter" matrix
  88177. * @param shaderMaterial: the shader material
  88178. * @param uniform: the name of the shader's uniform
  88179. * @param value: the value of the uniform
  88180. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  88181. */
  88182. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  88183. /**
  88184. * Returns the wrap mode of the texture
  88185. * @param mode: the mode value
  88186. */
  88187. static GetWrapMode(mode: number): number;
  88188. /**
  88189. * Returns the byte stride giving an accessor
  88190. * @param accessor: the GLTF accessor objet
  88191. */
  88192. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  88193. /**
  88194. * Returns the texture filter mode giving a mode value
  88195. * @param mode: the filter mode value
  88196. */
  88197. static GetTextureFilterMode(mode: number): ETextureFilterType;
  88198. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  88199. /**
  88200. * Returns a buffer from its accessor
  88201. * @param gltfRuntime: the GLTF runtime
  88202. * @param accessor: the GLTF accessor
  88203. */
  88204. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  88205. /**
  88206. * Decodes a buffer view into a string
  88207. * @param view: the buffer view
  88208. */
  88209. static DecodeBufferToText(view: ArrayBufferView): string;
  88210. /**
  88211. * Returns the default material of gltf. Related to
  88212. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  88213. * @param scene: the Babylon.js scene
  88214. */
  88215. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  88216. private static _DefaultMaterial;
  88217. }
  88218. }
  88219. declare module BABYLON.GLTF1 {
  88220. /**
  88221. * Implementation of the base glTF spec
  88222. * @hidden
  88223. */
  88224. export class GLTFLoaderBase {
  88225. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  88226. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  88227. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  88228. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  88229. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  88230. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  88231. }
  88232. /**
  88233. * glTF V1 Loader
  88234. * @hidden
  88235. */
  88236. export class GLTFLoader implements IGLTFLoader {
  88237. static Extensions: {
  88238. [name: string]: GLTFLoaderExtension;
  88239. };
  88240. static RegisterExtension(extension: GLTFLoaderExtension): void;
  88241. state: Nullable<GLTFLoaderState>;
  88242. dispose(): void;
  88243. private _importMeshAsync;
  88244. /**
  88245. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  88246. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  88247. * @param scene the scene the meshes should be added to
  88248. * @param forAssetContainer defines if the entities must be stored in the scene
  88249. * @param data gltf data containing information of the meshes in a loaded file
  88250. * @param rootUrl root url to load from
  88251. * @param onProgress event that fires when loading progress has occured
  88252. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  88253. */
  88254. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<ISceneLoaderAsyncResult>;
  88255. private _loadAsync;
  88256. /**
  88257. * Imports all objects from a loaded gltf file and adds them to the scene
  88258. * @param scene the scene the objects should be added to
  88259. * @param data gltf data containing information of the meshes in a loaded file
  88260. * @param rootUrl root url to load from
  88261. * @param onProgress event that fires when loading progress has occured
  88262. * @returns a promise which completes when objects have been loaded to the scene
  88263. */
  88264. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<void>;
  88265. private _loadShadersAsync;
  88266. private _loadBuffersAsync;
  88267. private _createNodes;
  88268. }
  88269. /** @hidden */
  88270. export abstract class GLTFLoaderExtension {
  88271. private _name;
  88272. constructor(name: string);
  88273. get name(): string;
  88274. /**
  88275. * Defines an override for loading the runtime
  88276. * Return true to stop further extensions from loading the runtime
  88277. */
  88278. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  88279. /**
  88280. * Defines an onverride for creating gltf runtime
  88281. * Return true to stop further extensions from creating the runtime
  88282. */
  88283. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  88284. /**
  88285. * Defines an override for loading buffers
  88286. * Return true to stop further extensions from loading this buffer
  88287. */
  88288. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  88289. /**
  88290. * Defines an override for loading texture buffers
  88291. * Return true to stop further extensions from loading this texture data
  88292. */
  88293. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  88294. /**
  88295. * Defines an override for creating textures
  88296. * Return true to stop further extensions from loading this texture
  88297. */
  88298. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  88299. /**
  88300. * Defines an override for loading shader strings
  88301. * Return true to stop further extensions from loading this shader data
  88302. */
  88303. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  88304. /**
  88305. * Defines an override for loading materials
  88306. * Return true to stop further extensions from loading this material
  88307. */
  88308. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  88309. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  88310. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  88311. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  88312. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  88313. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  88314. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  88315. private static LoadTextureBufferAsync;
  88316. private static CreateTextureAsync;
  88317. private static ApplyExtensions;
  88318. }
  88319. }
  88320. declare module BABYLON.GLTF1 {
  88321. /** @hidden */
  88322. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  88323. private _bin;
  88324. constructor();
  88325. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  88326. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  88327. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  88328. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  88329. }
  88330. }
  88331. declare module BABYLON.GLTF1 {
  88332. /** @hidden */
  88333. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  88334. constructor();
  88335. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  88336. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  88337. private _loadTexture;
  88338. }
  88339. }
  88340. declare module BABYLON.GLTF2.Loader {
  88341. /**
  88342. * Loader interface with an index field.
  88343. */
  88344. export interface IArrayItem {
  88345. /**
  88346. * The index of this item in the array.
  88347. */
  88348. index: number;
  88349. }
  88350. /**
  88351. * Loader interface with additional members.
  88352. */
  88353. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  88354. /** @hidden */
  88355. _data?: Promise<ArrayBufferView>;
  88356. /** @hidden */
  88357. _babylonVertexBuffer?: Promise<VertexBuffer>;
  88358. }
  88359. /**
  88360. * Loader interface with additional members.
  88361. */
  88362. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  88363. }
  88364. /** @hidden */
  88365. export interface _IAnimationSamplerData {
  88366. input: Float32Array;
  88367. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  88368. output: Float32Array;
  88369. }
  88370. /**
  88371. * Loader interface with additional members.
  88372. */
  88373. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  88374. /** @hidden */
  88375. _data?: Promise<_IAnimationSamplerData>;
  88376. }
  88377. /**
  88378. * Loader interface with additional members.
  88379. */
  88380. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  88381. channels: IAnimationChannel[];
  88382. samplers: IAnimationSampler[];
  88383. /** @hidden */
  88384. _babylonAnimationGroup?: AnimationGroup;
  88385. }
  88386. /**
  88387. * Loader interface with additional members.
  88388. */
  88389. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  88390. /** @hidden */
  88391. _data?: Promise<ArrayBufferView>;
  88392. }
  88393. /**
  88394. * Loader interface with additional members.
  88395. */
  88396. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  88397. /** @hidden */
  88398. _data?: Promise<ArrayBufferView>;
  88399. /** @hidden */
  88400. _babylonBuffer?: Promise<Buffer>;
  88401. }
  88402. /**
  88403. * Loader interface with additional members.
  88404. */
  88405. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  88406. }
  88407. /**
  88408. * Loader interface with additional members.
  88409. */
  88410. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  88411. /** @hidden */
  88412. _data?: Promise<ArrayBufferView>;
  88413. }
  88414. /**
  88415. * Loader interface with additional members.
  88416. */
  88417. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  88418. }
  88419. /**
  88420. * Loader interface with additional members.
  88421. */
  88422. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  88423. }
  88424. /**
  88425. * Loader interface with additional members.
  88426. */
  88427. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  88428. baseColorTexture?: ITextureInfo;
  88429. metallicRoughnessTexture?: ITextureInfo;
  88430. }
  88431. /**
  88432. * Loader interface with additional members.
  88433. */
  88434. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  88435. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  88436. normalTexture?: IMaterialNormalTextureInfo;
  88437. occlusionTexture?: IMaterialOcclusionTextureInfo;
  88438. emissiveTexture?: ITextureInfo;
  88439. /** @hidden */
  88440. _data?: {
  88441. [babylonDrawMode: number]: {
  88442. babylonMaterial: Material;
  88443. babylonMeshes: AbstractMesh[];
  88444. promise: Promise<void>;
  88445. };
  88446. };
  88447. }
  88448. /**
  88449. * Loader interface with additional members.
  88450. */
  88451. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  88452. primitives: IMeshPrimitive[];
  88453. }
  88454. /**
  88455. * Loader interface with additional members.
  88456. */
  88457. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  88458. /** @hidden */
  88459. _instanceData?: {
  88460. babylonSourceMesh: Mesh;
  88461. promise: Promise<any>;
  88462. };
  88463. }
  88464. /**
  88465. * Loader interface with additional members.
  88466. */
  88467. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  88468. /**
  88469. * The parent glTF node.
  88470. */
  88471. parent?: INode;
  88472. /** @hidden */
  88473. _babylonTransformNode?: TransformNode;
  88474. /** @hidden */
  88475. _primitiveBabylonMeshes?: AbstractMesh[];
  88476. /** @hidden */
  88477. _babylonBones?: Bone[];
  88478. /** @hidden */
  88479. _numMorphTargets?: number;
  88480. }
  88481. /** @hidden */
  88482. export interface _ISamplerData {
  88483. noMipMaps: boolean;
  88484. samplingMode: number;
  88485. wrapU: number;
  88486. wrapV: number;
  88487. }
  88488. /**
  88489. * Loader interface with additional members.
  88490. */
  88491. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  88492. /** @hidden */
  88493. _data?: _ISamplerData;
  88494. }
  88495. /**
  88496. * Loader interface with additional members.
  88497. */
  88498. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  88499. }
  88500. /**
  88501. * Loader interface with additional members.
  88502. */
  88503. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  88504. /** @hidden */
  88505. _data?: {
  88506. babylonSkeleton: Skeleton;
  88507. promise: Promise<void>;
  88508. };
  88509. }
  88510. /**
  88511. * Loader interface with additional members.
  88512. */
  88513. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  88514. /** @hidden */
  88515. _textureInfo: ITextureInfo;
  88516. }
  88517. /**
  88518. * Loader interface with additional members.
  88519. */
  88520. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  88521. /** false or undefined if the texture holds color data (true if data are roughness, normal, ...) */
  88522. nonColorData?: boolean;
  88523. }
  88524. /**
  88525. * Loader interface with additional members.
  88526. */
  88527. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  88528. accessors?: IAccessor[];
  88529. animations?: IAnimation[];
  88530. buffers?: IBuffer[];
  88531. bufferViews?: IBufferView[];
  88532. cameras?: ICamera[];
  88533. images?: IImage[];
  88534. materials?: IMaterial[];
  88535. meshes?: IMesh[];
  88536. nodes?: INode[];
  88537. samplers?: ISampler[];
  88538. scenes?: IScene[];
  88539. skins?: ISkin[];
  88540. textures?: ITexture[];
  88541. }
  88542. }
  88543. declare module BABYLON.GLTF2 {
  88544. /**
  88545. * Interface for a glTF loader extension.
  88546. */
  88547. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  88548. /**
  88549. * Called after the loader state changes to LOADING.
  88550. */
  88551. onLoading?(): void;
  88552. /**
  88553. * Called after the loader state changes to READY.
  88554. */
  88555. onReady?(): void;
  88556. /**
  88557. * Define this method to modify the default behavior when loading scenes.
  88558. * @param context The context when loading the asset
  88559. * @param scene The glTF scene property
  88560. * @returns A promise that resolves when the load is complete or null if not handled
  88561. */
  88562. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  88563. /**
  88564. * Define this method to modify the default behavior when loading nodes.
  88565. * @param context The context when loading the asset
  88566. * @param node The glTF node property
  88567. * @param assign A function called synchronously after parsing the glTF properties
  88568. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  88569. */
  88570. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  88571. /**
  88572. * Define this method to modify the default behavior when loading cameras.
  88573. * @param context The context when loading the asset
  88574. * @param camera The glTF camera property
  88575. * @param assign A function called synchronously after parsing the glTF properties
  88576. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  88577. */
  88578. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  88579. /**
  88580. * @hidden
  88581. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  88582. * @param context The context when loading the asset
  88583. * @param primitive The glTF mesh primitive property
  88584. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  88585. */
  88586. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  88587. /**
  88588. * @hidden
  88589. * Define this method to modify the default behavior when loading data for mesh primitives.
  88590. * @param context The context when loading the asset
  88591. * @param name The mesh name when loading the asset
  88592. * @param node The glTF node when loading the asset
  88593. * @param mesh The glTF mesh when loading the asset
  88594. * @param primitive The glTF mesh primitive property
  88595. * @param assign A function called synchronously after parsing the glTF properties
  88596. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  88597. */
  88598. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  88599. /**
  88600. * @hidden
  88601. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  88602. * @param context The context when loading the asset
  88603. * @param material The glTF material property
  88604. * @param assign A function called synchronously after parsing the glTF properties
  88605. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  88606. */
  88607. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  88608. /**
  88609. * Define this method to modify the default behavior when creating materials.
  88610. * @param context The context when loading the asset
  88611. * @param material The glTF material property
  88612. * @param babylonDrawMode The draw mode for the Babylon material
  88613. * @returns The Babylon material or null if not handled
  88614. */
  88615. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  88616. /**
  88617. * Define this method to modify the default behavior when loading material properties.
  88618. * @param context The context when loading the asset
  88619. * @param material The glTF material property
  88620. * @param babylonMaterial The Babylon material
  88621. * @returns A promise that resolves when the load is complete or null if not handled
  88622. */
  88623. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88624. /**
  88625. * Define this method to modify the default behavior when loading texture infos.
  88626. * @param context The context when loading the asset
  88627. * @param textureInfo The glTF texture info property
  88628. * @param assign A function called synchronously after parsing the glTF properties
  88629. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  88630. */
  88631. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  88632. /**
  88633. * @hidden
  88634. * Define this method to modify the default behavior when loading textures.
  88635. * @param context The context when loading the asset
  88636. * @param texture The glTF texture property
  88637. * @param assign A function called synchronously after parsing the glTF properties
  88638. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  88639. */
  88640. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  88641. /**
  88642. * Define this method to modify the default behavior when loading animations.
  88643. * @param context The context when loading the asset
  88644. * @param animation The glTF animation property
  88645. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  88646. */
  88647. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  88648. /**
  88649. * @hidden
  88650. * Define this method to modify the default behavior when loading skins.
  88651. * @param context The context when loading the asset
  88652. * @param node The glTF node property
  88653. * @param skin The glTF skin property
  88654. * @returns A promise that resolves when the load is complete or null if not handled
  88655. */
  88656. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  88657. /**
  88658. * @hidden
  88659. * Define this method to modify the default behavior when loading uris.
  88660. * @param context The context when loading the asset
  88661. * @param property The glTF property associated with the uri
  88662. * @param uri The uri to load
  88663. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  88664. */
  88665. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  88666. /**
  88667. * Define this method to modify the default behavior when loading buffer views.
  88668. * @param context The context when loading the asset
  88669. * @param bufferView The glTF buffer view property
  88670. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  88671. */
  88672. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  88673. /**
  88674. * Define this method to modify the default behavior when loading buffers.
  88675. * @param context The context when loading the asset
  88676. * @param buffer The glTF buffer property
  88677. * @param byteOffset The byte offset to load
  88678. * @param byteLength The byte length to load
  88679. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  88680. */
  88681. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  88682. }
  88683. }
  88684. declare module BABYLON.GLTF2 {
  88685. /**
  88686. * Helper class for working with arrays when loading the glTF asset
  88687. */
  88688. export class ArrayItem {
  88689. /**
  88690. * Gets an item from the given array.
  88691. * @param context The context when loading the asset
  88692. * @param array The array to get the item from
  88693. * @param index The index to the array
  88694. * @returns The array item
  88695. */
  88696. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  88697. /**
  88698. * Assign an `index` field to each item of the given array.
  88699. * @param array The array of items
  88700. */
  88701. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  88702. }
  88703. /**
  88704. * The glTF 2.0 loader
  88705. */
  88706. export class GLTFLoader implements IGLTFLoader {
  88707. /** @hidden */
  88708. _completePromises: Promise<any>[];
  88709. /** @hidden */
  88710. _forAssetContainer: boolean;
  88711. /** Storage */
  88712. _babylonLights: Light[];
  88713. /** @hidden */
  88714. _disableInstancedMesh: number;
  88715. private _disposed;
  88716. private _parent;
  88717. private _state;
  88718. private _extensions;
  88719. private _rootUrl;
  88720. private _fileName;
  88721. private _uniqueRootUrl;
  88722. private _gltf;
  88723. private _bin;
  88724. private _babylonScene;
  88725. private _rootBabylonMesh;
  88726. private _defaultBabylonMaterialData;
  88727. private static _RegisteredExtensions;
  88728. /**
  88729. * The default glTF sampler.
  88730. */
  88731. static readonly DefaultSampler: ISampler;
  88732. /**
  88733. * Registers a loader extension.
  88734. * @param name The name of the loader extension.
  88735. * @param factory The factory function that creates the loader extension.
  88736. */
  88737. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  88738. /**
  88739. * Unregisters a loader extension.
  88740. * @param name The name of the loader extension.
  88741. * @returns A boolean indicating whether the extension has been unregistered
  88742. */
  88743. static UnregisterExtension(name: string): boolean;
  88744. /**
  88745. * The loader state.
  88746. */
  88747. get state(): Nullable<GLTFLoaderState>;
  88748. /**
  88749. * The object that represents the glTF JSON.
  88750. */
  88751. get gltf(): IGLTF;
  88752. /**
  88753. * The BIN chunk of a binary glTF.
  88754. */
  88755. get bin(): Nullable<IDataBuffer>;
  88756. /**
  88757. * The parent file loader.
  88758. */
  88759. get parent(): GLTFFileLoader;
  88760. /**
  88761. * The Babylon scene when loading the asset.
  88762. */
  88763. get babylonScene(): Scene;
  88764. /**
  88765. * The root Babylon mesh when loading the asset.
  88766. */
  88767. get rootBabylonMesh(): Mesh;
  88768. /** @hidden */
  88769. constructor(parent: GLTFFileLoader);
  88770. /** @hidden */
  88771. dispose(): void;
  88772. /** @hidden */
  88773. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  88774. /** @hidden */
  88775. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  88776. private _loadAsync;
  88777. private _loadData;
  88778. private _setupData;
  88779. private _loadExtensions;
  88780. private _checkExtensions;
  88781. private _setState;
  88782. private _createRootNode;
  88783. /**
  88784. * Loads a glTF scene.
  88785. * @param context The context when loading the asset
  88786. * @param scene The glTF scene property
  88787. * @returns A promise that resolves when the load is complete
  88788. */
  88789. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  88790. private _forEachPrimitive;
  88791. private _getGeometries;
  88792. private _getMeshes;
  88793. private _getTransformNodes;
  88794. private _getSkeletons;
  88795. private _getAnimationGroups;
  88796. private _startAnimations;
  88797. /**
  88798. * Loads a glTF node.
  88799. * @param context The context when loading the asset
  88800. * @param node The glTF node property
  88801. * @param assign A function called synchronously after parsing the glTF properties
  88802. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  88803. */
  88804. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  88805. private _loadMeshAsync;
  88806. /**
  88807. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  88808. * @param context The context when loading the asset
  88809. * @param name The mesh name when loading the asset
  88810. * @param node The glTF node when loading the asset
  88811. * @param mesh The glTF mesh when loading the asset
  88812. * @param primitive The glTF mesh primitive property
  88813. * @param assign A function called synchronously after parsing the glTF properties
  88814. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  88815. */
  88816. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  88817. private _loadVertexDataAsync;
  88818. private _createMorphTargets;
  88819. private _loadMorphTargetsAsync;
  88820. private _loadMorphTargetVertexDataAsync;
  88821. private static _LoadTransform;
  88822. private _loadSkinAsync;
  88823. private _loadBones;
  88824. private _loadBone;
  88825. private _loadSkinInverseBindMatricesDataAsync;
  88826. private _updateBoneMatrices;
  88827. private _getNodeMatrix;
  88828. /**
  88829. * Loads a glTF camera.
  88830. * @param context The context when loading the asset
  88831. * @param camera The glTF camera property
  88832. * @param assign A function called synchronously after parsing the glTF properties
  88833. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  88834. */
  88835. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  88836. private _loadAnimationsAsync;
  88837. /**
  88838. * Loads a glTF animation.
  88839. * @param context The context when loading the asset
  88840. * @param animation The glTF animation property
  88841. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  88842. */
  88843. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  88844. /**
  88845. * @hidden Loads a glTF animation channel.
  88846. * @param context The context when loading the asset
  88847. * @param animationContext The context of the animation when loading the asset
  88848. * @param animation The glTF animation property
  88849. * @param channel The glTF animation channel property
  88850. * @param babylonAnimationGroup The babylon animation group property
  88851. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  88852. * @returns A void promise when the channel load is complete
  88853. */
  88854. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  88855. private _loadAnimationSamplerAsync;
  88856. /**
  88857. * Loads a glTF buffer.
  88858. * @param context The context when loading the asset
  88859. * @param buffer The glTF buffer property
  88860. * @param byteOffset The byte offset to use
  88861. * @param byteLength The byte length to use
  88862. * @returns A promise that resolves with the loaded data when the load is complete
  88863. */
  88864. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  88865. /**
  88866. * Loads a glTF buffer view.
  88867. * @param context The context when loading the asset
  88868. * @param bufferView The glTF buffer view property
  88869. * @returns A promise that resolves with the loaded data when the load is complete
  88870. */
  88871. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  88872. private _loadAccessorAsync;
  88873. /** @hidden */
  88874. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  88875. private _loadIndicesAccessorAsync;
  88876. private _loadVertexBufferViewAsync;
  88877. private _loadVertexAccessorAsync;
  88878. private _loadMaterialMetallicRoughnessPropertiesAsync;
  88879. /** @hidden */
  88880. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  88881. private _createDefaultMaterial;
  88882. /**
  88883. * Creates a Babylon material from a glTF material.
  88884. * @param context The context when loading the asset
  88885. * @param material The glTF material property
  88886. * @param babylonDrawMode The draw mode for the Babylon material
  88887. * @returns The Babylon material
  88888. */
  88889. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  88890. /**
  88891. * Loads properties from a glTF material into a Babylon material.
  88892. * @param context The context when loading the asset
  88893. * @param material The glTF material property
  88894. * @param babylonMaterial The Babylon material
  88895. * @returns A promise that resolves when the load is complete
  88896. */
  88897. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  88898. /**
  88899. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  88900. * @param context The context when loading the asset
  88901. * @param material The glTF material property
  88902. * @param babylonMaterial The Babylon material
  88903. * @returns A promise that resolves when the load is complete
  88904. */
  88905. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  88906. /**
  88907. * Loads the alpha properties from a glTF material into a Babylon material.
  88908. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  88909. * @param context The context when loading the asset
  88910. * @param material The glTF material property
  88911. * @param babylonMaterial The Babylon material
  88912. */
  88913. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  88914. /**
  88915. * Loads a glTF texture info.
  88916. * @param context The context when loading the asset
  88917. * @param textureInfo The glTF texture info property
  88918. * @param assign A function called synchronously after parsing the glTF properties
  88919. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  88920. */
  88921. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  88922. /** @hidden */
  88923. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  88924. /** @hidden */
  88925. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void, textureLoaderOptions?: any): Promise<BaseTexture>;
  88926. private _loadSampler;
  88927. /**
  88928. * Loads a glTF image.
  88929. * @param context The context when loading the asset
  88930. * @param image The glTF image property
  88931. * @returns A promise that resolves with the loaded data when the load is complete
  88932. */
  88933. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  88934. /**
  88935. * Loads a glTF uri.
  88936. * @param context The context when loading the asset
  88937. * @param property The glTF property associated with the uri
  88938. * @param uri The base64 or relative uri
  88939. * @returns A promise that resolves with the loaded data when the load is complete
  88940. */
  88941. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  88942. /**
  88943. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  88944. * @param babylonObject the Babylon object with metadata
  88945. * @param pointer the JSON pointer
  88946. */
  88947. static AddPointerMetadata(babylonObject: {
  88948. metadata: any;
  88949. }, pointer: string): void;
  88950. private static _GetTextureWrapMode;
  88951. private static _GetTextureSamplingMode;
  88952. private static _GetTypedArrayConstructor;
  88953. private static _GetTypedArray;
  88954. private static _GetNumComponents;
  88955. private static _ValidateUri;
  88956. /** @hidden */
  88957. static _GetDrawMode(context: string, mode: number | undefined): number;
  88958. private _compileMaterialsAsync;
  88959. private _compileShadowGeneratorsAsync;
  88960. private _forEachExtensions;
  88961. private _applyExtensions;
  88962. private _extensionsOnLoading;
  88963. private _extensionsOnReady;
  88964. private _extensionsLoadSceneAsync;
  88965. private _extensionsLoadNodeAsync;
  88966. private _extensionsLoadCameraAsync;
  88967. private _extensionsLoadVertexDataAsync;
  88968. private _extensionsLoadMeshPrimitiveAsync;
  88969. private _extensionsLoadMaterialAsync;
  88970. private _extensionsCreateMaterial;
  88971. private _extensionsLoadMaterialPropertiesAsync;
  88972. private _extensionsLoadTextureInfoAsync;
  88973. private _extensionsLoadTextureAsync;
  88974. private _extensionsLoadAnimationAsync;
  88975. private _extensionsLoadSkinAsync;
  88976. private _extensionsLoadUriAsync;
  88977. private _extensionsLoadBufferViewAsync;
  88978. private _extensionsLoadBufferAsync;
  88979. /**
  88980. * Helper method called by a loader extension to load an glTF extension.
  88981. * @param context The context when loading the asset
  88982. * @param property The glTF property to load the extension from
  88983. * @param extensionName The name of the extension to load
  88984. * @param actionAsync The action to run
  88985. * @returns The promise returned by actionAsync or null if the extension does not exist
  88986. */
  88987. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  88988. /**
  88989. * Helper method called by a loader extension to load a glTF extra.
  88990. * @param context The context when loading the asset
  88991. * @param property The glTF property to load the extra from
  88992. * @param extensionName The name of the extension to load
  88993. * @param actionAsync The action to run
  88994. * @returns The promise returned by actionAsync or null if the extra does not exist
  88995. */
  88996. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  88997. /**
  88998. * Checks for presence of an extension.
  88999. * @param name The name of the extension to check
  89000. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  89001. */
  89002. isExtensionUsed(name: string): boolean;
  89003. /**
  89004. * Increments the indentation level and logs a message.
  89005. * @param message The message to log
  89006. */
  89007. logOpen(message: string): void;
  89008. /**
  89009. * Decrements the indentation level.
  89010. */
  89011. logClose(): void;
  89012. /**
  89013. * Logs a message
  89014. * @param message The message to log
  89015. */
  89016. log(message: string): void;
  89017. /**
  89018. * Starts a performance counter.
  89019. * @param counterName The name of the performance counter
  89020. */
  89021. startPerformanceCounter(counterName: string): void;
  89022. /**
  89023. * Ends a performance counter.
  89024. * @param counterName The name of the performance counter
  89025. */
  89026. endPerformanceCounter(counterName: string): void;
  89027. }
  89028. }
  89029. declare module BABYLON.GLTF2.Loader.Extensions {
  89030. /** @hidden */
  89031. interface IEXTLightsImageBased_LightImageBased {
  89032. _babylonTexture?: BaseTexture;
  89033. _loaded?: Promise<void>;
  89034. }
  89035. /**
  89036. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  89037. */
  89038. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  89039. /**
  89040. * The name of this extension.
  89041. */
  89042. readonly name: string;
  89043. /**
  89044. * Defines whether this extension is enabled.
  89045. */
  89046. enabled: boolean;
  89047. private _loader;
  89048. private _lights?;
  89049. /** @hidden */
  89050. constructor(loader: GLTFLoader);
  89051. /** @hidden */
  89052. dispose(): void;
  89053. /** @hidden */
  89054. onLoading(): void;
  89055. /** @hidden */
  89056. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  89057. private _loadLightAsync;
  89058. }
  89059. }
  89060. declare module BABYLON.GLTF2.Loader.Extensions {
  89061. /**
  89062. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  89063. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  89064. * !!! Experimental Extension Subject to Changes !!!
  89065. */
  89066. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  89067. /**
  89068. * The name of this extension.
  89069. */
  89070. readonly name: string;
  89071. /**
  89072. * Defines whether this extension is enabled.
  89073. */
  89074. enabled: boolean;
  89075. private _loader;
  89076. /** @hidden */
  89077. constructor(loader: GLTFLoader);
  89078. /** @hidden */
  89079. dispose(): void;
  89080. /** @hidden */
  89081. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  89082. }
  89083. }
  89084. declare module BABYLON.GLTF2.Loader.Extensions {
  89085. /**
  89086. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/EXT_meshopt_compression)
  89087. *
  89088. * This extension uses a WebAssembly decoder module from https://github.com/zeux/meshoptimizer/tree/master/js
  89089. */
  89090. export class EXT_meshopt_compression implements IGLTFLoaderExtension {
  89091. /**
  89092. * The name of this extension.
  89093. */
  89094. readonly name: string;
  89095. /**
  89096. * Defines whether this extension is enabled.
  89097. */
  89098. enabled: boolean;
  89099. /**
  89100. * Path to decoder module; defaults to https://preview.babylonjs.com/meshopt_decoder.js
  89101. */
  89102. static DecoderPath: string;
  89103. private _loader;
  89104. private _decoderPromise?;
  89105. /** @hidden */
  89106. constructor(loader: GLTFLoader);
  89107. /** @hidden */
  89108. dispose(): void;
  89109. /** @hidden */
  89110. loadBufferViewAsync(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  89111. }
  89112. }
  89113. declare module BABYLON.GLTF2.Loader.Extensions {
  89114. /**
  89115. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_texture_webp/)
  89116. */
  89117. export class EXT_texture_webp implements IGLTFLoaderExtension {
  89118. /** The name of this extension. */
  89119. readonly name: string;
  89120. /** Defines whether this extension is enabled. */
  89121. enabled: boolean;
  89122. private _loader;
  89123. /** @hidden */
  89124. constructor(loader: GLTFLoader);
  89125. /** @hidden */
  89126. dispose(): void;
  89127. /** @hidden */
  89128. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  89129. }
  89130. }
  89131. declare module BABYLON.GLTF2.Loader.Extensions {
  89132. /**
  89133. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  89134. */
  89135. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  89136. /**
  89137. * The name of this extension.
  89138. */
  89139. readonly name: string;
  89140. /**
  89141. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  89142. */
  89143. dracoCompression?: DracoCompression;
  89144. /**
  89145. * Defines whether this extension is enabled.
  89146. */
  89147. enabled: boolean;
  89148. private _loader;
  89149. /** @hidden */
  89150. constructor(loader: GLTFLoader);
  89151. /** @hidden */
  89152. dispose(): void;
  89153. /** @hidden */
  89154. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  89155. }
  89156. }
  89157. declare module BABYLON.GLTF2.Loader.Extensions {
  89158. /**
  89159. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  89160. */
  89161. export class KHR_lights implements IGLTFLoaderExtension {
  89162. /**
  89163. * The name of this extension.
  89164. */
  89165. readonly name: string;
  89166. /**
  89167. * Defines whether this extension is enabled.
  89168. */
  89169. enabled: boolean;
  89170. private _loader;
  89171. private _lights?;
  89172. /** @hidden */
  89173. constructor(loader: GLTFLoader);
  89174. /** @hidden */
  89175. dispose(): void;
  89176. /** @hidden */
  89177. onLoading(): void;
  89178. /** @hidden */
  89179. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  89180. }
  89181. }
  89182. declare module BABYLON.GLTF2.Loader.Extensions {
  89183. /**
  89184. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  89185. */
  89186. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  89187. /**
  89188. * The name of this extension.
  89189. */
  89190. readonly name: string;
  89191. /**
  89192. * Defines whether this extension is enabled.
  89193. */
  89194. enabled: boolean;
  89195. /**
  89196. * Defines a number that determines the order the extensions are applied.
  89197. */
  89198. order: number;
  89199. private _loader;
  89200. /** @hidden */
  89201. constructor(loader: GLTFLoader);
  89202. /** @hidden */
  89203. dispose(): void;
  89204. /** @hidden */
  89205. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  89206. private _loadSpecularGlossinessPropertiesAsync;
  89207. }
  89208. }
  89209. declare module BABYLON.GLTF2.Loader.Extensions {
  89210. /**
  89211. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  89212. */
  89213. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  89214. /**
  89215. * The name of this extension.
  89216. */
  89217. readonly name: string;
  89218. /**
  89219. * Defines whether this extension is enabled.
  89220. */
  89221. enabled: boolean;
  89222. /**
  89223. * Defines a number that determines the order the extensions are applied.
  89224. */
  89225. order: number;
  89226. private _loader;
  89227. /** @hidden */
  89228. constructor(loader: GLTFLoader);
  89229. /** @hidden */
  89230. dispose(): void;
  89231. /** @hidden */
  89232. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  89233. private _loadUnlitPropertiesAsync;
  89234. }
  89235. }
  89236. declare module BABYLON.GLTF2.Loader.Extensions {
  89237. /**
  89238. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_clearcoat/README.md)
  89239. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  89240. */
  89241. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  89242. /**
  89243. * The name of this extension.
  89244. */
  89245. readonly name: string;
  89246. /**
  89247. * Defines whether this extension is enabled.
  89248. */
  89249. enabled: boolean;
  89250. /**
  89251. * Defines a number that determines the order the extensions are applied.
  89252. */
  89253. order: number;
  89254. private _loader;
  89255. /** @hidden */
  89256. constructor(loader: GLTFLoader);
  89257. /** @hidden */
  89258. dispose(): void;
  89259. /** @hidden */
  89260. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  89261. private _loadClearCoatPropertiesAsync;
  89262. }
  89263. }
  89264. declare module BABYLON.GLTF2.Loader.Extensions {
  89265. /**
  89266. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_sheen/README.md)
  89267. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  89268. * !!! Experimental Extension Subject to Changes !!!
  89269. */
  89270. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  89271. /**
  89272. * The name of this extension.
  89273. */
  89274. readonly name: string;
  89275. /**
  89276. * Defines whether this extension is enabled.
  89277. */
  89278. enabled: boolean;
  89279. /**
  89280. * Defines a number that determines the order the extensions are applied.
  89281. */
  89282. order: number;
  89283. private _loader;
  89284. /** @hidden */
  89285. constructor(loader: GLTFLoader);
  89286. /** @hidden */
  89287. dispose(): void;
  89288. /** @hidden */
  89289. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  89290. private _loadSheenPropertiesAsync;
  89291. }
  89292. }
  89293. declare module BABYLON.GLTF2.Loader.Extensions {
  89294. /**
  89295. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  89296. * !!! Experimental Extension Subject to Changes !!!
  89297. */
  89298. export class KHR_materials_specular implements IGLTFLoaderExtension {
  89299. /**
  89300. * The name of this extension.
  89301. */
  89302. readonly name: string;
  89303. /**
  89304. * Defines whether this extension is enabled.
  89305. */
  89306. enabled: boolean;
  89307. /**
  89308. * Defines a number that determines the order the extensions are applied.
  89309. */
  89310. order: number;
  89311. private _loader;
  89312. /** @hidden */
  89313. constructor(loader: GLTFLoader);
  89314. /** @hidden */
  89315. dispose(): void;
  89316. /** @hidden */
  89317. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  89318. private _loadSpecularPropertiesAsync;
  89319. }
  89320. }
  89321. declare module BABYLON.GLTF2.Loader.Extensions {
  89322. /**
  89323. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  89324. * !!! Experimental Extension Subject to Changes !!!
  89325. */
  89326. export class KHR_materials_ior implements IGLTFLoaderExtension {
  89327. /**
  89328. * Default ior Value from the spec.
  89329. */
  89330. private static readonly _DEFAULT_IOR;
  89331. /**
  89332. * The name of this extension.
  89333. */
  89334. readonly name: string;
  89335. /**
  89336. * Defines whether this extension is enabled.
  89337. */
  89338. enabled: boolean;
  89339. /**
  89340. * Defines a number that determines the order the extensions are applied.
  89341. */
  89342. order: number;
  89343. private _loader;
  89344. /** @hidden */
  89345. constructor(loader: GLTFLoader);
  89346. /** @hidden */
  89347. dispose(): void;
  89348. /** @hidden */
  89349. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  89350. private _loadIorPropertiesAsync;
  89351. }
  89352. }
  89353. declare module BABYLON.GLTF2.Loader.Extensions {
  89354. /**
  89355. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_variants/README.md)
  89356. */
  89357. export class KHR_materials_variants implements IGLTFLoaderExtension {
  89358. /**
  89359. * The name of this extension.
  89360. */
  89361. readonly name: string;
  89362. /**
  89363. * Defines whether this extension is enabled.
  89364. */
  89365. enabled: boolean;
  89366. private _loader;
  89367. private _variants?;
  89368. /** @hidden */
  89369. constructor(loader: GLTFLoader);
  89370. /** @hidden */
  89371. dispose(): void;
  89372. /**
  89373. * Gets the list of available variant names for this asset.
  89374. * @param rootMesh The glTF root mesh
  89375. * @returns the list of all the variant names for this model
  89376. */
  89377. static GetAvailableVariants(rootMesh: Mesh): string[];
  89378. /**
  89379. * Gets the list of available variant names for this asset.
  89380. * @param rootMesh The glTF root mesh
  89381. * @returns the list of all the variant names for this model
  89382. */
  89383. getAvailableVariants(rootMesh: Mesh): string[];
  89384. /**
  89385. * Select a variant given a variant name or a list of variant names.
  89386. * @param rootMesh The glTF root mesh
  89387. * @param variantName The variant name(s) to select.
  89388. */
  89389. static SelectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  89390. /**
  89391. * Select a variant given a variant name or a list of variant names.
  89392. * @param rootMesh The glTF root mesh
  89393. * @param variantName The variant name(s) to select.
  89394. */
  89395. selectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  89396. /**
  89397. * Reset back to the original before selecting a variant.
  89398. * @param rootMesh The glTF root mesh
  89399. */
  89400. static Reset(rootMesh: Mesh): void;
  89401. /**
  89402. * Reset back to the original before selecting a variant.
  89403. * @param rootMesh The glTF root mesh
  89404. */
  89405. reset(rootMesh: Mesh): void;
  89406. /**
  89407. * Gets the last selected variant name(s) or null if original.
  89408. * @param rootMesh The glTF root mesh
  89409. * @returns The selected variant name(s).
  89410. */
  89411. static GetLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  89412. /**
  89413. * Gets the last selected variant name(s) or null if original.
  89414. * @param rootMesh The glTF root mesh
  89415. * @returns The selected variant name(s).
  89416. */
  89417. getLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  89418. private static _GetExtensionMetadata;
  89419. /** @hidden */
  89420. onLoading(): void;
  89421. /** @hidden */
  89422. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  89423. }
  89424. }
  89425. declare module BABYLON.GLTF2.Loader.Extensions {
  89426. /**
  89427. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_transmission/README.md)
  89428. */
  89429. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  89430. /**
  89431. * The name of this extension.
  89432. */
  89433. readonly name: string;
  89434. /**
  89435. * Defines whether this extension is enabled.
  89436. */
  89437. enabled: boolean;
  89438. /**
  89439. * Defines a number that determines the order the extensions are applied.
  89440. */
  89441. order: number;
  89442. private _loader;
  89443. /** @hidden */
  89444. constructor(loader: GLTFLoader);
  89445. /** @hidden */
  89446. dispose(): void;
  89447. /** @hidden */
  89448. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  89449. private _loadTransparentPropertiesAsync;
  89450. }
  89451. }
  89452. declare module BABYLON.GLTF2.Loader.Extensions {
  89453. /**
  89454. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1825)
  89455. * !!! Experimental Extension Subject to Changes !!!
  89456. */
  89457. export class KHR_materials_translucency implements IGLTFLoaderExtension {
  89458. /**
  89459. * The name of this extension.
  89460. */
  89461. readonly name: string;
  89462. /**
  89463. * Defines whether this extension is enabled.
  89464. */
  89465. enabled: boolean;
  89466. /**
  89467. * Defines a number that determines the order the extensions are applied.
  89468. */
  89469. order: number;
  89470. private _loader;
  89471. /** @hidden */
  89472. constructor(loader: GLTFLoader);
  89473. /** @hidden */
  89474. dispose(): void;
  89475. /** @hidden */
  89476. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  89477. private _loadTranslucentPropertiesAsync;
  89478. }
  89479. }
  89480. declare module BABYLON.GLTF2.Loader.Extensions {
  89481. /**
  89482. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  89483. */
  89484. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  89485. /**
  89486. * The name of this extension.
  89487. */
  89488. readonly name: string;
  89489. /**
  89490. * Defines whether this extension is enabled.
  89491. */
  89492. enabled: boolean;
  89493. /** @hidden */
  89494. constructor(loader: GLTFLoader);
  89495. /** @hidden */
  89496. dispose(): void;
  89497. }
  89498. }
  89499. declare module BABYLON.GLTF2.Loader.Extensions {
  89500. /**
  89501. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  89502. * !!! Experimental Extension Subject to Changes !!!
  89503. */
  89504. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  89505. /** The name of this extension. */
  89506. readonly name: string;
  89507. /** Defines whether this extension is enabled. */
  89508. enabled: boolean;
  89509. private _loader;
  89510. /** @hidden */
  89511. constructor(loader: GLTFLoader);
  89512. /** @hidden */
  89513. dispose(): void;
  89514. /** @hidden */
  89515. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  89516. }
  89517. }
  89518. declare module BABYLON.GLTF2.Loader.Extensions {
  89519. /**
  89520. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  89521. */
  89522. export class KHR_texture_transform implements IGLTFLoaderExtension {
  89523. /**
  89524. * The name of this extension.
  89525. */
  89526. readonly name: string;
  89527. /**
  89528. * Defines whether this extension is enabled.
  89529. */
  89530. enabled: boolean;
  89531. private _loader;
  89532. /** @hidden */
  89533. constructor(loader: GLTFLoader);
  89534. /** @hidden */
  89535. dispose(): void;
  89536. /** @hidden */
  89537. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  89538. }
  89539. }
  89540. declare module BABYLON.GLTF2.Loader.Extensions {
  89541. /**
  89542. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1893)
  89543. * !!! Experimental Extension Subject to Changes !!!
  89544. */
  89545. export class KHR_xmp_json_ld implements IGLTFLoaderExtension {
  89546. /**
  89547. * The name of this extension.
  89548. */
  89549. readonly name: string;
  89550. /**
  89551. * Defines whether this extension is enabled.
  89552. */
  89553. enabled: boolean;
  89554. /**
  89555. * Defines a number that determines the order the extensions are applied.
  89556. */
  89557. order: number;
  89558. private _loader;
  89559. /** @hidden */
  89560. constructor(loader: GLTFLoader);
  89561. /** @hidden */
  89562. dispose(): void;
  89563. /**
  89564. * Called after the loader state changes to LOADING.
  89565. */
  89566. onLoading(): void;
  89567. }
  89568. }
  89569. declare module BABYLON.GLTF2.Loader.Extensions {
  89570. /**
  89571. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  89572. */
  89573. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  89574. /**
  89575. * The name of this extension.
  89576. */
  89577. readonly name: string;
  89578. /**
  89579. * Defines whether this extension is enabled.
  89580. */
  89581. enabled: boolean;
  89582. private _loader;
  89583. private _clips;
  89584. private _emitters;
  89585. /** @hidden */
  89586. constructor(loader: GLTFLoader);
  89587. /** @hidden */
  89588. dispose(): void;
  89589. /** @hidden */
  89590. onLoading(): void;
  89591. /** @hidden */
  89592. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  89593. /** @hidden */
  89594. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  89595. /** @hidden */
  89596. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  89597. private _loadClipAsync;
  89598. private _loadEmitterAsync;
  89599. private _getEventAction;
  89600. private _loadAnimationEventAsync;
  89601. }
  89602. }
  89603. declare module BABYLON.GLTF2.Loader.Extensions {
  89604. /**
  89605. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  89606. */
  89607. export class MSFT_lod implements IGLTFLoaderExtension {
  89608. /**
  89609. * The name of this extension.
  89610. */
  89611. readonly name: string;
  89612. /**
  89613. * Defines whether this extension is enabled.
  89614. */
  89615. enabled: boolean;
  89616. /**
  89617. * Defines a number that determines the order the extensions are applied.
  89618. */
  89619. order: number;
  89620. /**
  89621. * Maximum number of LODs to load, starting from the lowest LOD.
  89622. */
  89623. maxLODsToLoad: number;
  89624. /**
  89625. * Observable raised when all node LODs of one level are loaded.
  89626. * The event data is the index of the loaded LOD starting from zero.
  89627. * Dispose the loader to cancel the loading of the next level of LODs.
  89628. */
  89629. onNodeLODsLoadedObservable: Observable<number>;
  89630. /**
  89631. * Observable raised when all material LODs of one level are loaded.
  89632. * The event data is the index of the loaded LOD starting from zero.
  89633. * Dispose the loader to cancel the loading of the next level of LODs.
  89634. */
  89635. onMaterialLODsLoadedObservable: Observable<number>;
  89636. private _loader;
  89637. private _bufferLODs;
  89638. private _nodeIndexLOD;
  89639. private _nodeSignalLODs;
  89640. private _nodePromiseLODs;
  89641. private _nodeBufferLODs;
  89642. private _materialIndexLOD;
  89643. private _materialSignalLODs;
  89644. private _materialPromiseLODs;
  89645. private _materialBufferLODs;
  89646. /** @hidden */
  89647. constructor(loader: GLTFLoader);
  89648. /** @hidden */
  89649. dispose(): void;
  89650. /** @hidden */
  89651. onReady(): void;
  89652. /** @hidden */
  89653. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  89654. /** @hidden */
  89655. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  89656. /** @hidden */
  89657. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  89658. /** @hidden */
  89659. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  89660. /** @hidden */
  89661. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  89662. private _loadBufferLOD;
  89663. /**
  89664. * Gets an array of LOD properties from lowest to highest.
  89665. */
  89666. private _getLODs;
  89667. private _disposeTransformNode;
  89668. private _disposeMaterials;
  89669. }
  89670. }
  89671. declare module BABYLON.GLTF2.Loader.Extensions {
  89672. /** @hidden */
  89673. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  89674. readonly name: string;
  89675. enabled: boolean;
  89676. private _loader;
  89677. constructor(loader: GLTFLoader);
  89678. dispose(): void;
  89679. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  89680. }
  89681. }
  89682. declare module BABYLON.GLTF2.Loader.Extensions {
  89683. /** @hidden */
  89684. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  89685. readonly name: string;
  89686. enabled: boolean;
  89687. private _loader;
  89688. constructor(loader: GLTFLoader);
  89689. dispose(): void;
  89690. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  89691. }
  89692. }
  89693. declare module BABYLON.GLTF2.Loader.Extensions {
  89694. /**
  89695. * Store glTF extras (if present) in BJS objects' metadata
  89696. */
  89697. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  89698. /**
  89699. * The name of this extension.
  89700. */
  89701. readonly name: string;
  89702. /**
  89703. * Defines whether this extension is enabled.
  89704. */
  89705. enabled: boolean;
  89706. private _loader;
  89707. private _assignExtras;
  89708. /** @hidden */
  89709. constructor(loader: GLTFLoader);
  89710. /** @hidden */
  89711. dispose(): void;
  89712. /** @hidden */
  89713. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  89714. /** @hidden */
  89715. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  89716. /** @hidden */
  89717. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  89718. }
  89719. }
  89720. declare module BABYLON {
  89721. /**
  89722. * Class reading and parsing the MTL file bundled with the obj file.
  89723. */
  89724. export class MTLFileLoader {
  89725. /**
  89726. * Invert Y-Axis of referenced textures on load
  89727. */
  89728. static INVERT_TEXTURE_Y: boolean;
  89729. /**
  89730. * All material loaded from the mtl will be set here
  89731. */
  89732. materials: StandardMaterial[];
  89733. /**
  89734. * This function will read the mtl file and create each material described inside
  89735. * This function could be improve by adding :
  89736. * -some component missing (Ni, Tf...)
  89737. * -including the specific options available
  89738. *
  89739. * @param scene defines the scene the material will be created in
  89740. * @param data defines the mtl data to parse
  89741. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  89742. * @param forAssetContainer defines if the material should be registered in the scene
  89743. */
  89744. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  89745. /**
  89746. * Gets the texture for the material.
  89747. *
  89748. * If the material is imported from input file,
  89749. * We sanitize the url to ensure it takes the textre from aside the material.
  89750. *
  89751. * @param rootUrl The root url to load from
  89752. * @param value The value stored in the mtl
  89753. * @return The Texture
  89754. */
  89755. private static _getTexture;
  89756. }
  89757. }
  89758. declare module BABYLON {
  89759. /**
  89760. * Options for loading OBJ/MTL files
  89761. */
  89762. type MeshLoadOptions = {
  89763. /**
  89764. * Defines if UVs are optimized by default during load.
  89765. */
  89766. OptimizeWithUV: boolean;
  89767. /**
  89768. * Defines custom scaling of UV coordinates of loaded meshes.
  89769. */
  89770. UVScaling: Vector2;
  89771. /**
  89772. * Invert model on y-axis (does a model scaling inversion)
  89773. */
  89774. InvertY: boolean;
  89775. /**
  89776. * Invert Y-Axis of referenced textures on load
  89777. */
  89778. InvertTextureY: boolean;
  89779. /**
  89780. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  89781. */
  89782. ImportVertexColors: boolean;
  89783. /**
  89784. * Compute the normals for the model, even if normals are present in the file.
  89785. */
  89786. ComputeNormals: boolean;
  89787. /**
  89788. * 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.
  89789. * Using OptimizehNormals = true will help smoothing the lighting by averaging the normals of those vertices.
  89790. */
  89791. OptimizeNormals: boolean;
  89792. /**
  89793. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  89794. */
  89795. SkipMaterials: boolean;
  89796. /**
  89797. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  89798. */
  89799. MaterialLoadingFailsSilently: boolean;
  89800. };
  89801. /**
  89802. * OBJ file type loader.
  89803. * This is a babylon scene loader plugin.
  89804. */
  89805. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  89806. /**
  89807. * Defines if UVs are optimized by default during load.
  89808. */
  89809. static OPTIMIZE_WITH_UV: boolean;
  89810. /**
  89811. * Invert model on y-axis (does a model scaling inversion)
  89812. */
  89813. static INVERT_Y: boolean;
  89814. /**
  89815. * Invert Y-Axis of referenced textures on load
  89816. */
  89817. static get INVERT_TEXTURE_Y(): boolean;
  89818. static set INVERT_TEXTURE_Y(value: boolean);
  89819. /**
  89820. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  89821. */
  89822. static IMPORT_VERTEX_COLORS: boolean;
  89823. /**
  89824. * Compute the normals for the model, even if normals are present in the file.
  89825. */
  89826. static COMPUTE_NORMALS: boolean;
  89827. /**
  89828. * 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.
  89829. * Using OptimizehNormals = true will help smoothing the lighting by averaging the normals of those vertices.
  89830. */
  89831. static OPTIMIZE_NORMALS: boolean;
  89832. /**
  89833. * Defines custom scaling of UV coordinates of loaded meshes.
  89834. */
  89835. static UV_SCALING: Vector2;
  89836. /**
  89837. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  89838. */
  89839. static SKIP_MATERIALS: boolean;
  89840. /**
  89841. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  89842. *
  89843. * Defaults to true for backwards compatibility.
  89844. */
  89845. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  89846. /**
  89847. * Defines the name of the plugin.
  89848. */
  89849. name: string;
  89850. /**
  89851. * Defines the extension the plugin is able to load.
  89852. */
  89853. extensions: string;
  89854. /** @hidden */
  89855. obj: RegExp;
  89856. /** @hidden */
  89857. group: RegExp;
  89858. /** @hidden */
  89859. mtllib: RegExp;
  89860. /** @hidden */
  89861. usemtl: RegExp;
  89862. /** @hidden */
  89863. smooth: RegExp;
  89864. /** @hidden */
  89865. vertexPattern: RegExp;
  89866. /** @hidden */
  89867. normalPattern: RegExp;
  89868. /** @hidden */
  89869. uvPattern: RegExp;
  89870. /** @hidden */
  89871. facePattern1: RegExp;
  89872. /** @hidden */
  89873. facePattern2: RegExp;
  89874. /** @hidden */
  89875. facePattern3: RegExp;
  89876. /** @hidden */
  89877. facePattern4: RegExp;
  89878. /** @hidden */
  89879. facePattern5: RegExp;
  89880. private _forAssetContainer;
  89881. private _meshLoadOptions;
  89882. /**
  89883. * Creates loader for .OBJ files
  89884. *
  89885. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  89886. */
  89887. constructor(meshLoadOptions?: MeshLoadOptions);
  89888. private static get currentMeshLoadOptions();
  89889. /**
  89890. * Calls synchronously the MTL file attached to this obj.
  89891. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  89892. * Without this function materials are not displayed in the first frame (but displayed after).
  89893. * In consequence it is impossible to get material information in your HTML file
  89894. *
  89895. * @param url The URL of the MTL file
  89896. * @param rootUrl
  89897. * @param onSuccess Callback function to be called when the MTL file is loaded
  89898. * @private
  89899. */
  89900. private _loadMTL;
  89901. /**
  89902. * Instantiates a OBJ file loader plugin.
  89903. * @returns the created plugin
  89904. */
  89905. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  89906. /**
  89907. * If the data string can be loaded directly.
  89908. *
  89909. * @param data string containing the file data
  89910. * @returns if the data can be loaded directly
  89911. */
  89912. canDirectLoad(data: string): boolean;
  89913. /**
  89914. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  89915. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  89916. * @param scene the scene the meshes should be added to
  89917. * @param data the OBJ data to load
  89918. * @param rootUrl root url to load from
  89919. * @param onProgress event that fires when loading progress has occured
  89920. * @param fileName Defines the name of the file to load
  89921. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  89922. */
  89923. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  89924. /**
  89925. * Imports all objects from the loaded OBJ data and adds them to the scene
  89926. * @param scene the scene the objects should be added to
  89927. * @param data the OBJ data to load
  89928. * @param rootUrl root url to load from
  89929. * @param onProgress event that fires when loading progress has occured
  89930. * @param fileName Defines the name of the file to load
  89931. * @returns a promise which completes when objects have been loaded to the scene
  89932. */
  89933. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  89934. /**
  89935. * Load into an asset container.
  89936. * @param scene The scene to load into
  89937. * @param data The data to import
  89938. * @param rootUrl The root url for scene and resources
  89939. * @param onProgress The callback when the load progresses
  89940. * @param fileName Defines the name of the file to load
  89941. * @returns The loaded asset container
  89942. */
  89943. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  89944. private _optimizeNormals;
  89945. /**
  89946. * Read the OBJ file and create an Array of meshes.
  89947. * Each mesh contains all information given by the OBJ and the MTL file.
  89948. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  89949. *
  89950. * @param meshesNames
  89951. * @param scene Scene The scene where are displayed the data
  89952. * @param data String The content of the obj file
  89953. * @param rootUrl String The path to the folder
  89954. * @returns Array<AbstractMesh>
  89955. * @private
  89956. */
  89957. private _parseSolid;
  89958. }
  89959. }
  89960. declare module BABYLON {
  89961. /**
  89962. * STL file type loader.
  89963. * This is a babylon scene loader plugin.
  89964. */
  89965. export class STLFileLoader implements ISceneLoaderPlugin {
  89966. /** @hidden */
  89967. solidPattern: RegExp;
  89968. /** @hidden */
  89969. facetsPattern: RegExp;
  89970. /** @hidden */
  89971. normalPattern: RegExp;
  89972. /** @hidden */
  89973. vertexPattern: RegExp;
  89974. /**
  89975. * Defines the name of the plugin.
  89976. */
  89977. name: string;
  89978. /**
  89979. * Defines the extensions the stl loader is able to load.
  89980. * force data to come in as an ArrayBuffer
  89981. * we'll convert to string if it looks like it's an ASCII .stl
  89982. */
  89983. extensions: ISceneLoaderPluginExtensions;
  89984. /**
  89985. * Import meshes into a scene.
  89986. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  89987. * @param scene The scene to import into
  89988. * @param data The data to import
  89989. * @param rootUrl The root url for scene and resources
  89990. * @param meshes The meshes array to import into
  89991. * @param particleSystems The particle systems array to import into
  89992. * @param skeletons The skeletons array to import into
  89993. * @param onError The callback when import fails
  89994. * @returns True if successful or false otherwise
  89995. */
  89996. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  89997. /**
  89998. * Load into a scene.
  89999. * @param scene The scene to load into
  90000. * @param data The data to import
  90001. * @param rootUrl The root url for scene and resources
  90002. * @param onError The callback when import fails
  90003. * @returns true if successful or false otherwise
  90004. */
  90005. load(scene: Scene, data: any, rootUrl: string): boolean;
  90006. /**
  90007. * Load into an asset container.
  90008. * @param scene The scene to load into
  90009. * @param data The data to import
  90010. * @param rootUrl The root url for scene and resources
  90011. * @param onError The callback when import fails
  90012. * @returns The loaded asset container
  90013. */
  90014. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  90015. private _isBinary;
  90016. private _parseBinary;
  90017. private _parseASCII;
  90018. }
  90019. }
  90020. declare module BABYLON {
  90021. /**
  90022. * Class for generating OBJ data from a Babylon scene.
  90023. */
  90024. export class OBJExport {
  90025. /**
  90026. * Exports the geometry of a Mesh array in .OBJ file format (text)
  90027. * @param mesh defines the list of meshes to serialize
  90028. * @param materials defines if materials should be exported
  90029. * @param matlibname defines the name of the associated mtl file
  90030. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  90031. * @returns the OBJ content
  90032. */
  90033. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  90034. /**
  90035. * Exports the material(s) of a mesh in .MTL file format (text)
  90036. * @param mesh defines the mesh to extract the material from
  90037. * @returns the mtl content
  90038. */
  90039. static MTL(mesh: Mesh): string;
  90040. }
  90041. }
  90042. declare module BABYLON {
  90043. /** @hidden */
  90044. export var __IGLTFExporterExtension: number;
  90045. /**
  90046. * Interface for extending the exporter
  90047. * @hidden
  90048. */
  90049. export interface IGLTFExporterExtension {
  90050. /**
  90051. * The name of this extension
  90052. */
  90053. readonly name: string;
  90054. /**
  90055. * Defines whether this extension is enabled
  90056. */
  90057. enabled: boolean;
  90058. /**
  90059. * Defines whether this extension is required
  90060. */
  90061. required: boolean;
  90062. }
  90063. }
  90064. declare module BABYLON.GLTF2.Exporter {
  90065. /** @hidden */
  90066. export var __IGLTFExporterExtensionV2: number;
  90067. /**
  90068. * Interface for a glTF exporter extension
  90069. * @hidden
  90070. */
  90071. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  90072. /**
  90073. * Define this method to modify the default behavior before exporting a texture
  90074. * @param context The context when loading the asset
  90075. * @param babylonTexture The Babylon.js texture
  90076. * @param mimeType The mime-type of the generated image
  90077. * @returns A promise that resolves with the exported texture
  90078. */
  90079. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  90080. /**
  90081. * Define this method to get notified when a texture info is created
  90082. * @param context The context when loading the asset
  90083. * @param textureInfo The glTF texture info
  90084. * @param babylonTexture The Babylon.js texture
  90085. */
  90086. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  90087. /**
  90088. * Define this method to modify the default behavior when exporting texture info
  90089. * @param context The context when loading the asset
  90090. * @param meshPrimitive glTF mesh primitive
  90091. * @param babylonSubMesh Babylon submesh
  90092. * @param binaryWriter glTF serializer binary writer instance
  90093. * @returns nullable IMeshPrimitive promise
  90094. */
  90095. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  90096. /**
  90097. * Define this method to modify the default behavior when exporting a node
  90098. * @param context The context when exporting the node
  90099. * @param node glTF node
  90100. * @param babylonNode BabylonJS node
  90101. * @returns nullable INode promise
  90102. */
  90103. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  90104. [key: number]: number;
  90105. }): Promise<Nullable<INode>>;
  90106. /**
  90107. * Define this method to modify the default behavior when exporting a material
  90108. * @param material glTF material
  90109. * @param babylonMaterial BabylonJS material
  90110. * @returns nullable IMaterial promise
  90111. */
  90112. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  90113. /**
  90114. * Define this method to return additional textures to export from a material
  90115. * @param material glTF material
  90116. * @param babylonMaterial BabylonJS material
  90117. * @returns List of textures
  90118. */
  90119. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  90120. /** Gets a boolean indicating that this extension was used */
  90121. wasUsed: boolean;
  90122. /** Gets a boolean indicating that this extension is required for the file to work */
  90123. required: boolean;
  90124. /**
  90125. * Called after the exporter state changes to EXPORTING
  90126. */
  90127. onExporting?(): void;
  90128. }
  90129. }
  90130. declare module BABYLON.GLTF2.Exporter {
  90131. /**
  90132. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  90133. * @hidden
  90134. */
  90135. export class _GLTFMaterialExporter {
  90136. /**
  90137. * Represents the dielectric specular values for R, G and B
  90138. */
  90139. private static readonly _DielectricSpecular;
  90140. /**
  90141. * Allows the maximum specular power to be defined for material calculations
  90142. */
  90143. private static readonly _MaxSpecularPower;
  90144. /**
  90145. * Mapping to store textures
  90146. */
  90147. private _textureMap;
  90148. /**
  90149. * Numeric tolerance value
  90150. */
  90151. private static readonly _Epsilon;
  90152. /**
  90153. * Reference to the glTF Exporter
  90154. */
  90155. private _exporter;
  90156. constructor(exporter: _Exporter);
  90157. /**
  90158. * Specifies if two colors are approximately equal in value
  90159. * @param color1 first color to compare to
  90160. * @param color2 second color to compare to
  90161. * @param epsilon threshold value
  90162. */
  90163. private static FuzzyEquals;
  90164. /**
  90165. * Gets the materials from a Babylon scene and converts them to glTF materials
  90166. * @param scene babylonjs scene
  90167. * @param mimeType texture mime type
  90168. * @param images array of images
  90169. * @param textures array of textures
  90170. * @param materials array of materials
  90171. * @param imageData mapping of texture names to base64 textures
  90172. * @param hasTextureCoords specifies if texture coordinates are present on the material
  90173. */
  90174. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  90175. /**
  90176. * Makes a copy of the glTF material without the texture parameters
  90177. * @param originalMaterial original glTF material
  90178. * @returns glTF material without texture parameters
  90179. */
  90180. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  90181. /**
  90182. * Specifies if the material has any texture parameters present
  90183. * @param material glTF Material
  90184. * @returns boolean specifying if texture parameters are present
  90185. */
  90186. _hasTexturesPresent(material: IMaterial): boolean;
  90187. /**
  90188. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  90189. * @param babylonStandardMaterial
  90190. * @returns glTF Metallic Roughness Material representation
  90191. */
  90192. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  90193. /**
  90194. * Computes the metallic factor
  90195. * @param diffuse diffused value
  90196. * @param specular specular value
  90197. * @param oneMinusSpecularStrength one minus the specular strength
  90198. * @returns metallic value
  90199. */
  90200. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  90201. /**
  90202. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  90203. * @param glTFMaterial glTF material
  90204. * @param babylonMaterial Babylon material
  90205. */
  90206. private static _SetAlphaMode;
  90207. /**
  90208. * Converts a Babylon Standard Material to a glTF Material
  90209. * @param babylonStandardMaterial BJS Standard Material
  90210. * @param mimeType mime type to use for the textures
  90211. * @param images array of glTF image interfaces
  90212. * @param textures array of glTF texture interfaces
  90213. * @param materials array of glTF material interfaces
  90214. * @param imageData map of image file name to data
  90215. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  90216. */
  90217. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  90218. private _finishMaterial;
  90219. /**
  90220. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  90221. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  90222. * @param mimeType mime type to use for the textures
  90223. * @param images array of glTF image interfaces
  90224. * @param textures array of glTF texture interfaces
  90225. * @param materials array of glTF material interfaces
  90226. * @param imageData map of image file name to data
  90227. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  90228. */
  90229. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  90230. /**
  90231. * Converts an image typed array buffer to a base64 image
  90232. * @param buffer typed array buffer
  90233. * @param width width of the image
  90234. * @param height height of the image
  90235. * @param mimeType mimetype of the image
  90236. * @returns base64 image string
  90237. */
  90238. private _createBase64FromCanvasAsync;
  90239. /**
  90240. * Generates a white texture based on the specified width and height
  90241. * @param width width of the texture in pixels
  90242. * @param height height of the texture in pixels
  90243. * @param scene babylonjs scene
  90244. * @returns white texture
  90245. */
  90246. private _createWhiteTexture;
  90247. /**
  90248. * 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
  90249. * @param texture1 first texture to resize
  90250. * @param texture2 second texture to resize
  90251. * @param scene babylonjs scene
  90252. * @returns resized textures or null
  90253. */
  90254. private _resizeTexturesToSameDimensions;
  90255. /**
  90256. * Converts an array of pixels to a Float32Array
  90257. * Throws an error if the pixel format is not supported
  90258. * @param pixels - array buffer containing pixel values
  90259. * @returns Float32 of pixels
  90260. */
  90261. private _convertPixelArrayToFloat32;
  90262. /**
  90263. * Convert Specular Glossiness Textures to Metallic Roughness
  90264. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  90265. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  90266. * @param diffuseTexture texture used to store diffuse information
  90267. * @param specularGlossinessTexture texture used to store specular and glossiness information
  90268. * @param factors specular glossiness material factors
  90269. * @param mimeType the mime type to use for the texture
  90270. * @returns pbr metallic roughness interface or null
  90271. */
  90272. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  90273. /**
  90274. * Converts specular glossiness material properties to metallic roughness
  90275. * @param specularGlossiness interface with specular glossiness material properties
  90276. * @returns interface with metallic roughness material properties
  90277. */
  90278. private _convertSpecularGlossinessToMetallicRoughness;
  90279. /**
  90280. * Calculates the surface reflectance, independent of lighting conditions
  90281. * @param color Color source to calculate brightness from
  90282. * @returns number representing the perceived brightness, or zero if color is undefined
  90283. */
  90284. private _getPerceivedBrightness;
  90285. /**
  90286. * Returns the maximum color component value
  90287. * @param color
  90288. * @returns maximum color component value, or zero if color is null or undefined
  90289. */
  90290. private _getMaxComponent;
  90291. /**
  90292. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  90293. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  90294. * @param mimeType mime type to use for the textures
  90295. * @param images array of glTF image interfaces
  90296. * @param textures array of glTF texture interfaces
  90297. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  90298. * @param imageData map of image file name to data
  90299. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  90300. * @returns glTF PBR Metallic Roughness factors
  90301. */
  90302. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  90303. private _getGLTFTextureSampler;
  90304. private _getGLTFTextureWrapMode;
  90305. private _getGLTFTextureWrapModesSampler;
  90306. /**
  90307. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  90308. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  90309. * @param mimeType mime type to use for the textures
  90310. * @param images array of glTF image interfaces
  90311. * @param textures array of glTF texture interfaces
  90312. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  90313. * @param imageData map of image file name to data
  90314. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  90315. * @returns glTF PBR Metallic Roughness factors
  90316. */
  90317. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  90318. /**
  90319. * Converts a Babylon PBR Base Material to a glTF Material
  90320. * @param babylonPBRMaterial BJS PBR Base Material
  90321. * @param mimeType mime type to use for the textures
  90322. * @param images array of glTF image interfaces
  90323. * @param textures array of glTF texture interfaces
  90324. * @param materials array of glTF material interfaces
  90325. * @param imageData map of image file name to data
  90326. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  90327. */
  90328. _convertPBRMaterialAsync(babylonPBRMaterial: PBRBaseMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  90329. private setMetallicRoughnessPbrMaterial;
  90330. private getPixelsFromTexture;
  90331. /**
  90332. * Extracts a texture from a Babylon texture into file data and glTF data
  90333. * @param babylonTexture Babylon texture to extract
  90334. * @param mimeType Mime Type of the babylonTexture
  90335. * @return glTF texture info, or null if the texture format is not supported
  90336. */
  90337. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  90338. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  90339. /**
  90340. * Builds a texture from base64 string
  90341. * @param base64Texture base64 texture string
  90342. * @param baseTextureName Name to use for the texture
  90343. * @param mimeType image mime type for the texture
  90344. * @param images array of images
  90345. * @param textures array of textures
  90346. * @param imageData map of image data
  90347. * @returns glTF texture info, or null if the texture format is not supported
  90348. */
  90349. private _getTextureInfoFromBase64;
  90350. }
  90351. }
  90352. declare module BABYLON {
  90353. /**
  90354. * Class for holding and downloading glTF file data
  90355. */
  90356. export class GLTFData {
  90357. /**
  90358. * Object which contains the file name as the key and its data as the value
  90359. */
  90360. glTFFiles: {
  90361. [fileName: string]: string | Blob;
  90362. };
  90363. /**
  90364. * Initializes the glTF file object
  90365. */
  90366. constructor();
  90367. /**
  90368. * Downloads the glTF data as files based on their names and data
  90369. */
  90370. downloadFiles(): void;
  90371. }
  90372. }
  90373. declare module BABYLON {
  90374. /**
  90375. * Holds a collection of exporter options and parameters
  90376. */
  90377. export interface IExportOptions {
  90378. /**
  90379. * Function which indicates whether a babylon node should be exported or not
  90380. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  90381. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  90382. */
  90383. shouldExportNode?(node: Node): boolean;
  90384. /**
  90385. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  90386. * @param metadata source metadata to read from
  90387. * @returns the data to store to glTF node extras
  90388. */
  90389. metadataSelector?(metadata: any): any;
  90390. /**
  90391. * The sample rate to bake animation curves
  90392. */
  90393. animationSampleRate?: number;
  90394. /**
  90395. * Begin serialization without waiting for the scene to be ready
  90396. */
  90397. exportWithoutWaitingForScene?: boolean;
  90398. /**
  90399. * Indicates if coordinate system swapping root nodes should be included in export
  90400. */
  90401. includeCoordinateSystemConversionNodes?: boolean;
  90402. }
  90403. /**
  90404. * Class for generating glTF data from a Babylon scene.
  90405. */
  90406. export class GLTF2Export {
  90407. /**
  90408. * Exports the geometry of the scene to .gltf file format asynchronously
  90409. * @param scene Babylon scene with scene hierarchy information
  90410. * @param filePrefix File prefix to use when generating the glTF file
  90411. * @param options Exporter options
  90412. * @returns Returns an object with a .gltf file and associates texture names
  90413. * as keys and their data and paths as values
  90414. */
  90415. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  90416. private static _PreExportAsync;
  90417. private static _PostExportAsync;
  90418. /**
  90419. * Exports the geometry of the scene to .glb file format asychronously
  90420. * @param scene Babylon scene with scene hierarchy information
  90421. * @param filePrefix File prefix to use when generating glb file
  90422. * @param options Exporter options
  90423. * @returns Returns an object with a .glb filename as key and data as value
  90424. */
  90425. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  90426. }
  90427. }
  90428. declare module BABYLON.GLTF2.Exporter {
  90429. /**
  90430. * @hidden
  90431. */
  90432. export class _GLTFUtilities {
  90433. /**
  90434. * Creates a buffer view based on the supplied arguments
  90435. * @param bufferIndex index value of the specified buffer
  90436. * @param byteOffset byte offset value
  90437. * @param byteLength byte length of the bufferView
  90438. * @param byteStride byte distance between conequential elements
  90439. * @param name name of the buffer view
  90440. * @returns bufferView for glTF
  90441. */
  90442. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  90443. /**
  90444. * Creates an accessor based on the supplied arguments
  90445. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  90446. * @param name The name of the accessor
  90447. * @param type The type of the accessor
  90448. * @param componentType The datatype of components in the attribute
  90449. * @param count The number of attributes referenced by this accessor
  90450. * @param byteOffset The offset relative to the start of the bufferView in bytes
  90451. * @param min Minimum value of each component in this attribute
  90452. * @param max Maximum value of each component in this attribute
  90453. * @returns accessor for glTF
  90454. */
  90455. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  90456. /**
  90457. * Calculates the minimum and maximum values of an array of position floats
  90458. * @param positions Positions array of a mesh
  90459. * @param vertexStart Starting vertex offset to calculate min and max values
  90460. * @param vertexCount Number of vertices to check for min and max values
  90461. * @returns min number array and max number array
  90462. */
  90463. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  90464. min: number[];
  90465. max: number[];
  90466. };
  90467. /**
  90468. * Converts a new right-handed Vector3
  90469. * @param vector vector3 array
  90470. * @returns right-handed Vector3
  90471. */
  90472. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  90473. /**
  90474. * Converts a Vector3 to right-handed
  90475. * @param vector Vector3 to convert to right-handed
  90476. */
  90477. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  90478. /**
  90479. * Converts a three element number array to right-handed
  90480. * @param vector number array to convert to right-handed
  90481. */
  90482. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  90483. /**
  90484. * Converts a new right-handed Vector3
  90485. * @param vector vector3 array
  90486. * @returns right-handed Vector3
  90487. */
  90488. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  90489. /**
  90490. * Converts a Vector3 to right-handed
  90491. * @param vector Vector3 to convert to right-handed
  90492. */
  90493. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  90494. /**
  90495. * Converts a three element number array to right-handed
  90496. * @param vector number array to convert to right-handed
  90497. */
  90498. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  90499. /**
  90500. * Converts a Vector4 to right-handed
  90501. * @param vector Vector4 to convert to right-handed
  90502. */
  90503. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  90504. /**
  90505. * Converts a Vector4 to right-handed
  90506. * @param vector Vector4 to convert to right-handed
  90507. */
  90508. static _GetRightHandedArray4FromRef(vector: number[]): void;
  90509. /**
  90510. * Converts a Quaternion to right-handed
  90511. * @param quaternion Source quaternion to convert to right-handed
  90512. */
  90513. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  90514. /**
  90515. * Converts a Quaternion to right-handed
  90516. * @param quaternion Source quaternion to convert to right-handed
  90517. */
  90518. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  90519. static _NormalizeTangentFromRef(tangent: Vector4): void;
  90520. static _GetRightHandedMatrixFromRef(matrix: Matrix): void;
  90521. static _GetDataAccessorElementCount(accessorType: AccessorType): 1 | 3 | 2 | 4 | 9 | 16;
  90522. }
  90523. }
  90524. declare module BABYLON.GLTF2.Exporter {
  90525. /**
  90526. * Converts Babylon Scene into glTF 2.0.
  90527. * @hidden
  90528. */
  90529. export class _Exporter {
  90530. /**
  90531. * Stores the glTF to export
  90532. */
  90533. _glTF: IGLTF;
  90534. /**
  90535. * Stores all generated buffer views, which represents views into the main glTF buffer data
  90536. */
  90537. _bufferViews: IBufferView[];
  90538. /**
  90539. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  90540. */
  90541. _accessors: IAccessor[];
  90542. /**
  90543. * Stores all the generated nodes, which contains transform and/or mesh information per node
  90544. */
  90545. _nodes: INode[];
  90546. /**
  90547. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  90548. */
  90549. private _scenes;
  90550. /**
  90551. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  90552. */
  90553. private _meshes;
  90554. /**
  90555. * Stores all the generated material information, which represents the appearance of each primitive
  90556. */
  90557. _materials: IMaterial[];
  90558. _materialMap: {
  90559. [materialID: number]: number;
  90560. };
  90561. /**
  90562. * Stores all the generated texture information, which is referenced by glTF materials
  90563. */
  90564. _textures: ITexture[];
  90565. /**
  90566. * Stores all the generated image information, which is referenced by glTF textures
  90567. */
  90568. _images: IImage[];
  90569. /**
  90570. * Stores all the texture samplers
  90571. */
  90572. _samplers: ISampler[];
  90573. /**
  90574. * Stores all the generated glTF skins
  90575. */
  90576. _skins: ISkin[];
  90577. /**
  90578. * Stores all the generated animation samplers, which is referenced by glTF animations
  90579. */
  90580. /**
  90581. * Stores the animations for glTF models
  90582. */
  90583. private _animations;
  90584. /**
  90585. * Stores the total amount of bytes stored in the glTF buffer
  90586. */
  90587. private _totalByteLength;
  90588. /**
  90589. * Stores a reference to the Babylon scene containing the source geometry and material information
  90590. */
  90591. _babylonScene: Scene;
  90592. /**
  90593. * Stores a map of the image data, where the key is the file name and the value
  90594. * is the image data
  90595. */
  90596. _imageData: {
  90597. [fileName: string]: {
  90598. data: Uint8Array;
  90599. mimeType: ImageMimeType;
  90600. };
  90601. };
  90602. protected _orderedImageData: Array<{
  90603. data: Uint8Array;
  90604. mimeType: ImageMimeType;
  90605. }>;
  90606. /**
  90607. * Stores a map of the unique id of a node to its index in the node array
  90608. */
  90609. _nodeMap: {
  90610. [key: number]: number;
  90611. };
  90612. /**
  90613. * Specifies if the source Babylon scene was left handed, and needed conversion.
  90614. */
  90615. _convertToRightHandedSystem: boolean;
  90616. /**
  90617. * Specifies if a Babylon node should be converted to right-handed on export
  90618. */
  90619. _convertToRightHandedSystemMap: {
  90620. [nodeId: number]: boolean;
  90621. };
  90622. _includeCoordinateSystemConversionNodes: boolean;
  90623. /**
  90624. * Baked animation sample rate
  90625. */
  90626. private _animationSampleRate;
  90627. private _options;
  90628. private _localEngine;
  90629. _glTFMaterialExporter: _GLTFMaterialExporter;
  90630. private _extensions;
  90631. private static _ExtensionNames;
  90632. private static _ExtensionFactories;
  90633. private _applyExtension;
  90634. private _applyExtensions;
  90635. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  90636. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  90637. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  90638. [key: number]: number;
  90639. }): Promise<Nullable<INode>>;
  90640. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  90641. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  90642. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  90643. private _forEachExtensions;
  90644. private _extensionsOnExporting;
  90645. /**
  90646. * Load glTF serializer extensions
  90647. */
  90648. private _loadExtensions;
  90649. /**
  90650. * Creates a glTF Exporter instance, which can accept optional exporter options
  90651. * @param babylonScene Babylon scene object
  90652. * @param options Options to modify the behavior of the exporter
  90653. */
  90654. constructor(babylonScene: Scene, options?: IExportOptions);
  90655. dispose(): void;
  90656. /**
  90657. * Registers a glTF exporter extension
  90658. * @param name Name of the extension to export
  90659. * @param factory The factory function that creates the exporter extension
  90660. */
  90661. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  90662. /**
  90663. * Un-registers an exporter extension
  90664. * @param name The name fo the exporter extension
  90665. * @returns A boolean indicating whether the extension has been un-registered
  90666. */
  90667. static UnregisterExtension(name: string): boolean;
  90668. private reorderIndicesBasedOnPrimitiveMode;
  90669. /**
  90670. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  90671. * clock-wise during export to glTF
  90672. * @param submesh BabylonJS submesh
  90673. * @param primitiveMode Primitive mode of the mesh
  90674. * @param sideOrientation the winding order of the submesh
  90675. * @param vertexBufferKind The type of vertex attribute
  90676. * @param meshAttributeArray The vertex attribute data
  90677. * @param byteOffset The offset to the binary data
  90678. * @param binaryWriter The binary data for the glTF file
  90679. * @param convertToRightHandedSystem Converts the values to right-handed
  90680. */
  90681. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  90682. /**
  90683. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  90684. * clock-wise during export to glTF
  90685. * @param submesh BabylonJS submesh
  90686. * @param primitiveMode Primitive mode of the mesh
  90687. * @param sideOrientation the winding order of the submesh
  90688. * @param vertexBufferKind The type of vertex attribute
  90689. * @param meshAttributeArray The vertex attribute data
  90690. * @param byteOffset The offset to the binary data
  90691. * @param binaryWriter The binary data for the glTF file
  90692. * @param convertToRightHandedSystem Converts the values to right-handed
  90693. */
  90694. private reorderTriangleFillMode;
  90695. /**
  90696. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  90697. * clock-wise during export to glTF
  90698. * @param submesh BabylonJS submesh
  90699. * @param primitiveMode Primitive mode of the mesh
  90700. * @param sideOrientation the winding order of the submesh
  90701. * @param vertexBufferKind The type of vertex attribute
  90702. * @param meshAttributeArray The vertex attribute data
  90703. * @param byteOffset The offset to the binary data
  90704. * @param binaryWriter The binary data for the glTF file
  90705. * @param convertToRightHandedSystem Converts the values to right-handed
  90706. */
  90707. private reorderTriangleStripDrawMode;
  90708. /**
  90709. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  90710. * clock-wise during export to glTF
  90711. * @param submesh BabylonJS submesh
  90712. * @param primitiveMode Primitive mode of the mesh
  90713. * @param sideOrientation the winding order of the submesh
  90714. * @param vertexBufferKind The type of vertex attribute
  90715. * @param meshAttributeArray The vertex attribute data
  90716. * @param byteOffset The offset to the binary data
  90717. * @param binaryWriter The binary data for the glTF file
  90718. * @param convertToRightHandedSystem Converts the values to right-handed
  90719. */
  90720. private reorderTriangleFanMode;
  90721. /**
  90722. * Writes the vertex attribute data to binary
  90723. * @param vertices The vertices to write to the binary writer
  90724. * @param byteOffset The offset into the binary writer to overwrite binary data
  90725. * @param vertexAttributeKind The vertex attribute type
  90726. * @param meshAttributeArray The vertex attribute data
  90727. * @param binaryWriter The writer containing the binary data
  90728. * @param convertToRightHandedSystem Converts the values to right-handed
  90729. */
  90730. private writeVertexAttributeData;
  90731. /**
  90732. * Writes mesh attribute data to a data buffer
  90733. * Returns the bytelength of the data
  90734. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  90735. * @param meshAttributeArray Array containing the attribute data
  90736. * @param byteStride Specifies the space between data
  90737. * @param binaryWriter The buffer to write the binary data to
  90738. * @param convertToRightHandedSystem Converts the values to right-handed
  90739. */
  90740. writeAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, babylonTransformNode: TransformNode): void;
  90741. /**
  90742. * Writes mesh attribute data to a data buffer
  90743. * Returns the bytelength of the data
  90744. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  90745. * @param meshAttributeArray Array containing the attribute data
  90746. * @param byteStride Specifies the space between data
  90747. * @param binaryWriter The buffer to write the binary data to
  90748. * @param convertToRightHandedSystem Converts the values to right-handed
  90749. */
  90750. writeMorphTargetAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshPrimitive: SubMesh, morphTarget: MorphTarget, meshAttributeArray: FloatArray, morphTargetAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, minMax?: any): void;
  90751. /**
  90752. * Generates glTF json data
  90753. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  90754. * @param glTFPrefix Text to use when prefixing a glTF file
  90755. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  90756. * @returns json data as string
  90757. */
  90758. private generateJSON;
  90759. /**
  90760. * Generates data for .gltf and .bin files based on the glTF prefix string
  90761. * @param glTFPrefix Text to use when prefixing a glTF file
  90762. * @param dispose Dispose the exporter
  90763. * @returns GLTFData with glTF file data
  90764. */
  90765. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  90766. /**
  90767. * Creates a binary buffer for glTF
  90768. * @returns array buffer for binary data
  90769. */
  90770. private _generateBinaryAsync;
  90771. /**
  90772. * Pads the number to a multiple of 4
  90773. * @param num number to pad
  90774. * @returns padded number
  90775. */
  90776. private _getPadding;
  90777. /**
  90778. * @hidden
  90779. */
  90780. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  90781. /**
  90782. * Sets the TRS for each node
  90783. * @param node glTF Node for storing the transformation data
  90784. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  90785. * @param convertToRightHandedSystem Converts the values to right-handed
  90786. */
  90787. private setNodeTransformation;
  90788. private getVertexBufferFromMesh;
  90789. /**
  90790. * Creates a bufferview based on the vertices type for the Babylon mesh
  90791. * @param kind Indicates the type of vertices data
  90792. * @param componentType Indicates the numerical type used to store the data
  90793. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  90794. * @param binaryWriter The buffer to write the bufferview data to
  90795. * @param convertToRightHandedSystem Converts the values to right-handed
  90796. */
  90797. private createBufferViewKind;
  90798. /**
  90799. * Creates a bufferview based on the vertices type for the Babylon mesh
  90800. * @param babylonSubMesh The Babylon submesh that the morph target is applied to
  90801. * @param babylonMorphTarget the morph target to be exported
  90802. * @param binaryWriter The buffer to write the bufferview data to
  90803. * @param convertToRightHandedSystem Converts the values to right-handed
  90804. */
  90805. private setMorphTargetAttributes;
  90806. /**
  90807. * The primitive mode of the Babylon mesh
  90808. * @param babylonMesh The BabylonJS mesh
  90809. */
  90810. private getMeshPrimitiveMode;
  90811. /**
  90812. * Sets the primitive mode of the glTF mesh primitive
  90813. * @param meshPrimitive glTF mesh primitive
  90814. * @param primitiveMode The primitive mode
  90815. */
  90816. private setPrimitiveMode;
  90817. /**
  90818. * Sets the vertex attribute accessor based of the glTF mesh primitive
  90819. * @param meshPrimitive glTF mesh primitive
  90820. * @param attributeKind vertex attribute
  90821. * @returns boolean specifying if uv coordinates are present
  90822. */
  90823. private setAttributeKind;
  90824. /**
  90825. * Sets data for the primitive attributes of each submesh
  90826. * @param mesh glTF Mesh object to store the primitive attribute information
  90827. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  90828. * @param binaryWriter Buffer to write the attribute data to
  90829. * @param convertToRightHandedSystem Converts the values to right-handed
  90830. */
  90831. private setPrimitiveAttributesAsync;
  90832. /**
  90833. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  90834. * @param node The node to check
  90835. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  90836. */
  90837. private isBabylonCoordinateSystemConvertingNode;
  90838. /**
  90839. * Creates a glTF scene based on the array of meshes
  90840. * Returns the the total byte offset
  90841. * @param babylonScene Babylon scene to get the mesh data from
  90842. * @param binaryWriter Buffer to write binary data to
  90843. */
  90844. private createSceneAsync;
  90845. /**
  90846. * Creates a mapping of Node unique id to node index and handles animations
  90847. * @param babylonScene Babylon Scene
  90848. * @param nodes Babylon transform nodes
  90849. * @param binaryWriter Buffer to write binary data to
  90850. * @returns Node mapping of unique id to index
  90851. */
  90852. private createNodeMapAndAnimationsAsync;
  90853. /**
  90854. * Creates a glTF node from a Babylon mesh
  90855. * @param babylonMesh Source Babylon mesh
  90856. * @param binaryWriter Buffer for storing geometry data
  90857. * @param convertToRightHandedSystem Converts the values to right-handed
  90858. * @param nodeMap Node mapping of unique id to glTF node index
  90859. * @returns glTF node
  90860. */
  90861. private createNodeAsync;
  90862. /**
  90863. * Creates a glTF skin from a Babylon skeleton
  90864. * @param babylonScene Babylon Scene
  90865. * @param nodes Babylon transform nodes
  90866. * @param binaryWriter Buffer to write binary data to
  90867. * @returns Node mapping of unique id to index
  90868. */
  90869. private createSkinsAsync;
  90870. }
  90871. /**
  90872. * @hidden
  90873. *
  90874. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  90875. */
  90876. export class _BinaryWriter {
  90877. /**
  90878. * Array buffer which stores all binary data
  90879. */
  90880. private _arrayBuffer;
  90881. /**
  90882. * View of the array buffer
  90883. */
  90884. private _dataView;
  90885. /**
  90886. * byte offset of data in array buffer
  90887. */
  90888. private _byteOffset;
  90889. /**
  90890. * Initialize binary writer with an initial byte length
  90891. * @param byteLength Initial byte length of the array buffer
  90892. */
  90893. constructor(byteLength: number);
  90894. /**
  90895. * Resize the array buffer to the specified byte length
  90896. * @param byteLength
  90897. */
  90898. private resizeBuffer;
  90899. /**
  90900. * Get an array buffer with the length of the byte offset
  90901. * @returns ArrayBuffer resized to the byte offset
  90902. */
  90903. getArrayBuffer(): ArrayBuffer;
  90904. /**
  90905. * Get the byte offset of the array buffer
  90906. * @returns byte offset
  90907. */
  90908. getByteOffset(): number;
  90909. /**
  90910. * Stores an UInt8 in the array buffer
  90911. * @param entry
  90912. * @param byteOffset If defined, specifies where to set the value as an offset.
  90913. */
  90914. setUInt8(entry: number, byteOffset?: number): void;
  90915. /**
  90916. * Stores an UInt16 in the array buffer
  90917. * @param entry
  90918. * @param byteOffset If defined, specifies where to set the value as an offset.
  90919. */
  90920. setUInt16(entry: number, byteOffset?: number): void;
  90921. /**
  90922. * Gets an UInt32 in the array buffer
  90923. * @param entry
  90924. * @param byteOffset If defined, specifies where to set the value as an offset.
  90925. */
  90926. getUInt32(byteOffset: number): number;
  90927. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  90928. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  90929. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  90930. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  90931. /**
  90932. * Stores a Float32 in the array buffer
  90933. * @param entry
  90934. */
  90935. setFloat32(entry: number, byteOffset?: number): void;
  90936. /**
  90937. * Stores an UInt32 in the array buffer
  90938. * @param entry
  90939. * @param byteOffset If defined, specifies where to set the value as an offset.
  90940. */
  90941. setUInt32(entry: number, byteOffset?: number): void;
  90942. }
  90943. }
  90944. declare module BABYLON.GLTF2.Exporter {
  90945. /**
  90946. * @hidden
  90947. * Interface to store animation data.
  90948. */
  90949. export interface _IAnimationData {
  90950. /**
  90951. * Keyframe data.
  90952. */
  90953. inputs: number[];
  90954. /**
  90955. * Value data.
  90956. */
  90957. outputs: number[][];
  90958. /**
  90959. * Animation interpolation data.
  90960. */
  90961. samplerInterpolation: AnimationSamplerInterpolation;
  90962. /**
  90963. * Minimum keyframe value.
  90964. */
  90965. inputsMin: number;
  90966. /**
  90967. * Maximum keyframe value.
  90968. */
  90969. inputsMax: number;
  90970. }
  90971. /**
  90972. * @hidden
  90973. */
  90974. export interface _IAnimationInfo {
  90975. /**
  90976. * The target channel for the animation
  90977. */
  90978. animationChannelTargetPath: AnimationChannelTargetPath;
  90979. /**
  90980. * The glTF accessor type for the data.
  90981. */
  90982. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4 | AccessorType.SCALAR;
  90983. /**
  90984. * Specifies if quaternions should be used.
  90985. */
  90986. useQuaternion: boolean;
  90987. }
  90988. /**
  90989. * @hidden
  90990. * Utility class for generating glTF animation data from BabylonJS.
  90991. */
  90992. export class _GLTFAnimation {
  90993. /**
  90994. * @ignore
  90995. *
  90996. * Creates glTF channel animation from BabylonJS animation.
  90997. * @param babylonTransformNode - BabylonJS mesh.
  90998. * @param animation - animation.
  90999. * @param animationChannelTargetPath - The target animation channel.
  91000. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  91001. * @param useQuaternion - Specifies if quaternions are used.
  91002. * @returns nullable IAnimationData
  91003. */
  91004. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  91005. private static _DeduceAnimationInfo;
  91006. /**
  91007. * @ignore
  91008. * Create node animations from the transform node animations
  91009. * @param babylonNode
  91010. * @param runtimeGLTFAnimation
  91011. * @param idleGLTFAnimations
  91012. * @param nodeMap
  91013. * @param nodes
  91014. * @param binaryWriter
  91015. * @param bufferViews
  91016. * @param accessors
  91017. * @param convertToRightHandedSystem
  91018. * @param animationSampleRate
  91019. */
  91020. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  91021. [key: number]: number;
  91022. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  91023. /**
  91024. * @ignore
  91025. * Create individual morph animations from the mesh's morph target animation tracks
  91026. * @param babylonNode
  91027. * @param runtimeGLTFAnimation
  91028. * @param idleGLTFAnimations
  91029. * @param nodeMap
  91030. * @param nodes
  91031. * @param binaryWriter
  91032. * @param bufferViews
  91033. * @param accessors
  91034. * @param convertToRightHandedSystem
  91035. * @param animationSampleRate
  91036. */
  91037. static _CreateMorphTargetAnimationFromMorphTargetAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  91038. [key: number]: number;
  91039. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  91040. /**
  91041. * @ignore
  91042. * Create node and morph animations from the animation groups
  91043. * @param babylonScene
  91044. * @param glTFAnimations
  91045. * @param nodeMap
  91046. * @param nodes
  91047. * @param binaryWriter
  91048. * @param bufferViews
  91049. * @param accessors
  91050. * @param convertToRightHandedSystemMap
  91051. * @param animationSampleRate
  91052. */
  91053. static _CreateNodeAndMorphAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  91054. [key: number]: number;
  91055. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  91056. [nodeId: number]: boolean;
  91057. }, animationSampleRate: number): void;
  91058. private static AddAnimation;
  91059. /**
  91060. * Create a baked animation
  91061. * @param babylonTransformNode BabylonJS mesh
  91062. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  91063. * @param animationChannelTargetPath animation target channel
  91064. * @param minFrame minimum animation frame
  91065. * @param maxFrame maximum animation frame
  91066. * @param fps frames per second of the animation
  91067. * @param inputs input key frames of the animation
  91068. * @param outputs output key frame data of the animation
  91069. * @param convertToRightHandedSystem converts the values to right-handed
  91070. * @param useQuaternion specifies if quaternions should be used
  91071. */
  91072. private static _CreateBakedAnimation;
  91073. private static _ConvertFactorToVector3OrQuaternion;
  91074. private static _SetInterpolatedValue;
  91075. /**
  91076. * Creates linear animation from the animation key frames
  91077. * @param babylonTransformNode BabylonJS mesh
  91078. * @param animation BabylonJS animation
  91079. * @param animationChannelTargetPath The target animation channel
  91080. * @param frameDelta The difference between the last and first frame of the animation
  91081. * @param inputs Array to store the key frame times
  91082. * @param outputs Array to store the key frame data
  91083. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  91084. * @param useQuaternion Specifies if quaternions are used in the animation
  91085. */
  91086. private static _CreateLinearOrStepAnimation;
  91087. /**
  91088. * Creates cubic spline animation from the animation key frames
  91089. * @param babylonTransformNode BabylonJS mesh
  91090. * @param animation BabylonJS animation
  91091. * @param animationChannelTargetPath The target animation channel
  91092. * @param frameDelta The difference between the last and first frame of the animation
  91093. * @param inputs Array to store the key frame times
  91094. * @param outputs Array to store the key frame data
  91095. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  91096. * @param useQuaternion Specifies if quaternions are used in the animation
  91097. */
  91098. private static _CreateCubicSplineAnimation;
  91099. private static _GetBasePositionRotationOrScale;
  91100. /**
  91101. * Adds a key frame value
  91102. * @param keyFrame
  91103. * @param animation
  91104. * @param outputs
  91105. * @param animationChannelTargetPath
  91106. * @param basePositionRotationOrScale
  91107. * @param convertToRightHandedSystem
  91108. * @param useQuaternion
  91109. */
  91110. private static _AddKeyframeValue;
  91111. /**
  91112. * Determine the interpolation based on the key frames
  91113. * @param keyFrames
  91114. * @param animationChannelTargetPath
  91115. * @param useQuaternion
  91116. */
  91117. private static _DeduceInterpolation;
  91118. /**
  91119. * Adds an input tangent or output tangent to the output data
  91120. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  91121. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  91122. * @param outputs The animation data by keyframe
  91123. * @param animationChannelTargetPath The target animation channel
  91124. * @param interpolation The interpolation type
  91125. * @param keyFrame The key frame with the animation data
  91126. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  91127. * @param useQuaternion Specifies if quaternions are used
  91128. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  91129. */
  91130. private static AddSplineTangent;
  91131. /**
  91132. * Get the minimum and maximum key frames' frame values
  91133. * @param keyFrames animation key frames
  91134. * @returns the minimum and maximum key frame value
  91135. */
  91136. private static calculateMinMaxKeyFrames;
  91137. }
  91138. }
  91139. declare module BABYLON.GLTF2.Exporter {
  91140. /** @hidden */
  91141. export var textureTransformPixelShader: {
  91142. name: string;
  91143. shader: string;
  91144. };
  91145. }
  91146. declare module BABYLON.GLTF2.Exporter.Extensions {
  91147. /**
  91148. * @hidden
  91149. */
  91150. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  91151. private _recordedTextures;
  91152. /** Name of this extension */
  91153. readonly name: string;
  91154. /** Defines whether this extension is enabled */
  91155. enabled: boolean;
  91156. /** Defines whether this extension is required */
  91157. required: boolean;
  91158. /** Reference to the glTF exporter */
  91159. private _wasUsed;
  91160. constructor(exporter: _Exporter);
  91161. dispose(): void;
  91162. /** @hidden */
  91163. get wasUsed(): boolean;
  91164. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  91165. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  91166. /**
  91167. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  91168. * @param babylonTexture
  91169. * @param offset
  91170. * @param rotation
  91171. * @param scale
  91172. * @param scene
  91173. */
  91174. private _textureTransformTextureAsync;
  91175. }
  91176. }
  91177. declare module BABYLON.GLTF2.Exporter.Extensions {
  91178. /**
  91179. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  91180. */
  91181. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  91182. /** The name of this extension. */
  91183. readonly name: string;
  91184. /** Defines whether this extension is enabled. */
  91185. enabled: boolean;
  91186. /** Defines whether this extension is required */
  91187. required: boolean;
  91188. /** Reference to the glTF exporter */
  91189. private _exporter;
  91190. private _lights;
  91191. /** @hidden */
  91192. constructor(exporter: _Exporter);
  91193. /** @hidden */
  91194. dispose(): void;
  91195. /** @hidden */
  91196. get wasUsed(): boolean;
  91197. /** @hidden */
  91198. onExporting(): void;
  91199. /**
  91200. * Define this method to modify the default behavior when exporting a node
  91201. * @param context The context when exporting the node
  91202. * @param node glTF node
  91203. * @param babylonNode BabylonJS node
  91204. * @param nodeMap Node mapping of unique id to glTF node index
  91205. * @returns nullable INode promise
  91206. */
  91207. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  91208. [key: number]: number;
  91209. }): Promise<Nullable<INode>>;
  91210. }
  91211. }
  91212. declare module BABYLON.GLTF2.Exporter.Extensions {
  91213. /**
  91214. * @hidden
  91215. */
  91216. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  91217. /** Name of this extension */
  91218. readonly name: string;
  91219. /** Defines whether this extension is enabled */
  91220. enabled: boolean;
  91221. /** Defines whether this extension is required */
  91222. required: boolean;
  91223. /** Reference to the glTF exporter */
  91224. private _textureInfos;
  91225. private _exportedTextures;
  91226. private _wasUsed;
  91227. constructor(exporter: _Exporter);
  91228. dispose(): void;
  91229. /** @hidden */
  91230. get wasUsed(): boolean;
  91231. private _getTextureIndex;
  91232. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  91233. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  91234. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  91235. }
  91236. }
  91237. declare module BABYLON.GLTF2.Exporter.Extensions {
  91238. /**
  91239. * @hidden
  91240. */
  91241. export class KHR_materials_unlit implements IGLTFExporterExtensionV2 {
  91242. /** Name of this extension */
  91243. readonly name: string;
  91244. /** Defines whether this extension is enabled */
  91245. enabled: boolean;
  91246. /** Defines whether this extension is required */
  91247. required: boolean;
  91248. private _wasUsed;
  91249. constructor(exporter: _Exporter);
  91250. /** @hidden */
  91251. get wasUsed(): boolean;
  91252. dispose(): void;
  91253. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  91254. }
  91255. }
  91256. declare module BABYLON {
  91257. /**
  91258. * Class for generating STL data from a Babylon scene.
  91259. */
  91260. export class STLExport {
  91261. /**
  91262. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  91263. * @param meshes list defines the mesh to serialize
  91264. * @param download triggers the automatic download of the file.
  91265. * @param fileName changes the downloads fileName.
  91266. * @param binary changes the STL to a binary type.
  91267. * @param isLittleEndian toggle for binary type exporter.
  91268. * @param doNotBakeTransform toggle if meshes transforms should be baked or not.
  91269. * @returns the STL as UTF8 string
  91270. */
  91271. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean, doNotBakeTransform?: boolean): any;
  91272. }
  91273. }
  91274. declare module "babylonjs-gltf2interface" {
  91275. export = BABYLON.GLTF2;
  91276. }
  91277. /**
  91278. * Module for glTF 2.0 Interface
  91279. */
  91280. declare module BABYLON.GLTF2 {
  91281. /**
  91282. * The datatype of the components in the attribute
  91283. */
  91284. const enum AccessorComponentType {
  91285. /**
  91286. * Byte
  91287. */
  91288. BYTE = 5120,
  91289. /**
  91290. * Unsigned Byte
  91291. */
  91292. UNSIGNED_BYTE = 5121,
  91293. /**
  91294. * Short
  91295. */
  91296. SHORT = 5122,
  91297. /**
  91298. * Unsigned Short
  91299. */
  91300. UNSIGNED_SHORT = 5123,
  91301. /**
  91302. * Unsigned Int
  91303. */
  91304. UNSIGNED_INT = 5125,
  91305. /**
  91306. * Float
  91307. */
  91308. FLOAT = 5126,
  91309. }
  91310. /**
  91311. * Specifies if the attirbute is a scalar, vector, or matrix
  91312. */
  91313. const enum AccessorType {
  91314. /**
  91315. * Scalar
  91316. */
  91317. SCALAR = "SCALAR",
  91318. /**
  91319. * Vector2
  91320. */
  91321. VEC2 = "VEC2",
  91322. /**
  91323. * Vector3
  91324. */
  91325. VEC3 = "VEC3",
  91326. /**
  91327. * Vector4
  91328. */
  91329. VEC4 = "VEC4",
  91330. /**
  91331. * Matrix2x2
  91332. */
  91333. MAT2 = "MAT2",
  91334. /**
  91335. * Matrix3x3
  91336. */
  91337. MAT3 = "MAT3",
  91338. /**
  91339. * Matrix4x4
  91340. */
  91341. MAT4 = "MAT4",
  91342. }
  91343. /**
  91344. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  91345. */
  91346. const enum AnimationChannelTargetPath {
  91347. /**
  91348. * Translation
  91349. */
  91350. TRANSLATION = "translation",
  91351. /**
  91352. * Rotation
  91353. */
  91354. ROTATION = "rotation",
  91355. /**
  91356. * Scale
  91357. */
  91358. SCALE = "scale",
  91359. /**
  91360. * Weights
  91361. */
  91362. WEIGHTS = "weights",
  91363. }
  91364. /**
  91365. * Interpolation algorithm
  91366. */
  91367. const enum AnimationSamplerInterpolation {
  91368. /**
  91369. * The animated values are linearly interpolated between keyframes
  91370. */
  91371. LINEAR = "LINEAR",
  91372. /**
  91373. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  91374. */
  91375. STEP = "STEP",
  91376. /**
  91377. * The animation's interpolation is computed using a cubic spline with specified tangents
  91378. */
  91379. CUBICSPLINE = "CUBICSPLINE",
  91380. }
  91381. /**
  91382. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  91383. */
  91384. const enum CameraType {
  91385. /**
  91386. * A perspective camera containing properties to create a perspective projection matrix
  91387. */
  91388. PERSPECTIVE = "perspective",
  91389. /**
  91390. * An orthographic camera containing properties to create an orthographic projection matrix
  91391. */
  91392. ORTHOGRAPHIC = "orthographic",
  91393. }
  91394. /**
  91395. * The mime-type of the image
  91396. */
  91397. const enum ImageMimeType {
  91398. /**
  91399. * JPEG Mime-type
  91400. */
  91401. JPEG = "image/jpeg",
  91402. /**
  91403. * PNG Mime-type
  91404. */
  91405. PNG = "image/png",
  91406. }
  91407. /**
  91408. * The alpha rendering mode of the material
  91409. */
  91410. const enum MaterialAlphaMode {
  91411. /**
  91412. * The alpha value is ignored and the rendered output is fully opaque
  91413. */
  91414. OPAQUE = "OPAQUE",
  91415. /**
  91416. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  91417. */
  91418. MASK = "MASK",
  91419. /**
  91420. * 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)
  91421. */
  91422. BLEND = "BLEND",
  91423. }
  91424. /**
  91425. * The type of the primitives to render
  91426. */
  91427. const enum MeshPrimitiveMode {
  91428. /**
  91429. * Points
  91430. */
  91431. POINTS = 0,
  91432. /**
  91433. * Lines
  91434. */
  91435. LINES = 1,
  91436. /**
  91437. * Line Loop
  91438. */
  91439. LINE_LOOP = 2,
  91440. /**
  91441. * Line Strip
  91442. */
  91443. LINE_STRIP = 3,
  91444. /**
  91445. * Triangles
  91446. */
  91447. TRIANGLES = 4,
  91448. /**
  91449. * Triangle Strip
  91450. */
  91451. TRIANGLE_STRIP = 5,
  91452. /**
  91453. * Triangle Fan
  91454. */
  91455. TRIANGLE_FAN = 6,
  91456. }
  91457. /**
  91458. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  91459. */
  91460. const enum TextureMagFilter {
  91461. /**
  91462. * Nearest
  91463. */
  91464. NEAREST = 9728,
  91465. /**
  91466. * Linear
  91467. */
  91468. LINEAR = 9729,
  91469. }
  91470. /**
  91471. * Minification filter. All valid values correspond to WebGL enums
  91472. */
  91473. const enum TextureMinFilter {
  91474. /**
  91475. * Nearest
  91476. */
  91477. NEAREST = 9728,
  91478. /**
  91479. * Linear
  91480. */
  91481. LINEAR = 9729,
  91482. /**
  91483. * Nearest Mip-Map Nearest
  91484. */
  91485. NEAREST_MIPMAP_NEAREST = 9984,
  91486. /**
  91487. * Linear Mipmap Nearest
  91488. */
  91489. LINEAR_MIPMAP_NEAREST = 9985,
  91490. /**
  91491. * Nearest Mipmap Linear
  91492. */
  91493. NEAREST_MIPMAP_LINEAR = 9986,
  91494. /**
  91495. * Linear Mipmap Linear
  91496. */
  91497. LINEAR_MIPMAP_LINEAR = 9987,
  91498. }
  91499. /**
  91500. * S (U) wrapping mode. All valid values correspond to WebGL enums
  91501. */
  91502. const enum TextureWrapMode {
  91503. /**
  91504. * Clamp to Edge
  91505. */
  91506. CLAMP_TO_EDGE = 33071,
  91507. /**
  91508. * Mirrored Repeat
  91509. */
  91510. MIRRORED_REPEAT = 33648,
  91511. /**
  91512. * Repeat
  91513. */
  91514. REPEAT = 10497,
  91515. }
  91516. /**
  91517. * glTF Property
  91518. */
  91519. interface IProperty {
  91520. /**
  91521. * Dictionary object with extension-specific objects
  91522. */
  91523. extensions?: {
  91524. [key: string]: any;
  91525. };
  91526. /**
  91527. * Application-Specific data
  91528. */
  91529. extras?: any;
  91530. }
  91531. /**
  91532. * glTF Child of Root Property
  91533. */
  91534. interface IChildRootProperty extends IProperty {
  91535. /**
  91536. * The user-defined name of this object
  91537. */
  91538. name?: string;
  91539. }
  91540. /**
  91541. * Indices of those attributes that deviate from their initialization value
  91542. */
  91543. interface IAccessorSparseIndices extends IProperty {
  91544. /**
  91545. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  91546. */
  91547. bufferView: number;
  91548. /**
  91549. * The offset relative to the start of the bufferView in bytes. Must be aligned
  91550. */
  91551. byteOffset?: number;
  91552. /**
  91553. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  91554. */
  91555. componentType: AccessorComponentType;
  91556. }
  91557. /**
  91558. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  91559. */
  91560. interface IAccessorSparseValues extends IProperty {
  91561. /**
  91562. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  91563. */
  91564. bufferView: number;
  91565. /**
  91566. * The offset relative to the start of the bufferView in bytes. Must be aligned
  91567. */
  91568. byteOffset?: number;
  91569. }
  91570. /**
  91571. * Sparse storage of attributes that deviate from their initialization value
  91572. */
  91573. interface IAccessorSparse extends IProperty {
  91574. /**
  91575. * The number of attributes encoded in this sparse accessor
  91576. */
  91577. count: number;
  91578. /**
  91579. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  91580. */
  91581. indices: IAccessorSparseIndices;
  91582. /**
  91583. * 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
  91584. */
  91585. values: IAccessorSparseValues;
  91586. }
  91587. /**
  91588. * 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
  91589. */
  91590. interface IAccessor extends IChildRootProperty {
  91591. /**
  91592. * The index of the bufferview
  91593. */
  91594. bufferView?: number;
  91595. /**
  91596. * The offset relative to the start of the bufferView in bytes
  91597. */
  91598. byteOffset?: number;
  91599. /**
  91600. * The datatype of components in the attribute
  91601. */
  91602. componentType: AccessorComponentType;
  91603. /**
  91604. * Specifies whether integer data values should be normalized
  91605. */
  91606. normalized?: boolean;
  91607. /**
  91608. * The number of attributes referenced by this accessor
  91609. */
  91610. count: number;
  91611. /**
  91612. * Specifies if the attribute is a scalar, vector, or matrix
  91613. */
  91614. type: AccessorType;
  91615. /**
  91616. * Maximum value of each component in this attribute
  91617. */
  91618. max?: number[];
  91619. /**
  91620. * Minimum value of each component in this attribute
  91621. */
  91622. min?: number[];
  91623. /**
  91624. * Sparse storage of attributes that deviate from their initialization value
  91625. */
  91626. sparse?: IAccessorSparse;
  91627. }
  91628. /**
  91629. * Targets an animation's sampler at a node's property
  91630. */
  91631. interface IAnimationChannel extends IProperty {
  91632. /**
  91633. * The index of a sampler in this animation used to compute the value for the target
  91634. */
  91635. sampler: number;
  91636. /**
  91637. * The index of the node and TRS property to target
  91638. */
  91639. target: IAnimationChannelTarget;
  91640. }
  91641. /**
  91642. * The index of the node and TRS property that an animation channel targets
  91643. */
  91644. interface IAnimationChannelTarget extends IProperty {
  91645. /**
  91646. * The index of the node to target
  91647. */
  91648. node: number;
  91649. /**
  91650. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  91651. */
  91652. path: AnimationChannelTargetPath;
  91653. }
  91654. /**
  91655. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  91656. */
  91657. interface IAnimationSampler extends IProperty {
  91658. /**
  91659. * The index of an accessor containing keyframe input values, e.g., time
  91660. */
  91661. input: number;
  91662. /**
  91663. * Interpolation algorithm
  91664. */
  91665. interpolation?: AnimationSamplerInterpolation;
  91666. /**
  91667. * The index of an accessor, containing keyframe output values
  91668. */
  91669. output: number;
  91670. }
  91671. /**
  91672. * A keyframe animation
  91673. */
  91674. interface IAnimation extends IChildRootProperty {
  91675. /**
  91676. * An array of channels, each of which targets an animation's sampler at a node's property
  91677. */
  91678. channels: IAnimationChannel[];
  91679. /**
  91680. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  91681. */
  91682. samplers: IAnimationSampler[];
  91683. }
  91684. /**
  91685. * Metadata about the glTF asset
  91686. */
  91687. interface IAsset extends IChildRootProperty {
  91688. /**
  91689. * A copyright message suitable for display to credit the content creator
  91690. */
  91691. copyright?: string;
  91692. /**
  91693. * Tool that generated this glTF model. Useful for debugging
  91694. */
  91695. generator?: string;
  91696. /**
  91697. * The glTF version that this asset targets
  91698. */
  91699. version: string;
  91700. /**
  91701. * The minimum glTF version that this asset targets
  91702. */
  91703. minVersion?: string;
  91704. }
  91705. /**
  91706. * A buffer points to binary geometry, animation, or skins
  91707. */
  91708. interface IBuffer extends IChildRootProperty {
  91709. /**
  91710. * 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
  91711. */
  91712. uri?: string;
  91713. /**
  91714. * The length of the buffer in bytes
  91715. */
  91716. byteLength: number;
  91717. }
  91718. /**
  91719. * A view into a buffer generally representing a subset of the buffer
  91720. */
  91721. interface IBufferView extends IChildRootProperty {
  91722. /**
  91723. * The index of the buffer
  91724. */
  91725. buffer: number;
  91726. /**
  91727. * The offset into the buffer in bytes
  91728. */
  91729. byteOffset?: number;
  91730. /**
  91731. * The lenth of the bufferView in bytes
  91732. */
  91733. byteLength: number;
  91734. /**
  91735. * The stride, in bytes
  91736. */
  91737. byteStride?: number;
  91738. }
  91739. /**
  91740. * An orthographic camera containing properties to create an orthographic projection matrix
  91741. */
  91742. interface ICameraOrthographic extends IProperty {
  91743. /**
  91744. * The floating-point horizontal magnification of the view. Must not be zero
  91745. */
  91746. xmag: number;
  91747. /**
  91748. * The floating-point vertical magnification of the view. Must not be zero
  91749. */
  91750. ymag: number;
  91751. /**
  91752. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  91753. */
  91754. zfar: number;
  91755. /**
  91756. * The floating-point distance to the near clipping plane
  91757. */
  91758. znear: number;
  91759. }
  91760. /**
  91761. * A perspective camera containing properties to create a perspective projection matrix
  91762. */
  91763. interface ICameraPerspective extends IProperty {
  91764. /**
  91765. * The floating-point aspect ratio of the field of view
  91766. */
  91767. aspectRatio?: number;
  91768. /**
  91769. * The floating-point vertical field of view in radians
  91770. */
  91771. yfov: number;
  91772. /**
  91773. * The floating-point distance to the far clipping plane
  91774. */
  91775. zfar?: number;
  91776. /**
  91777. * The floating-point distance to the near clipping plane
  91778. */
  91779. znear: number;
  91780. }
  91781. /**
  91782. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  91783. */
  91784. interface ICamera extends IChildRootProperty {
  91785. /**
  91786. * An orthographic camera containing properties to create an orthographic projection matrix
  91787. */
  91788. orthographic?: ICameraOrthographic;
  91789. /**
  91790. * A perspective camera containing properties to create a perspective projection matrix
  91791. */
  91792. perspective?: ICameraPerspective;
  91793. /**
  91794. * Specifies if the camera uses a perspective or orthographic projection
  91795. */
  91796. type: CameraType;
  91797. }
  91798. /**
  91799. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  91800. */
  91801. interface IImage extends IChildRootProperty {
  91802. /**
  91803. * 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
  91804. */
  91805. uri?: string;
  91806. /**
  91807. * The image's MIME type
  91808. */
  91809. mimeType?: ImageMimeType;
  91810. /**
  91811. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  91812. */
  91813. bufferView?: number;
  91814. }
  91815. /**
  91816. * Material Normal Texture Info
  91817. */
  91818. interface IMaterialNormalTextureInfo extends ITextureInfo {
  91819. /**
  91820. * The scalar multiplier applied to each normal vector of the normal texture
  91821. */
  91822. scale?: number;
  91823. }
  91824. /**
  91825. * Material Occlusion Texture Info
  91826. */
  91827. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  91828. /**
  91829. * A scalar multiplier controlling the amount of occlusion applied
  91830. */
  91831. strength?: number;
  91832. }
  91833. /**
  91834. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  91835. */
  91836. interface IMaterialPbrMetallicRoughness {
  91837. /**
  91838. * The material's base color factor
  91839. */
  91840. baseColorFactor?: number[];
  91841. /**
  91842. * The base color texture
  91843. */
  91844. baseColorTexture?: ITextureInfo;
  91845. /**
  91846. * The metalness of the material
  91847. */
  91848. metallicFactor?: number;
  91849. /**
  91850. * The roughness of the material
  91851. */
  91852. roughnessFactor?: number;
  91853. /**
  91854. * The metallic-roughness texture
  91855. */
  91856. metallicRoughnessTexture?: ITextureInfo;
  91857. }
  91858. /**
  91859. * The material appearance of a primitive
  91860. */
  91861. interface IMaterial extends IChildRootProperty {
  91862. /**
  91863. * 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
  91864. */
  91865. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  91866. /**
  91867. * The normal map texture
  91868. */
  91869. normalTexture?: IMaterialNormalTextureInfo;
  91870. /**
  91871. * The occlusion map texture
  91872. */
  91873. occlusionTexture?: IMaterialOcclusionTextureInfo;
  91874. /**
  91875. * The emissive map texture
  91876. */
  91877. emissiveTexture?: ITextureInfo;
  91878. /**
  91879. * 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
  91880. */
  91881. emissiveFactor?: number[];
  91882. /**
  91883. * The alpha rendering mode of the material
  91884. */
  91885. alphaMode?: MaterialAlphaMode;
  91886. /**
  91887. * The alpha cutoff value of the material
  91888. */
  91889. alphaCutoff?: number;
  91890. /**
  91891. * Specifies whether the material is double sided
  91892. */
  91893. doubleSided?: boolean;
  91894. }
  91895. /**
  91896. * Geometry to be rendered with the given material
  91897. */
  91898. interface IMeshPrimitive extends IProperty {
  91899. /**
  91900. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  91901. */
  91902. attributes: {
  91903. [name: string]: number;
  91904. };
  91905. /**
  91906. * The index of the accessor that contains the indices
  91907. */
  91908. indices?: number;
  91909. /**
  91910. * The index of the material to apply to this primitive when rendering
  91911. */
  91912. material?: number;
  91913. /**
  91914. * The type of primitives to render. All valid values correspond to WebGL enums
  91915. */
  91916. mode?: MeshPrimitiveMode;
  91917. /**
  91918. * 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
  91919. */
  91920. targets?: {
  91921. [name: string]: number;
  91922. }[];
  91923. }
  91924. /**
  91925. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  91926. */
  91927. interface IMesh extends IChildRootProperty {
  91928. /**
  91929. * An array of primitives, each defining geometry to be rendered with a material
  91930. */
  91931. primitives: IMeshPrimitive[];
  91932. /**
  91933. * Array of weights to be applied to the Morph Targets
  91934. */
  91935. weights?: number[];
  91936. }
  91937. /**
  91938. * A node in the node hierarchy
  91939. */
  91940. interface INode extends IChildRootProperty {
  91941. /**
  91942. * The index of the camera referenced by this node
  91943. */
  91944. camera?: number;
  91945. /**
  91946. * The indices of this node's children
  91947. */
  91948. children?: number[];
  91949. /**
  91950. * The index of the skin referenced by this node
  91951. */
  91952. skin?: number;
  91953. /**
  91954. * A floating-point 4x4 transformation matrix stored in column-major order
  91955. */
  91956. matrix?: number[];
  91957. /**
  91958. * The index of the mesh in this node
  91959. */
  91960. mesh?: number;
  91961. /**
  91962. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  91963. */
  91964. rotation?: number[];
  91965. /**
  91966. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  91967. */
  91968. scale?: number[];
  91969. /**
  91970. * The node's translation along the x, y, and z axes
  91971. */
  91972. translation?: number[];
  91973. /**
  91974. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  91975. */
  91976. weights?: number[];
  91977. }
  91978. /**
  91979. * Texture sampler properties for filtering and wrapping modes
  91980. */
  91981. interface ISampler extends IChildRootProperty {
  91982. /**
  91983. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  91984. */
  91985. magFilter?: TextureMagFilter;
  91986. /**
  91987. * Minification filter. All valid values correspond to WebGL enums
  91988. */
  91989. minFilter?: TextureMinFilter;
  91990. /**
  91991. * S (U) wrapping mode. All valid values correspond to WebGL enums
  91992. */
  91993. wrapS?: TextureWrapMode;
  91994. /**
  91995. * T (V) wrapping mode. All valid values correspond to WebGL enums
  91996. */
  91997. wrapT?: TextureWrapMode;
  91998. }
  91999. /**
  92000. * The root nodes of a scene
  92001. */
  92002. interface IScene extends IChildRootProperty {
  92003. /**
  92004. * The indices of each root node
  92005. */
  92006. nodes: number[];
  92007. }
  92008. /**
  92009. * Joints and matrices defining a skin
  92010. */
  92011. interface ISkin extends IChildRootProperty {
  92012. /**
  92013. * 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
  92014. */
  92015. inverseBindMatrices?: number;
  92016. /**
  92017. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  92018. */
  92019. skeleton?: number;
  92020. /**
  92021. * 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)
  92022. */
  92023. joints: number[];
  92024. }
  92025. /**
  92026. * A texture and its sampler
  92027. */
  92028. interface ITexture extends IChildRootProperty {
  92029. /**
  92030. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  92031. */
  92032. sampler?: number;
  92033. /**
  92034. * The index of the image used by this texture
  92035. */
  92036. source: number;
  92037. }
  92038. /**
  92039. * Reference to a texture
  92040. */
  92041. interface ITextureInfo extends IProperty {
  92042. /**
  92043. * The index of the texture
  92044. */
  92045. index: number;
  92046. /**
  92047. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  92048. */
  92049. texCoord?: number;
  92050. }
  92051. /**
  92052. * The root object for a glTF asset
  92053. */
  92054. interface IGLTF extends IProperty {
  92055. /**
  92056. * An array of accessors. An accessor is a typed view into a bufferView
  92057. */
  92058. accessors?: IAccessor[];
  92059. /**
  92060. * An array of keyframe animations
  92061. */
  92062. animations?: IAnimation[];
  92063. /**
  92064. * Metadata about the glTF asset
  92065. */
  92066. asset: IAsset;
  92067. /**
  92068. * An array of buffers. A buffer points to binary geometry, animation, or skins
  92069. */
  92070. buffers?: IBuffer[];
  92071. /**
  92072. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  92073. */
  92074. bufferViews?: IBufferView[];
  92075. /**
  92076. * An array of cameras
  92077. */
  92078. cameras?: ICamera[];
  92079. /**
  92080. * Names of glTF extensions used somewhere in this asset
  92081. */
  92082. extensionsUsed?: string[];
  92083. /**
  92084. * Names of glTF extensions required to properly load this asset
  92085. */
  92086. extensionsRequired?: string[];
  92087. /**
  92088. * An array of images. An image defines data used to create a texture
  92089. */
  92090. images?: IImage[];
  92091. /**
  92092. * An array of materials. A material defines the appearance of a primitive
  92093. */
  92094. materials?: IMaterial[];
  92095. /**
  92096. * An array of meshes. A mesh is a set of primitives to be rendered
  92097. */
  92098. meshes?: IMesh[];
  92099. /**
  92100. * An array of nodes
  92101. */
  92102. nodes?: INode[];
  92103. /**
  92104. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  92105. */
  92106. samplers?: ISampler[];
  92107. /**
  92108. * The index of the default scene
  92109. */
  92110. scene?: number;
  92111. /**
  92112. * An array of scenes
  92113. */
  92114. scenes?: IScene[];
  92115. /**
  92116. * An array of skins. A skin is defined by joints and matrices
  92117. */
  92118. skins?: ISkin[];
  92119. /**
  92120. * An array of textures
  92121. */
  92122. textures?: ITexture[];
  92123. }
  92124. /**
  92125. * The glTF validation results
  92126. * @ignore
  92127. */
  92128. interface IGLTFValidationResults {
  92129. info: {
  92130. generator: string;
  92131. hasAnimations: boolean;
  92132. hasDefaultScene: boolean;
  92133. hasMaterials: boolean;
  92134. hasMorphTargets: boolean;
  92135. hasSkins: boolean;
  92136. hasTextures: boolean;
  92137. maxAttributesUsed: number;
  92138. primitivesCount: number
  92139. };
  92140. issues: {
  92141. messages: Array<string>;
  92142. numErrors: number;
  92143. numHints: number;
  92144. numInfos: number;
  92145. numWarnings: number;
  92146. truncated: boolean
  92147. };
  92148. mimeType: string;
  92149. uri: string;
  92150. validatedAt: string;
  92151. validatorVersion: string;
  92152. }
  92153. /**
  92154. * The glTF validation options
  92155. */
  92156. interface IGLTFValidationOptions {
  92157. /** Uri to use */
  92158. uri?: string;
  92159. /** Function used to load external resources */
  92160. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  92161. /** Boolean indicating that we need to validate accessor data */
  92162. validateAccessorData?: boolean;
  92163. /** max number of issues allowed */
  92164. maxIssues?: number;
  92165. /** Ignored issues */
  92166. ignoredIssues?: Array<string>;
  92167. /** Value to override severy settings */
  92168. severityOverrides?: Object;
  92169. }
  92170. /**
  92171. * The glTF validator object
  92172. * @ignore
  92173. */
  92174. interface IGLTFValidator {
  92175. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  92176. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  92177. }
  92178. /**
  92179. * Interfaces from the EXT_lights_image_based extension
  92180. */
  92181. /** @hidden */
  92182. interface IEXTLightsImageBased_LightReferenceImageBased {
  92183. light: number;
  92184. }
  92185. /** @hidden */
  92186. interface IEXTLightsImageBased_LightImageBased extends IChildRootProperty {
  92187. intensity: number;
  92188. rotation: number[];
  92189. specularImageSize: number;
  92190. specularImages: number[][];
  92191. irradianceCoefficients: number[][];
  92192. }
  92193. /** @hidden */
  92194. interface IEXTLightsImageBased {
  92195. lights: IEXTLightsImageBased_LightImageBased[];
  92196. }
  92197. /**
  92198. * Interfaces from the EXT_mesh_gpu_instancing extension
  92199. * !!! Experimental Extension Subject to Changes !!!
  92200. */
  92201. /** @hidden */
  92202. interface IEXTMeshGpuInstancing {
  92203. mesh?: number;
  92204. attributes: { [name: string]: number };
  92205. }
  92206. /**
  92207. * Interfaces from the KHR_draco_mesh_compression extension
  92208. */
  92209. /** @hidden */
  92210. interface IKHRDracoMeshCompression {
  92211. bufferView: number;
  92212. attributes: { [name: string]: number };
  92213. }
  92214. /**
  92215. * Interfaces from the KHR_lights_punctual extension
  92216. */
  92217. /** @hidden */
  92218. const enum IKHRLightsPunctual_LightType {
  92219. DIRECTIONAL = "directional",
  92220. POINT = "point",
  92221. SPOT = "spot"
  92222. }
  92223. /** @hidden */
  92224. interface IKHRLightsPunctual_LightReference {
  92225. light: number;
  92226. }
  92227. /** @hidden */
  92228. interface IKHRLightsPunctual_Light extends IChildRootProperty {
  92229. type: IKHRLightsPunctual_LightType;
  92230. color?: number[];
  92231. intensity?: number;
  92232. range?: number;
  92233. spot?: {
  92234. innerConeAngle?: number;
  92235. outerConeAngle?: number;
  92236. };
  92237. }
  92238. /** @hidden */
  92239. interface IKHRLightsPunctual {
  92240. lights: IKHRLightsPunctual_Light[];
  92241. }
  92242. /**
  92243. * Interfaces from the KHR_materials_clearcoat extension
  92244. * !!! Experimental Extension Subject to Changes !!!
  92245. */
  92246. /** @hidden */
  92247. interface IKHRMaterialsClearcoat {
  92248. clearcoatFactor: number;
  92249. clearcoatTexture: ITextureInfo;
  92250. clearcoatRoughnessFactor: number;
  92251. clearcoatRoughnessTexture: ITextureInfo;
  92252. clearcoatNormalTexture: IMaterialNormalTextureInfo;
  92253. }
  92254. /**
  92255. * Interfaces from the KHR_materials_ior extension
  92256. * !!! Experimental Extension Subject to Changes !!!
  92257. */
  92258. /** @hidden */
  92259. interface IKHRMaterialsIor {
  92260. ior: number;
  92261. }
  92262. /**
  92263. * Interfaces from the KHR_materials_pbrSpecularGlossiness extension
  92264. */
  92265. /** @hidden */
  92266. interface IKHRMaterialsPbrSpecularGlossiness {
  92267. diffuseFactor: number[];
  92268. diffuseTexture: ITextureInfo;
  92269. specularFactor: number[];
  92270. glossinessFactor: number;
  92271. specularGlossinessTexture: ITextureInfo;
  92272. }
  92273. /**
  92274. * Interfaces from the KHR_materials_sheen extension
  92275. * !!! Experimental Extension Subject to Changes !!!
  92276. */
  92277. /** @hidden */
  92278. interface IKHRMaterialsSheen {
  92279. sheenColorFactor?: number[];
  92280. sheenColorTexture?: ITextureInfo;
  92281. sheenRoughnessFactor?: number;
  92282. sheenRoughnessTexture?: ITextureInfo;
  92283. }
  92284. /**
  92285. * Interfaces from the KHR_materials_specular extension
  92286. * !!! Experimental Extension Subject to Changes !!!
  92287. */
  92288. /** @hidden */
  92289. interface IKHRMaterialsSpecular {
  92290. specularFactor: number;
  92291. specularColorFactor: number[];
  92292. specularTexture: ITextureInfo;
  92293. }
  92294. /**
  92295. * Interfaces from the KHR_materials_transmission extension
  92296. * !!! Experimental Extension Subject to Changes !!!
  92297. */
  92298. /** @hidden */
  92299. interface IKHRMaterialsTransmission {
  92300. transmissionFactor?: number;
  92301. transmissionTexture?: ITextureInfo;
  92302. }
  92303. /**
  92304. * Interfaces from the KHR_materials_translucency extension
  92305. * !!! Experimental Extension Subject to Changes !!!
  92306. */
  92307. /** @hidden */
  92308. interface IKHRMaterialsTranslucency {
  92309. translucencyFactor?: number;
  92310. translucencyTexture?: ITextureInfo;
  92311. }
  92312. /**
  92313. * Interfaces from the KHR_materials_variants extension
  92314. * !!! Experimental Extension Subject to Changes !!!
  92315. */
  92316. /** @hidden */
  92317. interface IKHRMaterialVariants_Mapping extends IProperty {
  92318. mappings: Array<{
  92319. variants: number[];
  92320. material: number;
  92321. }>;
  92322. }
  92323. /** @hidden */
  92324. interface IKHRMaterialVariants_Variant extends IProperty {
  92325. name: string;
  92326. }
  92327. /** @hidden */
  92328. interface IKHRMaterialVariants_Variants extends IChildRootProperty {
  92329. variants: Array<IKHRMaterialVariants_Variant>;
  92330. }
  92331. /**
  92332. * Interfaces from the KHR_texture_basisu extension
  92333. * !!! Experimental Extension Subject to Changes !!!
  92334. */
  92335. /** @hidden */
  92336. interface IKHRTextureBasisU {
  92337. source: number;
  92338. }
  92339. /**
  92340. * Interfaces from the EXT_texture_webp extension
  92341. */
  92342. /** @hidden */
  92343. interface IEXTTextureWebP {
  92344. source: number;
  92345. }
  92346. /**
  92347. * Interfaces from the KHR_texture_transform extension
  92348. */
  92349. /** @hidden */
  92350. interface IKHRTextureTransform {
  92351. offset?: number[];
  92352. rotation?: number;
  92353. scale?: number[];
  92354. texCoord?: number;
  92355. }
  92356. /**
  92357. * Interfaces from the KHR_xmp_json_ld extension
  92358. * !!! Experimental Extension Subject to Changes !!!
  92359. */
  92360. /** @hidden */
  92361. interface IKHRXmpJsonLd_Gltf {
  92362. packets: Array<{
  92363. [key: string]: unknown;
  92364. }>;
  92365. }
  92366. /** @hidden */
  92367. interface IKHRXmpJsonLd_Node {
  92368. packet: number;
  92369. }
  92370. /**
  92371. * Interfaces from the MSFT_audio_emitter extension
  92372. */
  92373. /** @hidden */
  92374. interface IMSFTAudioEmitter_ClipReference {
  92375. clip: number;
  92376. weight?: number;
  92377. }
  92378. /** @hidden */
  92379. interface IMSFTAudioEmitter_EmittersReference {
  92380. emitters: number[];
  92381. }
  92382. /** @hidden */
  92383. const enum IMSFTAudioEmitter_DistanceModel {
  92384. linear = "linear",
  92385. inverse = "inverse",
  92386. exponential = "exponential",
  92387. }
  92388. /** @hidden */
  92389. interface IMSFTAudioEmitter_Emitter {
  92390. name?: string;
  92391. distanceModel?: IMSFTAudioEmitter_DistanceModel;
  92392. refDistance?: number;
  92393. maxDistance?: number;
  92394. rolloffFactor?: number;
  92395. innerAngle?: number;
  92396. outerAngle?: number;
  92397. loop?: boolean;
  92398. volume?: number;
  92399. clips: IMSFTAudioEmitter_ClipReference[];
  92400. }
  92401. /** @hidden */
  92402. const enum IMSFTAudioEmitter_AudioMimeType {
  92403. WAV = "audio/wav",
  92404. }
  92405. /** @hidden */
  92406. interface IMSFTAudioEmitter_Clip extends IProperty {
  92407. uri?: string;
  92408. bufferView?: number;
  92409. mimeType?: IMSFTAudioEmitter_AudioMimeType;
  92410. }
  92411. /** @hidden */
  92412. const enum IMSFTAudioEmitter_AnimationEventAction {
  92413. play = "play",
  92414. pause = "pause",
  92415. stop = "stop",
  92416. }
  92417. /** @hidden */
  92418. interface IMSFTAudioEmitter_AnimationEvent {
  92419. action: IMSFTAudioEmitter_AnimationEventAction;
  92420. emitter: number;
  92421. time: number;
  92422. startOffset?: number;
  92423. }
  92424. /**
  92425. * Interfaces from the MSFT_lod extension
  92426. */
  92427. /** @hidden */
  92428. interface IMSFTLOD {
  92429. ids: number[];
  92430. }
  92431. /**
  92432. * Interfaces from the EXT_meshopt_compression extension
  92433. */
  92434. /** @hidden */
  92435. interface IEXTMeshoptCompression {
  92436. buffer: number;
  92437. byteOffset?: number;
  92438. byteLength: number;
  92439. byteStride: number;
  92440. count: number;
  92441. mode: "ATTRIBUTES" | "TRIANGLES" | "INDICES";
  92442. filter?: "NONE" | "OCTAHEDRAL" | "QUATERNION" | "EXPONENTIAL";
  92443. }
  92444. }
  92445. declare module BABYLON {
  92446. /** @hidden */
  92447. export var cellPixelShader: {
  92448. name: string;
  92449. shader: string;
  92450. };
  92451. }
  92452. declare module BABYLON {
  92453. /** @hidden */
  92454. export var cellVertexShader: {
  92455. name: string;
  92456. shader: string;
  92457. };
  92458. }
  92459. declare module BABYLON {
  92460. export class CellMaterial extends BABYLON.PushMaterial {
  92461. private _diffuseTexture;
  92462. diffuseTexture: BABYLON.BaseTexture;
  92463. diffuseColor: BABYLON.Color3;
  92464. _computeHighLevel: boolean;
  92465. computeHighLevel: boolean;
  92466. private _disableLighting;
  92467. disableLighting: boolean;
  92468. private _maxSimultaneousLights;
  92469. maxSimultaneousLights: number;
  92470. constructor(name: string, scene: BABYLON.Scene);
  92471. needAlphaBlending(): boolean;
  92472. needAlphaTesting(): boolean;
  92473. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92474. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92475. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92476. getAnimatables(): BABYLON.IAnimatable[];
  92477. getActiveTextures(): BABYLON.BaseTexture[];
  92478. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92479. dispose(forceDisposeEffect?: boolean): void;
  92480. getClassName(): string;
  92481. clone(name: string): CellMaterial;
  92482. serialize(): any;
  92483. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  92484. }
  92485. }
  92486. declare module BABYLON {
  92487. export class CustomShaderStructure {
  92488. FragmentStore: string;
  92489. VertexStore: string;
  92490. constructor();
  92491. }
  92492. export class ShaderSpecialParts {
  92493. constructor();
  92494. Fragment_Begin: string;
  92495. Fragment_Definitions: string;
  92496. Fragment_MainBegin: string;
  92497. Fragment_Custom_Diffuse: string;
  92498. Fragment_Before_Lights: string;
  92499. Fragment_Before_Fog: string;
  92500. Fragment_Custom_Alpha: string;
  92501. Fragment_Before_FragColor: string;
  92502. Vertex_Begin: string;
  92503. Vertex_Definitions: string;
  92504. Vertex_MainBegin: string;
  92505. Vertex_Before_PositionUpdated: string;
  92506. Vertex_Before_NormalUpdated: string;
  92507. Vertex_After_WorldPosComputed: string;
  92508. Vertex_MainEnd: string;
  92509. }
  92510. export class CustomMaterial extends BABYLON.StandardMaterial {
  92511. static ShaderIndexer: number;
  92512. CustomParts: ShaderSpecialParts;
  92513. _isCreatedShader: boolean;
  92514. _createdShaderName: string;
  92515. _customUniform: string[];
  92516. _newUniforms: string[];
  92517. _newUniformInstances: {
  92518. [name: string]: any;
  92519. };
  92520. _newSamplerInstances: {
  92521. [name: string]: BABYLON.Texture;
  92522. };
  92523. _customAttributes: string[];
  92524. FragmentShader: string;
  92525. VertexShader: string;
  92526. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  92527. ReviewUniform(name: string, arr: string[]): string[];
  92528. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  92529. constructor(name: string, scene: BABYLON.Scene);
  92530. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  92531. AddAttribute(name: string): CustomMaterial;
  92532. Fragment_Begin(shaderPart: string): CustomMaterial;
  92533. Fragment_Definitions(shaderPart: string): CustomMaterial;
  92534. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  92535. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  92536. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  92537. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  92538. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  92539. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  92540. Vertex_Begin(shaderPart: string): CustomMaterial;
  92541. Vertex_Definitions(shaderPart: string): CustomMaterial;
  92542. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  92543. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  92544. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  92545. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  92546. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  92547. }
  92548. }
  92549. declare module BABYLON {
  92550. export class ShaderAlebdoParts {
  92551. constructor();
  92552. Fragment_Begin: string;
  92553. Fragment_Definitions: string;
  92554. Fragment_MainBegin: string;
  92555. Fragment_Custom_Albedo: string;
  92556. Fragment_Before_Lights: string;
  92557. Fragment_Custom_MetallicRoughness: string;
  92558. Fragment_Custom_MicroSurface: string;
  92559. Fragment_Before_Fog: string;
  92560. Fragment_Custom_Alpha: string;
  92561. Fragment_Before_FragColor: string;
  92562. Vertex_Begin: string;
  92563. Vertex_Definitions: string;
  92564. Vertex_MainBegin: string;
  92565. Vertex_Before_PositionUpdated: string;
  92566. Vertex_Before_NormalUpdated: string;
  92567. Vertex_After_WorldPosComputed: string;
  92568. Vertex_MainEnd: string;
  92569. }
  92570. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  92571. static ShaderIndexer: number;
  92572. CustomParts: ShaderAlebdoParts;
  92573. _isCreatedShader: boolean;
  92574. _createdShaderName: string;
  92575. _customUniform: string[];
  92576. _newUniforms: string[];
  92577. _newUniformInstances: {
  92578. [name: string]: any;
  92579. };
  92580. _newSamplerInstances: {
  92581. [name: string]: BABYLON.Texture;
  92582. };
  92583. _customAttributes: string[];
  92584. FragmentShader: string;
  92585. VertexShader: string;
  92586. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  92587. ReviewUniform(name: string, arr: string[]): string[];
  92588. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[], options?: BABYLON.ICustomShaderNameResolveOptions): string;
  92589. constructor(name: string, scene: BABYLON.Scene);
  92590. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  92591. AddAttribute(name: string): PBRCustomMaterial;
  92592. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  92593. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  92594. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  92595. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  92596. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  92597. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  92598. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  92599. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  92600. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  92601. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  92602. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  92603. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  92604. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  92605. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  92606. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  92607. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  92608. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  92609. }
  92610. }
  92611. declare module BABYLON {
  92612. /** @hidden */
  92613. export var firePixelShader: {
  92614. name: string;
  92615. shader: string;
  92616. };
  92617. }
  92618. declare module BABYLON {
  92619. /** @hidden */
  92620. export var fireVertexShader: {
  92621. name: string;
  92622. shader: string;
  92623. };
  92624. }
  92625. declare module BABYLON {
  92626. export class FireMaterial extends BABYLON.PushMaterial {
  92627. private _diffuseTexture;
  92628. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  92629. private _distortionTexture;
  92630. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  92631. private _opacityTexture;
  92632. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  92633. diffuseColor: BABYLON.Color3;
  92634. speed: number;
  92635. private _scaledDiffuse;
  92636. private _lastTime;
  92637. constructor(name: string, scene: BABYLON.Scene);
  92638. needAlphaBlending(): boolean;
  92639. needAlphaTesting(): boolean;
  92640. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92641. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92642. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92643. getAnimatables(): BABYLON.IAnimatable[];
  92644. getActiveTextures(): BABYLON.BaseTexture[];
  92645. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92646. getClassName(): string;
  92647. dispose(forceDisposeEffect?: boolean): void;
  92648. clone(name: string): FireMaterial;
  92649. serialize(): any;
  92650. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  92651. }
  92652. }
  92653. declare module BABYLON {
  92654. /** @hidden */
  92655. export var furPixelShader: {
  92656. name: string;
  92657. shader: string;
  92658. };
  92659. }
  92660. declare module BABYLON {
  92661. /** @hidden */
  92662. export var furVertexShader: {
  92663. name: string;
  92664. shader: string;
  92665. };
  92666. }
  92667. declare module BABYLON {
  92668. export class FurMaterial extends BABYLON.PushMaterial {
  92669. private _diffuseTexture;
  92670. diffuseTexture: BABYLON.BaseTexture;
  92671. private _heightTexture;
  92672. heightTexture: BABYLON.BaseTexture;
  92673. diffuseColor: BABYLON.Color3;
  92674. furLength: number;
  92675. furAngle: number;
  92676. furColor: BABYLON.Color3;
  92677. furOffset: number;
  92678. furSpacing: number;
  92679. furGravity: BABYLON.Vector3;
  92680. furSpeed: number;
  92681. furDensity: number;
  92682. furOcclusion: number;
  92683. furTexture: BABYLON.DynamicTexture;
  92684. private _disableLighting;
  92685. disableLighting: boolean;
  92686. private _maxSimultaneousLights;
  92687. maxSimultaneousLights: number;
  92688. highLevelFur: boolean;
  92689. _meshes: BABYLON.AbstractMesh[];
  92690. private _furTime;
  92691. constructor(name: string, scene: BABYLON.Scene);
  92692. get furTime(): number;
  92693. set furTime(furTime: number);
  92694. needAlphaBlending(): boolean;
  92695. needAlphaTesting(): boolean;
  92696. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92697. updateFur(): void;
  92698. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92699. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92700. getAnimatables(): BABYLON.IAnimatable[];
  92701. getActiveTextures(): BABYLON.BaseTexture[];
  92702. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92703. dispose(forceDisposeEffect?: boolean): void;
  92704. clone(name: string): FurMaterial;
  92705. serialize(): any;
  92706. getClassName(): string;
  92707. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  92708. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  92709. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  92710. }
  92711. }
  92712. declare module BABYLON {
  92713. /** @hidden */
  92714. export var gradientPixelShader: {
  92715. name: string;
  92716. shader: string;
  92717. };
  92718. }
  92719. declare module BABYLON {
  92720. /** @hidden */
  92721. export var gradientVertexShader: {
  92722. name: string;
  92723. shader: string;
  92724. };
  92725. }
  92726. declare module BABYLON {
  92727. export class GradientMaterial extends BABYLON.PushMaterial {
  92728. private _maxSimultaneousLights;
  92729. maxSimultaneousLights: number;
  92730. topColor: BABYLON.Color3;
  92731. topColorAlpha: number;
  92732. bottomColor: BABYLON.Color3;
  92733. bottomColorAlpha: number;
  92734. offset: number;
  92735. scale: number;
  92736. smoothness: number;
  92737. private _disableLighting;
  92738. disableLighting: boolean;
  92739. constructor(name: string, scene: BABYLON.Scene);
  92740. needAlphaBlending(): boolean;
  92741. needAlphaTesting(): boolean;
  92742. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92743. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92744. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92745. getAnimatables(): BABYLON.IAnimatable[];
  92746. dispose(forceDisposeEffect?: boolean): void;
  92747. clone(name: string): GradientMaterial;
  92748. serialize(): any;
  92749. getClassName(): string;
  92750. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  92751. }
  92752. }
  92753. declare module BABYLON {
  92754. /** @hidden */
  92755. export var gridPixelShader: {
  92756. name: string;
  92757. shader: string;
  92758. };
  92759. }
  92760. declare module BABYLON {
  92761. /** @hidden */
  92762. export var gridVertexShader: {
  92763. name: string;
  92764. shader: string;
  92765. };
  92766. }
  92767. declare module BABYLON {
  92768. /**
  92769. * The grid materials allows you to wrap any shape with a grid.
  92770. * Colors are customizable.
  92771. */
  92772. export class GridMaterial extends BABYLON.PushMaterial {
  92773. /**
  92774. * Main color of the grid (e.g. between lines)
  92775. */
  92776. mainColor: BABYLON.Color3;
  92777. /**
  92778. * Color of the grid lines.
  92779. */
  92780. lineColor: BABYLON.Color3;
  92781. /**
  92782. * The scale of the grid compared to unit.
  92783. */
  92784. gridRatio: number;
  92785. /**
  92786. * Allows setting an offset for the grid lines.
  92787. */
  92788. gridOffset: BABYLON.Vector3;
  92789. /**
  92790. * The frequency of thicker lines.
  92791. */
  92792. majorUnitFrequency: number;
  92793. /**
  92794. * The visibility of minor units in the grid.
  92795. */
  92796. minorUnitVisibility: number;
  92797. /**
  92798. * The grid opacity outside of the lines.
  92799. */
  92800. opacity: number;
  92801. /**
  92802. * Determine RBG output is premultiplied by alpha value.
  92803. */
  92804. preMultiplyAlpha: boolean;
  92805. private _opacityTexture;
  92806. opacityTexture: BABYLON.BaseTexture;
  92807. private _gridControl;
  92808. /**
  92809. * constructor
  92810. * @param name The name given to the material in order to identify it afterwards.
  92811. * @param scene The scene the material is used in.
  92812. */
  92813. constructor(name: string, scene: BABYLON.Scene);
  92814. /**
  92815. * Returns wehter or not the grid requires alpha blending.
  92816. */
  92817. needAlphaBlending(): boolean;
  92818. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  92819. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92820. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92821. /**
  92822. * Dispose the material and its associated resources.
  92823. * @param forceDisposeEffect will also dispose the used effect when true
  92824. */
  92825. dispose(forceDisposeEffect?: boolean): void;
  92826. clone(name: string): GridMaterial;
  92827. serialize(): any;
  92828. getClassName(): string;
  92829. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  92830. }
  92831. }
  92832. declare module BABYLON {
  92833. /** @hidden */
  92834. export var lavaPixelShader: {
  92835. name: string;
  92836. shader: string;
  92837. };
  92838. }
  92839. declare module BABYLON {
  92840. /** @hidden */
  92841. export var lavaVertexShader: {
  92842. name: string;
  92843. shader: string;
  92844. };
  92845. }
  92846. declare module BABYLON {
  92847. export class LavaMaterial extends BABYLON.PushMaterial {
  92848. private _diffuseTexture;
  92849. diffuseTexture: BABYLON.BaseTexture;
  92850. noiseTexture: BABYLON.BaseTexture;
  92851. fogColor: BABYLON.Color3;
  92852. speed: number;
  92853. movingSpeed: number;
  92854. lowFrequencySpeed: number;
  92855. fogDensity: number;
  92856. private _lastTime;
  92857. diffuseColor: BABYLON.Color3;
  92858. private _disableLighting;
  92859. disableLighting: boolean;
  92860. private _unlit;
  92861. unlit: boolean;
  92862. private _maxSimultaneousLights;
  92863. maxSimultaneousLights: number;
  92864. private _scaledDiffuse;
  92865. constructor(name: string, scene: BABYLON.Scene);
  92866. needAlphaBlending(): boolean;
  92867. needAlphaTesting(): boolean;
  92868. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92869. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92870. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92871. getAnimatables(): BABYLON.IAnimatable[];
  92872. getActiveTextures(): BABYLON.BaseTexture[];
  92873. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92874. dispose(forceDisposeEffect?: boolean): void;
  92875. clone(name: string): LavaMaterial;
  92876. serialize(): any;
  92877. getClassName(): string;
  92878. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  92879. }
  92880. }
  92881. declare module BABYLON {
  92882. /** @hidden */
  92883. export var mixPixelShader: {
  92884. name: string;
  92885. shader: string;
  92886. };
  92887. }
  92888. declare module BABYLON {
  92889. /** @hidden */
  92890. export var mixVertexShader: {
  92891. name: string;
  92892. shader: string;
  92893. };
  92894. }
  92895. declare module BABYLON {
  92896. export class MixMaterial extends BABYLON.PushMaterial {
  92897. /**
  92898. * Mix textures
  92899. */
  92900. private _mixTexture1;
  92901. mixTexture1: BABYLON.BaseTexture;
  92902. private _mixTexture2;
  92903. mixTexture2: BABYLON.BaseTexture;
  92904. /**
  92905. * Diffuse textures
  92906. */
  92907. private _diffuseTexture1;
  92908. diffuseTexture1: BABYLON.Texture;
  92909. private _diffuseTexture2;
  92910. diffuseTexture2: BABYLON.Texture;
  92911. private _diffuseTexture3;
  92912. diffuseTexture3: BABYLON.Texture;
  92913. private _diffuseTexture4;
  92914. diffuseTexture4: BABYLON.Texture;
  92915. private _diffuseTexture5;
  92916. diffuseTexture5: BABYLON.Texture;
  92917. private _diffuseTexture6;
  92918. diffuseTexture6: BABYLON.Texture;
  92919. private _diffuseTexture7;
  92920. diffuseTexture7: BABYLON.Texture;
  92921. private _diffuseTexture8;
  92922. diffuseTexture8: BABYLON.Texture;
  92923. /**
  92924. * Uniforms
  92925. */
  92926. diffuseColor: BABYLON.Color3;
  92927. specularColor: BABYLON.Color3;
  92928. specularPower: number;
  92929. private _disableLighting;
  92930. disableLighting: boolean;
  92931. private _maxSimultaneousLights;
  92932. maxSimultaneousLights: number;
  92933. constructor(name: string, scene: BABYLON.Scene);
  92934. needAlphaBlending(): boolean;
  92935. needAlphaTesting(): boolean;
  92936. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92937. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92938. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92939. getAnimatables(): BABYLON.IAnimatable[];
  92940. getActiveTextures(): BABYLON.BaseTexture[];
  92941. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92942. dispose(forceDisposeEffect?: boolean): void;
  92943. clone(name: string): MixMaterial;
  92944. serialize(): any;
  92945. getClassName(): string;
  92946. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  92947. }
  92948. }
  92949. declare module BABYLON {
  92950. /** @hidden */
  92951. export var normalPixelShader: {
  92952. name: string;
  92953. shader: string;
  92954. };
  92955. }
  92956. declare module BABYLON {
  92957. /** @hidden */
  92958. export var normalVertexShader: {
  92959. name: string;
  92960. shader: string;
  92961. };
  92962. }
  92963. declare module BABYLON {
  92964. export class NormalMaterial extends BABYLON.PushMaterial {
  92965. private _diffuseTexture;
  92966. diffuseTexture: BABYLON.BaseTexture;
  92967. diffuseColor: BABYLON.Color3;
  92968. private _disableLighting;
  92969. disableLighting: boolean;
  92970. private _maxSimultaneousLights;
  92971. maxSimultaneousLights: number;
  92972. constructor(name: string, scene: BABYLON.Scene);
  92973. needAlphaBlending(): boolean;
  92974. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  92975. needAlphaTesting(): boolean;
  92976. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92977. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92978. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92979. getAnimatables(): BABYLON.IAnimatable[];
  92980. getActiveTextures(): BABYLON.BaseTexture[];
  92981. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92982. dispose(forceDisposeEffect?: boolean): void;
  92983. clone(name: string): NormalMaterial;
  92984. serialize(): any;
  92985. getClassName(): string;
  92986. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  92987. }
  92988. }
  92989. declare module BABYLON {
  92990. /** @hidden */
  92991. export var shadowOnlyPixelShader: {
  92992. name: string;
  92993. shader: string;
  92994. };
  92995. }
  92996. declare module BABYLON {
  92997. /** @hidden */
  92998. export var shadowOnlyVertexShader: {
  92999. name: string;
  93000. shader: string;
  93001. };
  93002. }
  93003. declare module BABYLON {
  93004. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  93005. private _activeLight;
  93006. private _needAlphaBlending;
  93007. constructor(name: string, scene: BABYLON.Scene);
  93008. shadowColor: BABYLON.Color3;
  93009. needAlphaBlending(): boolean;
  93010. needAlphaTesting(): boolean;
  93011. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  93012. get activeLight(): BABYLON.IShadowLight;
  93013. set activeLight(light: BABYLON.IShadowLight);
  93014. private _getFirstShadowLightForMesh;
  93015. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  93016. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  93017. clone(name: string): ShadowOnlyMaterial;
  93018. serialize(): any;
  93019. getClassName(): string;
  93020. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  93021. }
  93022. }
  93023. declare module BABYLON {
  93024. /** @hidden */
  93025. export var simplePixelShader: {
  93026. name: string;
  93027. shader: string;
  93028. };
  93029. }
  93030. declare module BABYLON {
  93031. /** @hidden */
  93032. export var simpleVertexShader: {
  93033. name: string;
  93034. shader: string;
  93035. };
  93036. }
  93037. declare module BABYLON {
  93038. export class SimpleMaterial extends BABYLON.PushMaterial {
  93039. private _diffuseTexture;
  93040. diffuseTexture: BABYLON.BaseTexture;
  93041. diffuseColor: BABYLON.Color3;
  93042. private _disableLighting;
  93043. disableLighting: boolean;
  93044. private _maxSimultaneousLights;
  93045. maxSimultaneousLights: number;
  93046. constructor(name: string, scene: BABYLON.Scene);
  93047. needAlphaBlending(): boolean;
  93048. needAlphaTesting(): boolean;
  93049. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  93050. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  93051. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  93052. getAnimatables(): BABYLON.IAnimatable[];
  93053. getActiveTextures(): BABYLON.BaseTexture[];
  93054. hasTexture(texture: BABYLON.BaseTexture): boolean;
  93055. dispose(forceDisposeEffect?: boolean): void;
  93056. clone(name: string): SimpleMaterial;
  93057. serialize(): any;
  93058. getClassName(): string;
  93059. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  93060. }
  93061. }
  93062. declare module BABYLON {
  93063. /** @hidden */
  93064. export var skyPixelShader: {
  93065. name: string;
  93066. shader: string;
  93067. };
  93068. }
  93069. declare module BABYLON {
  93070. /** @hidden */
  93071. export var skyVertexShader: {
  93072. name: string;
  93073. shader: string;
  93074. };
  93075. }
  93076. declare module BABYLON {
  93077. /**
  93078. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  93079. * @see https://doc.babylonjs.com/extensions/sky
  93080. */
  93081. export class SkyMaterial extends BABYLON.PushMaterial {
  93082. /**
  93083. * Defines the overall luminance of sky in interval ]0, 1[.
  93084. */
  93085. luminance: number;
  93086. /**
  93087. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  93088. */
  93089. turbidity: number;
  93090. /**
  93091. * Defines the sky appearance (light intensity).
  93092. */
  93093. rayleigh: number;
  93094. /**
  93095. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  93096. */
  93097. mieCoefficient: number;
  93098. /**
  93099. * Defines the amount of haze particles following the Mie scattering theory.
  93100. */
  93101. mieDirectionalG: number;
  93102. /**
  93103. * Defines the distance of the sun according to the active scene camera.
  93104. */
  93105. distance: number;
  93106. /**
  93107. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  93108. * "inclined".
  93109. */
  93110. inclination: number;
  93111. /**
  93112. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  93113. * an object direction and a reference direction.
  93114. */
  93115. azimuth: number;
  93116. /**
  93117. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  93118. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  93119. */
  93120. sunPosition: BABYLON.Vector3;
  93121. /**
  93122. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  93123. * .sunPosition property.
  93124. */
  93125. useSunPosition: boolean;
  93126. /**
  93127. * Defines an offset vector used to get a horizon offset.
  93128. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  93129. */
  93130. cameraOffset: BABYLON.Vector3;
  93131. /**
  93132. * Defines the vector the skyMaterial should consider as up. (default is BABYLON.Vector3(0, 1, 0) as returned by BABYLON.Vector3.Up())
  93133. */
  93134. up: BABYLON.Vector3;
  93135. private _cameraPosition;
  93136. private _skyOrientation;
  93137. /**
  93138. * Instantiates a new sky material.
  93139. * This material allows to create dynamic and texture free
  93140. * effects for skyboxes by taking care of the atmosphere state.
  93141. * @see https://doc.babylonjs.com/extensions/sky
  93142. * @param name Define the name of the material in the scene
  93143. * @param scene Define the scene the material belong to
  93144. */
  93145. constructor(name: string, scene: BABYLON.Scene);
  93146. /**
  93147. * Specifies if the material will require alpha blending
  93148. * @returns a boolean specifying if alpha blending is needed
  93149. */
  93150. needAlphaBlending(): boolean;
  93151. /**
  93152. * Specifies if this material should be rendered in alpha test mode
  93153. * @returns false as the sky material doesn't need alpha testing.
  93154. */
  93155. needAlphaTesting(): boolean;
  93156. /**
  93157. * Get the texture used for alpha test purpose.
  93158. * @returns null as the sky material has no texture.
  93159. */
  93160. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  93161. /**
  93162. * Get if the submesh is ready to be used and all its information available.
  93163. * Child classes can use it to update shaders
  93164. * @param mesh defines the mesh to check
  93165. * @param subMesh defines which submesh to check
  93166. * @param useInstances specifies that instances should be used
  93167. * @returns a boolean indicating that the submesh is ready or not
  93168. */
  93169. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  93170. /**
  93171. * Binds the submesh to this material by preparing the effect and shader to draw
  93172. * @param world defines the world transformation matrix
  93173. * @param mesh defines the mesh containing the submesh
  93174. * @param subMesh defines the submesh to bind the material to
  93175. */
  93176. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  93177. /**
  93178. * Get the list of animatables in the material.
  93179. * @returns the list of animatables object used in the material
  93180. */
  93181. getAnimatables(): BABYLON.IAnimatable[];
  93182. /**
  93183. * Disposes the material
  93184. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  93185. */
  93186. dispose(forceDisposeEffect?: boolean): void;
  93187. /**
  93188. * Makes a duplicate of the material, and gives it a new name
  93189. * @param name defines the new name for the duplicated material
  93190. * @returns the cloned material
  93191. */
  93192. clone(name: string): SkyMaterial;
  93193. /**
  93194. * Serializes this material in a JSON representation
  93195. * @returns the serialized material object
  93196. */
  93197. serialize(): any;
  93198. /**
  93199. * Gets the current class name of the material e.g. "SkyMaterial"
  93200. * Mainly use in serialization.
  93201. * @returns the class name
  93202. */
  93203. getClassName(): string;
  93204. /**
  93205. * Creates a sky material from parsed material data
  93206. * @param source defines the JSON representation of the material
  93207. * @param scene defines the hosting scene
  93208. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  93209. * @returns a new sky material
  93210. */
  93211. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  93212. }
  93213. }
  93214. declare module BABYLON {
  93215. /** @hidden */
  93216. export var terrainPixelShader: {
  93217. name: string;
  93218. shader: string;
  93219. };
  93220. }
  93221. declare module BABYLON {
  93222. /** @hidden */
  93223. export var terrainVertexShader: {
  93224. name: string;
  93225. shader: string;
  93226. };
  93227. }
  93228. declare module BABYLON {
  93229. export class TerrainMaterial extends BABYLON.PushMaterial {
  93230. private _mixTexture;
  93231. mixTexture: BABYLON.BaseTexture;
  93232. private _diffuseTexture1;
  93233. diffuseTexture1: BABYLON.Texture;
  93234. private _diffuseTexture2;
  93235. diffuseTexture2: BABYLON.Texture;
  93236. private _diffuseTexture3;
  93237. diffuseTexture3: BABYLON.Texture;
  93238. private _bumpTexture1;
  93239. bumpTexture1: BABYLON.Texture;
  93240. private _bumpTexture2;
  93241. bumpTexture2: BABYLON.Texture;
  93242. private _bumpTexture3;
  93243. bumpTexture3: BABYLON.Texture;
  93244. diffuseColor: BABYLON.Color3;
  93245. specularColor: BABYLON.Color3;
  93246. specularPower: number;
  93247. private _disableLighting;
  93248. disableLighting: boolean;
  93249. private _maxSimultaneousLights;
  93250. maxSimultaneousLights: number;
  93251. constructor(name: string, scene: BABYLON.Scene);
  93252. needAlphaBlending(): boolean;
  93253. needAlphaTesting(): boolean;
  93254. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  93255. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  93256. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  93257. getAnimatables(): BABYLON.IAnimatable[];
  93258. getActiveTextures(): BABYLON.BaseTexture[];
  93259. hasTexture(texture: BABYLON.BaseTexture): boolean;
  93260. dispose(forceDisposeEffect?: boolean): void;
  93261. clone(name: string): TerrainMaterial;
  93262. serialize(): any;
  93263. getClassName(): string;
  93264. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  93265. }
  93266. }
  93267. declare module BABYLON {
  93268. /** @hidden */
  93269. export var triplanarPixelShader: {
  93270. name: string;
  93271. shader: string;
  93272. };
  93273. }
  93274. declare module BABYLON {
  93275. /** @hidden */
  93276. export var triplanarVertexShader: {
  93277. name: string;
  93278. shader: string;
  93279. };
  93280. }
  93281. declare module BABYLON {
  93282. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  93283. mixTexture: BABYLON.BaseTexture;
  93284. private _diffuseTextureX;
  93285. diffuseTextureX: BABYLON.BaseTexture;
  93286. private _diffuseTextureY;
  93287. diffuseTextureY: BABYLON.BaseTexture;
  93288. private _diffuseTextureZ;
  93289. diffuseTextureZ: BABYLON.BaseTexture;
  93290. private _normalTextureX;
  93291. normalTextureX: BABYLON.BaseTexture;
  93292. private _normalTextureY;
  93293. normalTextureY: BABYLON.BaseTexture;
  93294. private _normalTextureZ;
  93295. normalTextureZ: BABYLON.BaseTexture;
  93296. tileSize: number;
  93297. diffuseColor: BABYLON.Color3;
  93298. specularColor: BABYLON.Color3;
  93299. specularPower: number;
  93300. private _disableLighting;
  93301. disableLighting: boolean;
  93302. private _maxSimultaneousLights;
  93303. maxSimultaneousLights: number;
  93304. constructor(name: string, scene: BABYLON.Scene);
  93305. needAlphaBlending(): boolean;
  93306. needAlphaTesting(): boolean;
  93307. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  93308. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  93309. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  93310. getAnimatables(): BABYLON.IAnimatable[];
  93311. getActiveTextures(): BABYLON.BaseTexture[];
  93312. hasTexture(texture: BABYLON.BaseTexture): boolean;
  93313. dispose(forceDisposeEffect?: boolean): void;
  93314. clone(name: string): TriPlanarMaterial;
  93315. serialize(): any;
  93316. getClassName(): string;
  93317. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  93318. }
  93319. }
  93320. declare module BABYLON {
  93321. /** @hidden */
  93322. export var waterPixelShader: {
  93323. name: string;
  93324. shader: string;
  93325. };
  93326. }
  93327. declare module BABYLON {
  93328. /** @hidden */
  93329. export var waterVertexShader: {
  93330. name: string;
  93331. shader: string;
  93332. };
  93333. }
  93334. declare module BABYLON {
  93335. export class WaterMaterial extends BABYLON.PushMaterial {
  93336. renderTargetSize: BABYLON.Vector2;
  93337. private _bumpTexture;
  93338. bumpTexture: BABYLON.BaseTexture;
  93339. diffuseColor: BABYLON.Color3;
  93340. specularColor: BABYLON.Color3;
  93341. specularPower: number;
  93342. private _disableLighting;
  93343. disableLighting: boolean;
  93344. private _maxSimultaneousLights;
  93345. maxSimultaneousLights: number;
  93346. /**
  93347. * Defines the wind force.
  93348. */
  93349. windForce: number;
  93350. /**
  93351. * Defines the direction of the wind in the plane (X, Z).
  93352. */
  93353. windDirection: BABYLON.Vector2;
  93354. /**
  93355. * Defines the height of the waves.
  93356. */
  93357. waveHeight: number;
  93358. /**
  93359. * Defines the bump height related to the bump map.
  93360. */
  93361. bumpHeight: number;
  93362. /**
  93363. * Defines wether or not: to add a smaller moving bump to less steady waves.
  93364. */
  93365. private _bumpSuperimpose;
  93366. bumpSuperimpose: boolean;
  93367. /**
  93368. * Defines wether or not color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  93369. */
  93370. private _fresnelSeparate;
  93371. fresnelSeparate: boolean;
  93372. /**
  93373. * Defines wether or not bump Wwves modify the reflection.
  93374. */
  93375. private _bumpAffectsReflection;
  93376. bumpAffectsReflection: boolean;
  93377. /**
  93378. * Defines the water color blended with the refraction (near).
  93379. */
  93380. waterColor: BABYLON.Color3;
  93381. /**
  93382. * Defines the blend factor related to the water color.
  93383. */
  93384. colorBlendFactor: number;
  93385. /**
  93386. * Defines the water color blended with the reflection (far).
  93387. */
  93388. waterColor2: BABYLON.Color3;
  93389. /**
  93390. * Defines the blend factor related to the water color (reflection, far).
  93391. */
  93392. colorBlendFactor2: number;
  93393. /**
  93394. * Defines the maximum length of a wave.
  93395. */
  93396. waveLength: number;
  93397. /**
  93398. * Defines the waves speed.
  93399. */
  93400. waveSpeed: number;
  93401. /**
  93402. * 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.
  93403. */
  93404. waveCount: number;
  93405. /**
  93406. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  93407. * will avoid calculating useless pixels in the pixel shader of the water material.
  93408. */
  93409. disableClipPlane: boolean;
  93410. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  93411. private _mesh;
  93412. private _refractionRTT;
  93413. private _reflectionRTT;
  93414. private _reflectionTransform;
  93415. private _lastTime;
  93416. private _lastDeltaTime;
  93417. private _useLogarithmicDepth;
  93418. private _waitingRenderList;
  93419. private _imageProcessingConfiguration;
  93420. private _imageProcessingObserver;
  93421. /**
  93422. * Gets a boolean indicating that current material needs to register RTT
  93423. */
  93424. get hasRenderTargetTextures(): boolean;
  93425. /**
  93426. * Constructor
  93427. */
  93428. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  93429. get useLogarithmicDepth(): boolean;
  93430. set useLogarithmicDepth(value: boolean);
  93431. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  93432. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  93433. addToRenderList(node: any): void;
  93434. enableRenderTargets(enable: boolean): void;
  93435. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  93436. get renderTargetsEnabled(): boolean;
  93437. needAlphaBlending(): boolean;
  93438. needAlphaTesting(): boolean;
  93439. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  93440. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  93441. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  93442. private _createRenderTargets;
  93443. getAnimatables(): BABYLON.IAnimatable[];
  93444. getActiveTextures(): BABYLON.BaseTexture[];
  93445. hasTexture(texture: BABYLON.BaseTexture): boolean;
  93446. dispose(forceDisposeEffect?: boolean): void;
  93447. clone(name: string): WaterMaterial;
  93448. serialize(): any;
  93449. getClassName(): string;
  93450. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  93451. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  93452. }
  93453. }
  93454. declare module BABYLON {
  93455. /** @hidden */
  93456. export var asciiartPixelShader: {
  93457. name: string;
  93458. shader: string;
  93459. };
  93460. }
  93461. declare module BABYLON {
  93462. /**
  93463. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  93464. *
  93465. * It basically takes care rendering the font front the given font size to a texture.
  93466. * This is used later on in the postprocess.
  93467. */
  93468. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  93469. private _font;
  93470. private _text;
  93471. private _charSize;
  93472. /**
  93473. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  93474. */
  93475. get charSize(): number;
  93476. /**
  93477. * Create a new instance of the Ascii Art FontTexture class
  93478. * @param name the name of the texture
  93479. * @param font the font to use, use the W3C CSS notation
  93480. * @param text the caracter set to use in the rendering.
  93481. * @param scene the scene that owns the texture
  93482. */
  93483. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  93484. /**
  93485. * Gets the max char width of a font.
  93486. * @param font the font to use, use the W3C CSS notation
  93487. * @return the max char width
  93488. */
  93489. private getFontWidth;
  93490. /**
  93491. * Gets the max char height of a font.
  93492. * @param font the font to use, use the W3C CSS notation
  93493. * @return the max char height
  93494. */
  93495. private getFontHeight;
  93496. /**
  93497. * Clones the current AsciiArtTexture.
  93498. * @return the clone of the texture.
  93499. */
  93500. clone(): AsciiArtFontTexture;
  93501. /**
  93502. * Parses a json object representing the texture and returns an instance of it.
  93503. * @param source the source JSON representation
  93504. * @param scene the scene to create the texture for
  93505. * @return the parsed texture
  93506. */
  93507. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  93508. }
  93509. /**
  93510. * Option available in the Ascii Art Post Process.
  93511. */
  93512. export interface IAsciiArtPostProcessOptions {
  93513. /**
  93514. * The font to use following the w3c font definition.
  93515. */
  93516. font?: string;
  93517. /**
  93518. * The character set to use in the postprocess.
  93519. */
  93520. characterSet?: string;
  93521. /**
  93522. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  93523. * This number is defined between 0 and 1;
  93524. */
  93525. mixToTile?: number;
  93526. /**
  93527. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  93528. * This number is defined between 0 and 1;
  93529. */
  93530. mixToNormal?: number;
  93531. }
  93532. /**
  93533. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  93534. *
  93535. * Simmply add it to your scene and let the nerd that lives in you have fun.
  93536. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  93537. */
  93538. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  93539. /**
  93540. * The font texture used to render the char in the post process.
  93541. */
  93542. private _asciiArtFontTexture;
  93543. /**
  93544. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  93545. * This number is defined between 0 and 1;
  93546. */
  93547. mixToTile: number;
  93548. /**
  93549. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  93550. * This number is defined between 0 and 1;
  93551. */
  93552. mixToNormal: number;
  93553. /**
  93554. * Instantiates a new Ascii Art Post Process.
  93555. * @param name the name to give to the postprocess
  93556. * @camera the camera to apply the post process to.
  93557. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  93558. */
  93559. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  93560. }
  93561. }
  93562. declare module BABYLON {
  93563. /** @hidden */
  93564. export var digitalrainPixelShader: {
  93565. name: string;
  93566. shader: string;
  93567. };
  93568. }
  93569. declare module BABYLON {
  93570. /**
  93571. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  93572. *
  93573. * It basically takes care rendering the font front the given font size to a texture.
  93574. * This is used later on in the postprocess.
  93575. */
  93576. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  93577. private _font;
  93578. private _text;
  93579. private _charSize;
  93580. /**
  93581. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  93582. */
  93583. get charSize(): number;
  93584. /**
  93585. * Create a new instance of the Digital Rain FontTexture class
  93586. * @param name the name of the texture
  93587. * @param font the font to use, use the W3C CSS notation
  93588. * @param text the caracter set to use in the rendering.
  93589. * @param scene the scene that owns the texture
  93590. */
  93591. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  93592. /**
  93593. * Gets the max char width of a font.
  93594. * @param font the font to use, use the W3C CSS notation
  93595. * @return the max char width
  93596. */
  93597. private getFontWidth;
  93598. /**
  93599. * Gets the max char height of a font.
  93600. * @param font the font to use, use the W3C CSS notation
  93601. * @return the max char height
  93602. */
  93603. private getFontHeight;
  93604. /**
  93605. * Clones the current DigitalRainFontTexture.
  93606. * @return the clone of the texture.
  93607. */
  93608. clone(): DigitalRainFontTexture;
  93609. /**
  93610. * Parses a json object representing the texture and returns an instance of it.
  93611. * @param source the source JSON representation
  93612. * @param scene the scene to create the texture for
  93613. * @return the parsed texture
  93614. */
  93615. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  93616. }
  93617. /**
  93618. * Option available in the Digital Rain Post Process.
  93619. */
  93620. export interface IDigitalRainPostProcessOptions {
  93621. /**
  93622. * The font to use following the w3c font definition.
  93623. */
  93624. font?: string;
  93625. /**
  93626. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  93627. * This number is defined between 0 and 1;
  93628. */
  93629. mixToTile?: number;
  93630. /**
  93631. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  93632. * This number is defined between 0 and 1;
  93633. */
  93634. mixToNormal?: number;
  93635. }
  93636. /**
  93637. * DigitalRainPostProcess helps rendering everithing in digital rain.
  93638. *
  93639. * Simmply add it to your scene and let the nerd that lives in you have fun.
  93640. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  93641. */
  93642. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  93643. /**
  93644. * The font texture used to render the char in the post process.
  93645. */
  93646. private _digitalRainFontTexture;
  93647. /**
  93648. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  93649. * This number is defined between 0 and 1;
  93650. */
  93651. mixToTile: number;
  93652. /**
  93653. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  93654. * This number is defined between 0 and 1;
  93655. */
  93656. mixToNormal: number;
  93657. /**
  93658. * Instantiates a new Digital Rain Post Process.
  93659. * @param name the name to give to the postprocess
  93660. * @camera the camera to apply the post process to.
  93661. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  93662. */
  93663. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  93664. }
  93665. }
  93666. declare module BABYLON {
  93667. /** @hidden */
  93668. export var brickProceduralTexturePixelShader: {
  93669. name: string;
  93670. shader: string;
  93671. };
  93672. }
  93673. declare module BABYLON {
  93674. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  93675. private _numberOfBricksHeight;
  93676. private _numberOfBricksWidth;
  93677. private _jointColor;
  93678. private _brickColor;
  93679. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93680. updateShaderUniforms(): void;
  93681. get numberOfBricksHeight(): number;
  93682. set numberOfBricksHeight(value: number);
  93683. get numberOfBricksWidth(): number;
  93684. set numberOfBricksWidth(value: number);
  93685. get jointColor(): BABYLON.Color3;
  93686. set jointColor(value: BABYLON.Color3);
  93687. get brickColor(): BABYLON.Color3;
  93688. set brickColor(value: BABYLON.Color3);
  93689. /**
  93690. * Serializes this brick procedural texture
  93691. * @returns a serialized brick procedural texture object
  93692. */
  93693. serialize(): any;
  93694. /**
  93695. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  93696. * @param parsedTexture defines parsed texture data
  93697. * @param scene defines the current scene
  93698. * @param rootUrl defines the root URL containing brick procedural texture information
  93699. * @returns a parsed Brick Procedural BABYLON.Texture
  93700. */
  93701. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  93702. }
  93703. }
  93704. declare module BABYLON {
  93705. /** @hidden */
  93706. export var cloudProceduralTexturePixelShader: {
  93707. name: string;
  93708. shader: string;
  93709. };
  93710. }
  93711. declare module BABYLON {
  93712. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  93713. private _skyColor;
  93714. private _cloudColor;
  93715. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93716. updateShaderUniforms(): void;
  93717. get skyColor(): BABYLON.Color4;
  93718. set skyColor(value: BABYLON.Color4);
  93719. get cloudColor(): BABYLON.Color4;
  93720. set cloudColor(value: BABYLON.Color4);
  93721. /**
  93722. * Serializes this cloud procedural texture
  93723. * @returns a serialized cloud procedural texture object
  93724. */
  93725. serialize(): any;
  93726. /**
  93727. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  93728. * @param parsedTexture defines parsed texture data
  93729. * @param scene defines the current scene
  93730. * @param rootUrl defines the root URL containing cloud procedural texture information
  93731. * @returns a parsed Cloud Procedural BABYLON.Texture
  93732. */
  93733. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  93734. }
  93735. }
  93736. declare module BABYLON {
  93737. /** @hidden */
  93738. export var fireProceduralTexturePixelShader: {
  93739. name: string;
  93740. shader: string;
  93741. };
  93742. }
  93743. declare module BABYLON {
  93744. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  93745. private _time;
  93746. private _speed;
  93747. private _autoGenerateTime;
  93748. private _fireColors;
  93749. private _alphaThreshold;
  93750. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93751. updateShaderUniforms(): void;
  93752. render(useCameraPostProcess?: boolean): void;
  93753. static get PurpleFireColors(): BABYLON.Color3[];
  93754. static get GreenFireColors(): BABYLON.Color3[];
  93755. static get RedFireColors(): BABYLON.Color3[];
  93756. static get BlueFireColors(): BABYLON.Color3[];
  93757. get autoGenerateTime(): boolean;
  93758. set autoGenerateTime(value: boolean);
  93759. get fireColors(): BABYLON.Color3[];
  93760. set fireColors(value: BABYLON.Color3[]);
  93761. get time(): number;
  93762. set time(value: number);
  93763. get speed(): BABYLON.Vector2;
  93764. set speed(value: BABYLON.Vector2);
  93765. get alphaThreshold(): number;
  93766. set alphaThreshold(value: number);
  93767. /**
  93768. * Serializes this fire procedural texture
  93769. * @returns a serialized fire procedural texture object
  93770. */
  93771. serialize(): any;
  93772. /**
  93773. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  93774. * @param parsedTexture defines parsed texture data
  93775. * @param scene defines the current scene
  93776. * @param rootUrl defines the root URL containing fire procedural texture information
  93777. * @returns a parsed Fire Procedural BABYLON.Texture
  93778. */
  93779. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  93780. }
  93781. }
  93782. declare module BABYLON {
  93783. /** @hidden */
  93784. export var grassProceduralTexturePixelShader: {
  93785. name: string;
  93786. shader: string;
  93787. };
  93788. }
  93789. declare module BABYLON {
  93790. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  93791. private _grassColors;
  93792. private _groundColor;
  93793. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93794. updateShaderUniforms(): void;
  93795. get grassColors(): BABYLON.Color3[];
  93796. set grassColors(value: BABYLON.Color3[]);
  93797. get groundColor(): BABYLON.Color3;
  93798. set groundColor(value: BABYLON.Color3);
  93799. /**
  93800. * Serializes this grass procedural texture
  93801. * @returns a serialized grass procedural texture object
  93802. */
  93803. serialize(): any;
  93804. /**
  93805. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  93806. * @param parsedTexture defines parsed texture data
  93807. * @param scene defines the current scene
  93808. * @param rootUrl defines the root URL containing grass procedural texture information
  93809. * @returns a parsed Grass Procedural BABYLON.Texture
  93810. */
  93811. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  93812. }
  93813. }
  93814. declare module BABYLON {
  93815. /** @hidden */
  93816. export var marbleProceduralTexturePixelShader: {
  93817. name: string;
  93818. shader: string;
  93819. };
  93820. }
  93821. declare module BABYLON {
  93822. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  93823. private _numberOfTilesHeight;
  93824. private _numberOfTilesWidth;
  93825. private _amplitude;
  93826. private _jointColor;
  93827. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93828. updateShaderUniforms(): void;
  93829. get numberOfTilesHeight(): number;
  93830. set numberOfTilesHeight(value: number);
  93831. get amplitude(): number;
  93832. set amplitude(value: number);
  93833. get numberOfTilesWidth(): number;
  93834. set numberOfTilesWidth(value: number);
  93835. get jointColor(): BABYLON.Color3;
  93836. set jointColor(value: BABYLON.Color3);
  93837. /**
  93838. * Serializes this marble procedural texture
  93839. * @returns a serialized marble procedural texture object
  93840. */
  93841. serialize(): any;
  93842. /**
  93843. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  93844. * @param parsedTexture defines parsed texture data
  93845. * @param scene defines the current scene
  93846. * @param rootUrl defines the root URL containing marble procedural texture information
  93847. * @returns a parsed Marble Procedural BABYLON.Texture
  93848. */
  93849. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  93850. }
  93851. }
  93852. declare module BABYLON {
  93853. /** @hidden */
  93854. export var normalMapProceduralTexturePixelShader: {
  93855. name: string;
  93856. shader: string;
  93857. };
  93858. }
  93859. declare module BABYLON {
  93860. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  93861. private _baseTexture;
  93862. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93863. updateShaderUniforms(): void;
  93864. render(useCameraPostProcess?: boolean): void;
  93865. resize(size: any, generateMipMaps: any): void;
  93866. isReady(): boolean;
  93867. get baseTexture(): BABYLON.Texture;
  93868. set baseTexture(texture: BABYLON.Texture);
  93869. /**
  93870. * Serializes this normal map procedural texture
  93871. * @returns a serialized normal map procedural texture object
  93872. */
  93873. serialize(): any;
  93874. /**
  93875. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  93876. * @param parsedTexture defines parsed texture data
  93877. * @param scene defines the current scene
  93878. * @param rootUrl defines the root URL containing normal map procedural texture information
  93879. * @returns a parsed Normal Map Procedural BABYLON.Texture
  93880. */
  93881. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  93882. }
  93883. }
  93884. declare module BABYLON {
  93885. /** @hidden */
  93886. export var perlinNoiseProceduralTexturePixelShader: {
  93887. name: string;
  93888. shader: string;
  93889. };
  93890. }
  93891. declare module BABYLON {
  93892. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  93893. time: number;
  93894. timeScale: number;
  93895. translationSpeed: number;
  93896. private _currentTranslation;
  93897. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93898. updateShaderUniforms(): void;
  93899. render(useCameraPostProcess?: boolean): void;
  93900. resize(size: any, generateMipMaps: any): void;
  93901. /**
  93902. * Serializes this perlin noise procedural texture
  93903. * @returns a serialized perlin noise procedural texture object
  93904. */
  93905. serialize(): any;
  93906. /**
  93907. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  93908. * @param parsedTexture defines parsed texture data
  93909. * @param scene defines the current scene
  93910. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  93911. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  93912. */
  93913. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  93914. }
  93915. }
  93916. declare module BABYLON {
  93917. /** @hidden */
  93918. export var roadProceduralTexturePixelShader: {
  93919. name: string;
  93920. shader: string;
  93921. };
  93922. }
  93923. declare module BABYLON {
  93924. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  93925. private _roadColor;
  93926. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93927. updateShaderUniforms(): void;
  93928. get roadColor(): BABYLON.Color3;
  93929. set roadColor(value: BABYLON.Color3);
  93930. /**
  93931. * Serializes this road procedural texture
  93932. * @returns a serialized road procedural texture object
  93933. */
  93934. serialize(): any;
  93935. /**
  93936. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  93937. * @param parsedTexture defines parsed texture data
  93938. * @param scene defines the current scene
  93939. * @param rootUrl defines the root URL containing road procedural texture information
  93940. * @returns a parsed Road Procedural BABYLON.Texture
  93941. */
  93942. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  93943. }
  93944. }
  93945. declare module BABYLON {
  93946. /** @hidden */
  93947. export var starfieldProceduralTexturePixelShader: {
  93948. name: string;
  93949. shader: string;
  93950. };
  93951. }
  93952. declare module BABYLON {
  93953. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  93954. private _time;
  93955. private _alpha;
  93956. private _beta;
  93957. private _zoom;
  93958. private _formuparam;
  93959. private _stepsize;
  93960. private _tile;
  93961. private _brightness;
  93962. private _darkmatter;
  93963. private _distfading;
  93964. private _saturation;
  93965. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93966. updateShaderUniforms(): void;
  93967. get time(): number;
  93968. set time(value: number);
  93969. get alpha(): number;
  93970. set alpha(value: number);
  93971. get beta(): number;
  93972. set beta(value: number);
  93973. get formuparam(): number;
  93974. set formuparam(value: number);
  93975. get stepsize(): number;
  93976. set stepsize(value: number);
  93977. get zoom(): number;
  93978. set zoom(value: number);
  93979. get tile(): number;
  93980. set tile(value: number);
  93981. get brightness(): number;
  93982. set brightness(value: number);
  93983. get darkmatter(): number;
  93984. set darkmatter(value: number);
  93985. get distfading(): number;
  93986. set distfading(value: number);
  93987. get saturation(): number;
  93988. set saturation(value: number);
  93989. /**
  93990. * Serializes this starfield procedural texture
  93991. * @returns a serialized starfield procedural texture object
  93992. */
  93993. serialize(): any;
  93994. /**
  93995. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  93996. * @param parsedTexture defines parsed texture data
  93997. * @param scene defines the current scene
  93998. * @param rootUrl defines the root URL containing startfield procedural texture information
  93999. * @returns a parsed Starfield Procedural BABYLON.Texture
  94000. */
  94001. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  94002. }
  94003. }
  94004. declare module BABYLON {
  94005. /** @hidden */
  94006. export var woodProceduralTexturePixelShader: {
  94007. name: string;
  94008. shader: string;
  94009. };
  94010. }
  94011. declare module BABYLON {
  94012. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  94013. private _ampScale;
  94014. private _woodColor;
  94015. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  94016. updateShaderUniforms(): void;
  94017. get ampScale(): number;
  94018. set ampScale(value: number);
  94019. get woodColor(): BABYLON.Color3;
  94020. set woodColor(value: BABYLON.Color3);
  94021. /**
  94022. * Serializes this wood procedural texture
  94023. * @returns a serialized wood procedural texture object
  94024. */
  94025. serialize(): any;
  94026. /**
  94027. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  94028. * @param parsedTexture defines parsed texture data
  94029. * @param scene defines the current scene
  94030. * @param rootUrl defines the root URL containing wood procedural texture information
  94031. * @returns a parsed Wood Procedural BABYLON.Texture
  94032. */
  94033. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  94034. }
  94035. }